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

"-target" doesn't work with modules #1434

Closed
radeksimko opened this issue Apr 8, 2015 · 6 comments · Fixed by #1820
Closed

"-target" doesn't work with modules #1434

radeksimko opened this issue Apr 8, 2015 · 6 comments · Fixed by #1820
Assignees

Comments

@radeksimko
Copy link
Member

I'm not sure if this is a bug or a feature, but -target does not work with modules. See below:

sample.tf:

variable "aws_region" {
  default = "eu-west-1"
  description = "AWS Region"
}

provider "aws" {
  access_key = ""
  secret_key = ""
  region = "${var.aws_region}"
}

module "vpc" {
  source = "github.com/terraform-community-modules/tf_aws_vpc"

  aws_access_key = ""
  aws_secret_key = ""
  aws_region = "${var.aws_region}"
  environment_name = "dev"
  cidr_block = "10.10.0.0/16"
  mytag = ""
}
$ terraform plan
Refreshing Terraform state prior to plan...


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ module.vpc
    1 resource(s)
$ terraform plan -target=module.vpc
Refreshing Terraform state prior to plan...


No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.
@knuckolls
Copy link
Contributor

We encountered this yesterday as well. It would be nice to be able to target an entire module.

@radeksimko
Copy link
Member Author

I reckon it has something to do with the fact that all dependencies are currently based on resources and module is not a resource, which is also the reason for #538 and #1178

@radeksimko
Copy link
Member Author

btw. I thought I'm gonna get around that, but this doesn't work either:

$ terraform plan -target=module.vpc.null_resource.null

nor this

$ terraform plan -target=module.vpc.aws_vpc.vpc
There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  * Problem parsing address: "module.vpc.aws_vpc.vpc"

@clstokes
Copy link
Contributor

+1 this is currently impacting us.

@jszwedko
Copy link
Contributor

Ditto 👍 -- modules not being in the same graph as the root resources is causing us a lot of pain (also with dependency resolution).

@phinze phinze self-assigned this Apr 30, 2015
phinze added a commit that referenced this issue May 6, 2015
Adds the ability to target resources within modules, like:

module.mymod.aws_instance.foo

And the ability to target all resources inside a module, like:

module.mymod

Closes #1434
@ghost
Copy link

ghost commented May 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants