From f9d6f7343bda9bdb02b5a1215a79fdcae845772e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 23 Jul 2020 11:00:19 -0400 Subject: [PATCH] Remove hardcoded AMI and AZ --- ...rce_aws_autoscaling_lifecycle_hook_test.go | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/aws/resource_aws_autoscaling_lifecycle_hook_test.go b/aws/resource_aws_autoscaling_lifecycle_hook_test.go index 41f04ed1087..5850b296c7a 100644 --- a/aws/resource_aws_autoscaling_lifecycle_hook_test.go +++ b/aws/resource_aws_autoscaling_lifecycle_hook_test.go @@ -125,10 +125,10 @@ func testAccAWSAutoscalingLifecycleHookImportStateIdFunc(resourceName string) re } func testAccAWSAutoscalingLifecycleHookConfig(name string) string { - return fmt.Sprintf(` + return testAccLatestAmazonLinuxHvmEbsAmiConfig() + fmt.Sprintf(` resource "aws_launch_configuration" "foobar" { name = "%s" - image_id = "ami-21f78e11" + image_id = data.aws_ami.amzn-ami-minimal-hvm-ebs.id instance_type = "t1.micro" } @@ -177,8 +177,17 @@ resource "aws_iam_role_policy" "foobar" { EOF } +data "aws_availability_zones" "available" { + state = "available" + + filter { + name = "opt-in-status" + values = ["opt-in-not-required"] + } +} + resource "aws_autoscaling_group" "foobar" { - availability_zones = ["us-west-2a"] + availability_zones = [data.aws_availability_zones.available.names[1]] name = "%s" max_size = 5 min_size = 2 @@ -215,10 +224,10 @@ EOF } func testAccAWSAutoscalingLifecycleHookConfig_omitDefaultResult(name string, rInt int) string { - return fmt.Sprintf(` + return testAccLatestAmazonLinuxHvmEbsAmiConfig() + fmt.Sprintf(` resource "aws_launch_configuration" "foobar" { name = "%s" - image_id = "ami-21f78e11" + image_id = data.aws_ami.amzn-ami-minimal-hvm-ebs.id instance_type = "t1.micro" } @@ -267,8 +276,17 @@ resource "aws_iam_role_policy" "foobar" { EOF } +data "aws_availability_zones" "available" { + state = "available" + + filter { + name = "opt-in-status" + values = ["opt-in-not-required"] + } +} + resource "aws_autoscaling_group" "foobar" { - availability_zones = ["us-west-2a"] + availability_zones = [data.aws_availability_zones.available.names[1]] name = "%s" max_size = 5 min_size = 2