Hello,
Every time I run
1 | terraform apply |
my elastic beanstalk environment is marked for update, which in turn re-creates my environment. This is clearly undesirable behavior.
1 | Terraform v0.10.2 |
1 2 3 4 5 6 7 8 9 10 11 | hcl resource "aws_elastic_beanstalk_environment" "backend" { name = "backend-${var.environment}" application = "backend" solution_stack_name = "64bit Amazon Linux 2017.03 v2.4.3 running PHP 5.6" tier = "WebServer" setting { ... } } |
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 90 | ~ module.ums.aws_elastic_beanstalk_environment.backend setting.#: "19" => "20" setting.1224657411.name: "SSHSourceRestriction" => "" setting.1224657411.namespace: "aws:autoscaling:launchconfiguration" => "" setting.1224657411.resource: "" => "" setting.1224657411.value: "tcp,22,22,null" => "" setting.1311926541.name: "RollingUpdateEnabled" => "RollingUpdateEnabled" setting.1311926541.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate" setting.1311926541.resource: "" => "" setting.1311926541.value: "true" => "true" setting.1531156480.name: "Application Healthcheck URL" => "" setting.1531156480.namespace: "aws:elasticbeanstalk:application" => "" setting.1531156480.resource: "" => "" setting.1531156480.value: "/elb-status" => "" setting.1636165274.name: "EC2KeyName" => "EC2KeyName" setting.1636165274.namespace: "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration" setting.1636165274.resource: "" => "" setting.1636165274.value: "key" => "key" setting.2276893638.name: "RollingUpdateType" => "RollingUpdateType" setting.2276893638.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate" setting.2276893638.resource: "" => "" setting.2276893638.value: "Health" => "Health" setting.2396587397.name: "MinSize" => "MinSize" setting.2396587397.namespace: "aws:autoscaling:asg" => "aws:autoscaling:asg" setting.2396587397.resource: "" => "" setting.2396587397.value: "1" => "1" setting.2420299722.name: "SystemType" => "SystemType" setting.2420299722.namespace: "aws:elasticbeanstalk:healthreporting:system" => "aws:elasticbeanstalk:healthreporting:system" setting.2420299722.resource: "" => "" setting.2420299722.value: "enhanced" => "enhanced" setting.2558992023.name: "ManagedActionsEnabled" => "ManagedActionsEnabled" setting.2558992023.namespace: "aws:elasticbeanstalk:managedactions" => "aws:elasticbeanstalk:managedactions" setting.2558992023.resource: "" => "" setting.2558992023.value: "true" => "true" setting.2671587030.name: "Subnets" => "Subnets" setting.2671587030.namespace: "aws:ec2:vpc" => "aws:ec2:vpc" setting.2671587030.resource: "" => "" setting.2671587030.value: "subnet-3630230b,subnet-6a798c23,subnet-6d116547,subnet-8ea1a4d6" => "subnet-3630230b,subnet-6a798c23,subnet-6d116547,subnet-8ea1a4d6" setting.2808638165.name: "PreferredStartTime" => "PreferredStartTime" setting.2808638165.namespace: "aws:elasticbeanstalk:managedactions" => "aws:elasticbeanstalk:managedactions" setting.2808638165.resource: "" => "" setting.2808638165.value: "Sun:02:00" => "Sun:02:00" setting.2983186660.name: "UpdateLevel" => "UpdateLevel" setting.2983186660.namespace: "aws:elasticbeanstalk:managedactions:platformupdate" => "aws:elasticbeanstalk:managedactions:platformupdate" setting.2983186660.resource: "" => "" setting.2983186660.value: "minor" => "minor" setting.3007260544.name: "AssociatePublicIpAddress" => "AssociatePublicIpAddress" setting.3007260544.namespace: "aws:ec2:vpc" => "aws:ec2:vpc" setting.3007260544.resource: "" => "" setting.3007260544.value: "true" => "true" setting.3172159480.name: "ELBSubnets" => "ELBSubnets" setting.3172159480.namespace: "aws:ec2:vpc" => "aws:ec2:vpc" setting.3172159480.resource: "" => "" setting.3172159480.value: "subnet-3630230b,subnet-6a798c23,subnet-6d116547,subnet-8ea1a4d6" => "subnet-3630230b,subnet-6a798c23,subnet-6d116547,subnet-8ea1a4d6" setting.3225151102.name: "MaxSize" => "MaxSize" setting.3225151102.namespace: "aws:autoscaling:asg" => "aws:autoscaling:asg" setting.3225151102.resource: "" => "" setting.3225151102.value: "2" => "2" setting.3276487710.name: "" => "Application Healthcheck URL" setting.3276487710.namespace: "" => "aws:elasticbeanstalk:application" setting.3276487710.resource: "" => "" setting.3276487710.value: "" => "HTTP:80/elb-status" setting.335963092.name: "" => "DBSubnets" setting.335963092.namespace: "" => "aws:ec2:vpc" setting.335963092.resource: "" => "" setting.335963092.value: "" => "subnet-3630230b,subnet-6a798c23,subnet-6d116547,subnet-8ea1a4d6" setting.337125008.name: "" => "SSHSourceRestriction" setting.337125008.namespace: "" => "aws:autoscaling:launchconfiguration" setting.337125008.resource: "" => "" setting.337125008.value: "" => "tcp, 22, 22, sg-9f9946e4" setting.37040285.name: "ServiceRole" => "ServiceRole" setting.37040285.namespace: "aws:elasticbeanstalk:environment" => "aws:elasticbeanstalk:environment" setting.37040285.resource: "" => "" setting.37040285.value: "aws-elasticbeanstalk-service-role" => "aws-elasticbeanstalk-service-role" setting.3909253589.name: "VPCId" => "VPCId" setting.3909253589.namespace: "aws:ec2:vpc" => "aws:ec2:vpc" setting.3909253589.resource: "" => "" setting.3909253589.value: "vpc-581ad93f" => "vpc-581ad93f" setting.417274623.name: "InstanceType" => "InstanceType" setting.417274623.namespace: "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration" setting.417274623.resource: "" => "" setting.417274623.value: "m3.medium" => "m3.medium" setting.43215759.name: "SecurityGroups" => "SecurityGroups" setting.43215759.namespace: "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration" setting.43215759.resource: "" => "" setting.43215759.value: "sg-b445c3c4" => "sg-b445c3c4" setting.733236782.name: "IamInstanceProfile" => "IamInstanceProfile" setting.733236782.namespace: "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration" setting.733236782.resource: "" => "" setting.733236782.value: "profile" => "profile" |
No change should be detected
Terraform thinks I've made a change
1 | terraform apply |
1 | terraform apply |
again with no changes
该提问来源于开源项目:hashicorp/terraform-provider-aws
One other thing I just noticed was that when you have lists of things (subnets, security groups), sometimes they come back in a different order than your TF config specifies, so it detects a diff every time. Reorder the entries in the value to match what's coming back, and it should be set. That, plus the
1 | resource = "" |
hack is what fixed it all for me.