Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using -target in terraformOptions #191

Closed
BensamV opened this issue Nov 2, 2018 · 2 comments
Closed

Add support for using -target in terraformOptions #191

BensamV opened this issue Nov 2, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@BensamV
Copy link

BensamV commented Nov 2, 2018

I have 2 modules in my terraform file and would like to invoke only one module from the terraform file via my Terratest suite. Unfortunately, there is no support in Terratest for this.

Ideally in my test suite, I would want to call the first module via -target and then call the second module via -target, thereby I can test upgrading to v1.4.6 does not cause any issues.

Terraform does not support using 'count' on modules yet and hence this feature to use -target in terraformOptions of Terratest will be of great help.

Terraform Module

provider "aws" {
region = "${var.region}"
}

module "aws_s3_previous" {
#Testing source from this module
//count = "${var.current == false ? 1: 0}"
source = "git::ssh://xxxx-xxxxxx-xxxxxxxx-xxxxxx-bucket.git?ref=v1.4.5"
region = "${var.region}"
app_name = "${var.app_name}"
owner = "${var.owner}"
allow_force_destroy = "${var.allow_force_destroy}"
}

module "aws_s3_current" {
#Testing source from this module
//count = "${var.current == true ? 1: 0}"
source = "git::ssh://xxxx-xxxxxx-xxxxxxxx-xxxxxx-bucket.git?ref=v1.4.6"
region = "${var.region}"
app_name = "${var.app_name}"
owner = "${var.owner}"
allow_force_destroy = "${var.allow_force_destroy}"
}

terraform {
backend "local" {
path = "../stateFiles/terraform.tfstate"
}
}

Use case

Ability to do "terraform apply -target=${module.aws_s3_previous}" in Terratest.

@BensamV BensamV changed the title Terratest can support using -target option in terraformOptions Add support for using -target in terraformOptions Nov 2, 2018
@brikis98 brikis98 added enhancement New feature or request help wanted labels Nov 2, 2018
@brikis98
Copy link
Member

brikis98 commented Nov 2, 2018

Sure, a PR for that would be welcome. You could add it to terraform.Options and if set, add the appropriate CLI args.

@BensamV
Copy link
Author

BensamV commented Feb 1, 2020

This must be closed

@BensamV BensamV closed this as completed Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants