Skip to content

Commit

Permalink
Merge pull request #14148 from YakDriver/hardami-autoscaleattach
Browse files Browse the repository at this point in the history
Removed hardcoded AMI IDs from AutoscalingAttachment
  • Loading branch information
YakDriver authored Jul 16, 2020
2 parents e11ab5c + 8e5f0cb commit d182a80
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions aws/resource_aws_autoscaling_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,16 @@ func testAccCheckAWSAutocalingAlbAttachmentExists(asgname string, targetGroupCou
}

func testAccAWSAutoscalingAttachment_alb(rInt int) string {
return fmt.Sprintf(`
return testAccLatestAmazonLinuxHvmEbsAmiConfig() + fmt.Sprintf(`
data "aws_availability_zones" "available" {
state = "available"
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
resource "aws_lb_target_group" "test" {
name = "test-alb-%d"
port = 443
Expand Down Expand Up @@ -236,7 +245,7 @@ resource "aws_lb_target_group" "another_test" {
}
resource "aws_autoscaling_group" "asg" {
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
availability_zones = data.aws_availability_zones.available.names
name = "asg-lb-assoc-terraform-test_%d"
max_size = 1
min_size = 0
Expand All @@ -258,7 +267,7 @@ resource "aws_autoscaling_group" "asg" {
resource "aws_launch_configuration" "as_conf" {
name = "test_config_%d"
image_id = "ami-f34032c3"
image_id = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
instance_type = "t1.micro"
}
Expand All @@ -273,9 +282,18 @@ resource "aws_vpc" "test" {
}

func testAccAWSAutoscalingAttachment_elb(rInt int) string {
return fmt.Sprintf(`
return testAccLatestAmazonLinuxHvmEbsAmiConfig() + fmt.Sprintf(`
data "aws_availability_zones" "available" {
state = "available"
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
resource "aws_elb" "foo" {
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
availability_zones = data.aws_availability_zones.available.names
listener {
instance_port = 8000
Expand All @@ -286,7 +304,7 @@ resource "aws_elb" "foo" {
}
resource "aws_elb" "bar" {
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
availability_zones = data.aws_availability_zones.available.names
listener {
instance_port = 8000
Expand All @@ -298,12 +316,12 @@ resource "aws_elb" "bar" {
resource "aws_launch_configuration" "as_conf" {
name = "test_config_%d"
image_id = "ami-f34032c3"
image_id = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "asg" {
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
availability_zones = data.aws_availability_zones.available.names
name = "asg-lb-assoc-terraform-test_%d"
max_size = 1
min_size = 0
Expand Down

0 comments on commit d182a80

Please sign in to comment.