作者:胡子壮熊_623 | 来源:互联网 | 2023-09-05 08:08
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Terraform Version
Terraform v0.10.7
Affected Resource(s)
Please list the resources as a list, for example:
- aws_security_group
- aws_instance
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| hcl
provider "aws" {
region = "us-east-1"
version = "~> 1.1"
}
variable "keypair" {}
variable "vpc_id" {}
variable "subnet_id" {}
data "aws_ami" "selected" {
most_recent = true
filter {
name = "owner-alias"
values = ["amazon"]
}
filter {
name = "name"
values = ["amzn-ami-hvm-2017.09.*"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
filter {
name = "root-device-type"
values = ["ebs"]
}
filter {
name = "block-device-mapping.volume-type"
values = ["gp2"]
}
}
output "selected_aws_ami_id" {
value = "${ data.aws_ami.selected.id }"
}
resource "aws_security_group" "repro" {
name = "TestIssue1993Repro"
vpc_id = "${ var.vpc_id }"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["10.10.10.10/32"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "TestIssue1993Repro"
}
lifecycle {
create_before_destroy = true
}
}
output "repro_aws_security_group_id" {
value = "${ aws_security_group.repro.id }"
}
resource "aws_instance" "repro" {
subnet_id = "${ var.subnet_id }"
instance_type = "t2.micro"
ami = "${ data.aws_ami.selected.id }"
security_groups = ["${ aws_security_group.repro.id }"]
key_name = "${ var.keypair }"
tags = {
Name = "TestIssue1993Repro"
}
}
output "repro_aws_instance_id" {
value = "${ aws_instance.repro.id }"
} |
Debug Output
https://gist.github.com/marklap/b814c8a91cd711e9d2c0d78d75fd7785
(Note: not debug output but should be enough support the issue and enable repro)
Panic Output
N/A
Expected Behavior
Nothing has changed in the template therefore
should return
1
| No changes. Infrastructure is up-to-date. |
.
Actual Behavior
Nothing has changed in the template yet
plans to delete the instance and recreate it because it detects that security groups have changed.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
1.
2.
Important Factoids
1 2 3
| $ terraform providers
.
└── provider.aws ~> 1.1 |
Repro was done in a VPC that is not the region
VPC.
It seems like when you create an
with a
and then create an
with a
param (instead of the
param), the
finds the VPC security group and assigns it as expected. However it's stored in the state file under
so that on the next run, only the
key is looked up to determine if a change needs to be made.
References
1993 - I believe this is the same exact issue but didn't want to litter the comments of #1993 with my repro steps.
该提问来源于开源项目:terraform-providers/terraform-provider-aws
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!