“ aws_ami”具有most_recent = true是否会影响将来的更新?

问题描述 投票:1回答:1

给出下面的配置,如果Amazon推出了新版本的AMI,如果我对基础架构运行apply命令,会发生什么?

test实例将被销毁并重新创建吗?

如此场景

  1. terrain init
  2. 适用于地形
  3. 等待N个月
  4. 地形计划(或适用)

我会看到N个月前使用当时较“新”的AMI较旧版本创建的ec2实例的“强制”再现吗?

data "aws_ami" "amazon-linux-2" {
 most_recent = true

 filter {
   name   = "owner-alias"
   values = ["amazon"]
 }


 filter {
   name   = "name"
   values = ["amzn2-ami-hvm*"]
 }
}


resource "aws_instance" "test" {
 depends_on = ["aws_internet_gateway.test"]


 ami                         = "${data.aws_ami.amazon-linux-2.id}"
 associate_public_ip_address = true
 iam_instance_profile        = "${aws_iam_instance_profile.test.id}"
 instance_type               = "t2.micro"
 key_name                    = "bflad-20180605"
 vpc_security_group_ids      = ["${aws_security_group.test.id}"]
 subnet_id                   = "${aws_subnet.test.id}"
}

具有most_recent = true的“ aws_ami”会影响以后的更新吗?

terraform terraform-provider-aws terraform0.12+
1个回答
0
投票

是的,按照@ydaetskcoR所说,您可以查看ignore_changes生命周期,然后它不会重新创建实例。 https://www.terraform.io/docs/configuration/resources.html#ignore_changes

© www.soinside.com 2019 - 2024. All rights reserved.