热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

vpcsecuritygroupandvpcinstancetriggerrecreatewhentherearenotemplatechanges

Hithere,Thankyouforopeninganissue.PleasenotethatwetrytokeeptheTerr

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

1
terraform plan

should return

1
No changes. Infrastructure is up-to-date.

.

Actual Behavior

Nothing has changed in the template yet

1
terraform plan

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.

1
terraform apply

2.

1
terraform plan

Important Factoids

1
2
3
$ terraform providers

.

└── provider.aws ~> 1.1

Repro was done in a VPC that is not the region

1
default

VPC.

It seems like when you create an

1
aws_security_group

with a

1
vpc_id

and then create an

1
aws_instance

with a

1
security_group

param (instead of the

1
vpc_security_group_ids

param), the

1
aws_instance

finds the VPC security group and assigns it as expected. However it's stored in the state file under

1
vpc_security_group_ids

so that on the next run, only the

1
security_groups

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!


推荐阅读
author-avatar
胡子壮熊_623
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有