./terraform -v
Terraform v0.9.4
Please list the resources as a list, for example:
test1.tf
provider "aws" {
region = "ca-central-1"
}
module "test1" {
source = "test1"
}
test1/main.tf
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
}
test2.tf
provider "aws" {
region = "ca-central-1"
}
test1/main.tf
provider "aws" {
region = "ca-central-1"
}
module "test1" {
source = "test1"
}
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
}
As per the docs only the specified target and dependencies should be planned.
-target=resource Resource to target. Operation will be limited to this
resource and its dependencies. This flag can be used
multiple times.
Scenario 1
Terraform is is looking at all files in the directory not just those targeted, creating a conflict with multiple providers being declared.
Scenario 2
Terraform is looking for a configuration file in the current directory, not just the targeted directory.
Please list the steps required to reproduce the issue, for example:
Scenario 1
terraform plan -target=test1.tf
1 error(s) occurred:
* module root: 1 error(s) occurred:
* provider.aws: declared multiple times, you can only declare a provider once
Scenario 2
./terraform plan -target=test1/
No configuration files found!
Plan requires configuration to be present. Planning without a configuration
would mark everything for destruction, which is normally not what is desired.
If you would like to destroy everything, please run plan with the "-destroy"
flag or create a single empty configuration file. Otherwise, please create
a Terraform configuration file in the path being executed and try again.
Hello โย The syntax for -target
is to supply Resource address
Example:
$ terraform plan -target=aws_instance.example
Terraform still needs to load all the files for your infrastructure to find the resource in question, however it limits it's plan
/ apply
operations to just those resources specified, and any dependencies that would require changes as well
There is bad logic inside.
I think,
-target=path_to_dir/
-target=file.tf
is more logically than -target=aws_instance.example
For resources will be great specify
-resource=aws_instance.example
terraform state list
is a great way to see all the modules that are available as targets for terraform plan -target=module.name
.
anyone have this for azure?
what is the format to feed to multiple resources at same time as list.. similarly would it support multiple module to be input at same time ?
@surajn03 you simply specify -target=resourceX
multiple times for each module.name
that shows in terraform state list
.
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.
Most helpful comment
There is bad logic inside.
I think,
-target=path_to_dir/
-target=file.tf
is more logically than -target=aws_instance.example
For resources will be great specify
-resource=aws_instance.example