diff --git a/examples/packer-docker-example/build.json b/examples/packer-docker-example/build.json index fde5ab0c3..c0ca57750 100644 --- a/examples/packer-docker-example/build.json +++ b/examples/packer-docker-example/build.json @@ -15,7 +15,7 @@ "filters": { "virtualization-type": "hvm", "architecture": "x86_64", - "name": "*ubuntu-xenial-16.04-amd64-server-*", + "name": "*ubuntu-jammy-22.04-amd64-server-*", "block-device-mapping.volume-type": "gp2", "root-device-type": "ebs" }, @@ -27,7 +27,7 @@ },{ "name": "ubuntu-docker", "type": "docker", - "image": "gruntwork/ubuntu-test:16.04", + "image": "gruntwork/ubuntu-test:22.04", "commit": true, "changes": ["ENTRYPOINT [\"\"]"] }], diff --git a/examples/packer-docker-example/build.pkr.hcl b/examples/packer-docker-example/build.pkr.hcl index 50e36495b..afedc3279 100644 --- a/examples/packer-docker-example/build.pkr.hcl +++ b/examples/packer-docker-example/build.pkr.hcl @@ -26,7 +26,7 @@ data "amazon-ami" "aws" { filters = { architecture = "x86_64" "block-device-mapping.volume-type" = "gp2" - name = "*ubuntu-xenial-16.04-amd64-server-*" + name = "*ubuntu-jammy-22.04-amd64-server-*" root-device-type = "ebs" virtualization-type = "hvm" } @@ -48,7 +48,7 @@ source "amazon-ebs" "ubuntu-ami" { source "docker" "ubuntu-docker" { changes = ["ENTRYPOINT [\"\"]"] commit = true - image = "gruntwork/ubuntu-test:16.04" + image = "gruntwork/ubuntu-test:22.04" } build { diff --git a/examples/packer-docker-example/configure-sinatra-app.sh b/examples/packer-docker-example/configure-sinatra-app.sh index 3867aa959..0e954665d 100755 --- a/examples/packer-docker-example/configure-sinatra-app.sh +++ b/examples/packer-docker-example/configure-sinatra-app.sh @@ -11,7 +11,7 @@ sudo apt-get update sudo apt-get install -y make zlib1g-dev build-essential ruby ruby-dev echo "Installing Sinatra" -sudo gem install sinatra json --no-rdoc --no-ri +sudo gem install sinatra json echo "Moving $APP_RB_SRC to $APP_RB_DST" mkdir -p "$(dirname "$APP_RB_DST")" diff --git a/examples/terraform-asg-scp-example/main.tf b/examples/terraform-asg-scp-example/main.tf index 20c74d9e8..d665e1e48 100644 --- a/examples/terraform-asg-scp-example/main.tf +++ b/examples/terraform-asg-scp-example/main.tf @@ -107,5 +107,9 @@ data "aws_subnets" "default_subnets" { name = "vpc-id" values = [data.aws_vpc.default.id] } + filter { + name = "defaultForAz" + values = [true] + } } diff --git a/examples/terraform-redeploy-example/main.tf b/examples/terraform-redeploy-example/main.tf index 75c928568..6a3c7d9e6 100644 --- a/examples/terraform-redeploy-example/main.tf +++ b/examples/terraform-redeploy-example/main.tf @@ -96,7 +96,7 @@ data "template_file" "user_data" { } # --------------------------------------------------------------------------------------------------------------------- -# FOR THIS EXAMPLE, WE JUST RUN A PLAIN UBUNTU 16.04 AMI +# FOR THIS EXAMPLE, WE JUST RUN A PLAIN UBUNTU 22.04 AMI # --------------------------------------------------------------------------------------------------------------------- data "aws_ami" "ubuntu" { @@ -120,7 +120,7 @@ data "aws_ami" "ubuntu" { filter { name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] } } @@ -299,5 +299,9 @@ data "aws_subnets" "default" { name = "vpc-id" values = [data.aws_vpc.default.id] } + filter { + name = "defaultForAz" + values = [true] + } } diff --git a/examples/terraform-ssh-password-example/main.tf b/examples/terraform-ssh-password-example/main.tf index 1220207f9..ce53fbf71 100644 --- a/examples/terraform-ssh-password-example/main.tf +++ b/examples/terraform-ssh-password-example/main.tf @@ -102,7 +102,7 @@ data "aws_ami" "ubuntu" { filter { name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-*-amd64-server-*"] + values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] } } diff --git a/modules/aws/ami.go b/modules/aws/ami.go index 01218bcb4..44329339b 100644 --- a/modules/aws/ami.go +++ b/modules/aws/ami.go @@ -112,8 +112,9 @@ func GetMostRecentAmiIdE(t testing.TestingT, region string, ownerId string, filt } input := ec2.DescribeImagesInput{ - Filters: ec2Filters, - Owners: []*string{aws.String(ownerId)}, + Filters: ec2Filters, + IncludeDeprecated: aws.Bool(true), + Owners: []*string{aws.String(ownerId)}, } out, err := ec2Client.DescribeImages(&input) diff --git a/modules/aws/asg_test.go b/modules/aws/asg_test.go index d7c32f5d6..b6b1dda7c 100644 --- a/modules/aws/asg_test.go +++ b/modules/aws/asg_test.go @@ -74,7 +74,7 @@ func createTestEC2Instance(t *testing.T, region string, name string) ec2.Instanc imageID := GetAmazonLinuxAmi(t, region) params := &ec2.RunInstancesInput{ ImageId: aws.String(imageID), - InstanceType: aws.String("t2.micro"), + InstanceType: aws.String(GetRecommendedInstanceType(t, region, []string{"t2.micro, t3.micro", "t2.small", "t3.small"})), MinCount: aws.Int64(1), MaxCount: aws.Int64(1), } diff --git a/modules/aws/rds.go b/modules/aws/rds.go index 25afcf56f..5ec6bbf50 100644 --- a/modules/aws/rds.go +++ b/modules/aws/rds.go @@ -277,6 +277,31 @@ func instanceTypeExistsForEngineAndRegionE(client *rds.RDS, engine string, engin return false, nil } +// GetValidEngineVersion returns a string containing a valid RDS engine version for the provided region and engine type. +// This function will fail the test if no valid engine is found. +func GetValidEngineVersion(t testing.TestingT, region string, engine string, majorVersion string) string { + out, err := GetValidEngineVersionE(t, region, engine, majorVersion) + require.NoError(t, err) + return out +} + +// GetValidEngineVersionE returns a string containing a valid RDS engine version or an error if no valid version is found. +func GetValidEngineVersionE(t testing.TestingT, region string, engine string, majorVersion string) (string, error) { + client, err := NewRdsClientE(t, region) + if err != nil { + return "", err + } + input := rds.DescribeDBEngineVersionsInput{ + Engine: aws.String(engine), + EngineVersion: aws.String(majorVersion), + } + out, err := client.DescribeDBEngineVersions(&input) + if err != nil || len(out.DBEngineVersions) == 0 { + return "", err + } + return *out.DBEngineVersions[0].EngineVersion, nil +} + // ParameterForDbInstanceNotFound is an error that occurs when the parameter group specified is not found for the DB instance type ParameterForDbInstanceNotFound struct { ParameterName string diff --git a/modules/aws/rds_test.go b/modules/aws/rds_test.go index 213a22981..f9b92ca17 100644 --- a/modules/aws/rds_test.go +++ b/modules/aws/rds_test.go @@ -9,46 +9,46 @@ import ( func TestGetRecommendedRdsInstanceTypeHappyPath(t *testing.T) { type TestingScenerios struct { - name string - region string - databaseEngine string - databaseEngineVersion string - instanceTypes []string - expected string + name string + region string + databaseEngine string + engineMajorVersion string + instanceTypes []string + expected string } testingScenerios := []TestingScenerios{ { - name: "US region, mysql, first offering available", - region: "us-east-2", - databaseEngine: "mysql", - databaseEngineVersion: "8.0.32", - instanceTypes: []string{"db.t2.micro", "db.t3.micro"}, - expected: "db.t2.micro", + name: "US region, mysql, first offering available", + region: "us-east-2", + databaseEngine: "mysql", + engineMajorVersion: "8.0", + instanceTypes: []string{"db.t2.micro", "db.t3.micro", "db.t3.small"}, + expected: "db.t2.micro", }, { - name: "EU region, postgres, 2nd offering available based on region", - region: "eu-north-1", - databaseEngine: "postgres", - databaseEngineVersion: "13.5", - instanceTypes: []string{"db.t2.micro", "db.m5.large"}, - expected: "db.m5.large", + name: "EU region, postgres, 2nd offering available based on region", + region: "eu-north-1", + databaseEngine: "postgres", + engineMajorVersion: "13", + instanceTypes: []string{"db.t2.micro", "db.m5.large"}, + expected: "db.m5.large", }, { - name: "US region, oracle-ee, 2nd offering available based on db type", - region: "us-west-2", - databaseEngine: "oracle-ee", - databaseEngineVersion: "19.0.0.0.ru-2021-01.rur-2021-01.r1", - instanceTypes: []string{"db.m5d.xlarge", "db.m5.large"}, - expected: "db.m5.large", + name: "US region, oracle-ee, 2nd offering available based on db type", + region: "us-west-2", + databaseEngine: "oracle-ee", + engineMajorVersion: "19", + instanceTypes: []string{"db.m5d.xlarge", "db.m5.large"}, + expected: "db.m5d.xlarge", }, { - name: "US region, oracle-ee, 2nd offering available based on db engine version", - region: "us-west-2", - databaseEngine: "oracle-ee", - databaseEngineVersion: "19.0.0.0.ru-2021-01.rur-2021-01.r1", - instanceTypes: []string{"db.t3.micro", "db.t3.small"}, - expected: "db.t3.small", + name: "US region, oracle-ee, 2nd offering available based on db engine version", + region: "us-west-2", + databaseEngine: "oracle-ee", + engineMajorVersion: "19", + instanceTypes: []string{"db.t3.micro", "db.t3.small"}, + expected: "db.t3.small", }, } @@ -57,8 +57,8 @@ func TestGetRecommendedRdsInstanceTypeHappyPath(t *testing.T) { t.Run(scenerio.name, func(t *testing.T) { t.Parallel() - - actual, err := GetRecommendedRdsInstanceTypeE(t, scenerio.region, scenerio.databaseEngine, scenerio.databaseEngineVersion, scenerio.instanceTypes) + engineVersion := GetValidEngineVersion(t, scenerio.region, scenerio.databaseEngine, scenerio.engineMajorVersion) + actual, err := GetRecommendedRdsInstanceTypeE(t, scenerio.region, scenerio.databaseEngine, engineVersion, scenerio.instanceTypes) assert.NoError(t, err) assert.Equal(t, scenerio.expected, actual) }) @@ -122,7 +122,7 @@ func TestGetRecommendedRdsInstanceTypeErrors(t *testing.T) { region: "us-east-1", databaseEngine: "oracle-ee", databaseEngineVersion: "19.0.0.0.ru-2021-01.rur-2021-01.r1", - instanceTypes: []string{"db.r5d.large"}, + instanceTypes: []string{"db.r5a.large"}, }, { name: "No instance type available for engine version", diff --git a/modules/aws/vpc_test.go b/modules/aws/vpc_test.go index 72126eb20..b5a345ce7 100644 --- a/modules/aws/vpc_test.go +++ b/modules/aws/vpc_test.go @@ -1,7 +1,6 @@ package aws import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -81,25 +80,13 @@ func TestGetDefaultSubnetIDsForVpc(t *testing.T) { t.Parallel() region := GetRandomStableRegion(t, nil, nil) - defaultVpcBeforeSubnetCreation := GetDefaultVpc(t, region) - - // Creates a subnet in the default VPC with deferred deletion - // and fetches vpc object again - subnetName := fmt.Sprintf("%s-subnet", t.Name()) - subnet := createPrivateSubnetInDefaultVpc(t, defaultVpcBeforeSubnetCreation.Id, subnetName, region) - defer deleteSubnet(t, *subnet.SubnetId, region) defaultVpc := GetDefaultVpc(t, region) defaultSubnetIDs := GetDefaultSubnetIDsForVpc(t, *defaultVpc) assert.NotEmpty(t, defaultSubnetIDs) - // Checks that the amount of default subnets is smaller than - // total number of subnets in default vpc - assert.True(t, len(defaultSubnetIDs) < len(defaultVpc.Subnets)) availabilityZones := []string{} for _, id := range defaultSubnetIDs { - // check if the recently created subnet does not come up here - assert.NotEqual(t, id, subnet.SubnetId) // default subnets are by default public // https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html assert.True(t, IsPublicSubnet(t, id, region)) @@ -231,38 +218,6 @@ func createSubnet(t *testing.T, vpcId string, routeTableId string, region string return *createSubnetOutput.Subnet } -func createPrivateSubnetInDefaultVpc(t *testing.T, vpcId string, subnetName string, region string) ec2.Subnet { - ec2Client := NewEc2Client(t, region) - - createSubnetOutput, err := ec2Client.CreateSubnet(&ec2.CreateSubnetInput{ - CidrBlock: aws.String("172.31.172.0/24"), - VpcId: aws.String(vpcId), - TagSpecifications: []*ec2.TagSpecification{ - { - ResourceType: aws.String("subnet"), - Tags: []*ec2.Tag{ - { - Key: aws.String("Name"), - Value: aws.String(subnetName), - }, - }, - }, - }, - }) - require.NoError(t, err) - - return *createSubnetOutput.Subnet -} - -func deleteSubnet(t *testing.T, subnetId string, region string) { - ec2Client := NewEc2Client(t, region) - - _, err := ec2Client.DeleteSubnet(&ec2.DeleteSubnetInput{ - SubnetId: aws.String(subnetId), - }) - require.NoError(t, err) -} - func createVpc(t *testing.T, region string) ec2.Vpc { ec2Client := NewEc2Client(t, region) diff --git a/modules/slack/validate_test.go b/modules/slack/validate_test.go index 752d21dbb..8a5cf3173 100644 --- a/modules/slack/validate_test.go +++ b/modules/slack/validate_test.go @@ -42,7 +42,7 @@ func TestValidateSlackMessage(t *testing.T) { retry.DoWithRetry( t, "wait for slack message", - 6, 10*time.Second, + 10, 10*time.Second, func() (string, error) { err := ValidateExpectedSlackMessageE(t, token, channelID, msgTxt, 10, 5*time.Minute) return "", err diff --git a/test-docker-images/gruntwork-ubuntu-test/Dockerfile b/test-docker-images/gruntwork-ubuntu-test/Dockerfile index 6e2b22d17..a670fd3f2 100644 --- a/test-docker-images/gruntwork-ubuntu-test/Dockerfile +++ b/test-docker-images/gruntwork-ubuntu-test/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:22.04 # Reduce Docker image size per https://blog.replicated.com/refactoring-a-dockerfile-for-image-size/ # - dnsutils: Install handy DNS checking tools like dig @@ -15,8 +15,8 @@ RUN DEBIAN_FRONTEND=noninteractive \ dnsutils \ jq \ libcrypt-hcesha-perl \ - python \ - python-pip \ + python3 \ + python3-pip \ rsyslog \ software-properties-common \ sudo \ @@ -25,14 +25,9 @@ RUN DEBIAN_FRONTEND=noninteractive \ rm -rf /var/lib/apt/lists/* # Install the AWS CLI per https://docs.aws.amazon.com/cli/latest/userguide/installing.html. The last line upgrades pip -# to the latest version. Note that we need to remove python-pip before we can use the updated pip, as pip does not -# automatically remove the ubuntu managed pip. We also need to refresh the cached pip path in the current bash session so -# that it picks up the new pip. -RUN pip install --upgrade setuptools && \ - pip install --upgrade pip && \ - apt-get remove -y python-pip python-pip-whl && \ - hash pip && \ - pip install awscli --upgrade +# to the latest version. +RUN pip3 install --upgrade setuptools && \ + pip3 install awscli --upgrade # Install the latest version of Docker, Consumer Edition RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ diff --git a/test/packer_basic_example_test.go b/test/packer_basic_example_test.go index 37558ed9c..cf501a37e 100644 --- a/test/packer_basic_example_test.go +++ b/test/packer_basic_example_test.go @@ -35,7 +35,7 @@ func TestPackerBasicExample(t *testing.T) { awsRegion := terratest_aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // website::tag::1::Read Packer's template and set AWS Region variable. packerOptions := &packer.Options{ @@ -92,7 +92,7 @@ func TestPackerBasicExampleWithVarFile(t *testing.T) { awsRegion := terratest_aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Create temporary packer variable file to store aws region varFile, err := ioutil.TempFile("", "*.json") @@ -162,7 +162,7 @@ func TestPackerMultipleConcurrentAmis(t *testing.T) { awsRegion := terratest_aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := terratest_aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) packerOptions := &packer.Options{ // The path to where the Packer template is located diff --git a/test/terraform_aws_example_plan_test.go b/test/terraform_aws_example_plan_test.go index 1f7849f94..c8780b980 100644 --- a/test/terraform_aws_example_plan_test.go +++ b/test/terraform_aws_example_plan_test.go @@ -29,7 +29,7 @@ func TestTerraformAwsExamplePlan(t *testing.T) { awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // website::tag::1::Configure Terraform setting path to Terraform code, EC2 instance name, and AWS Region. We also // configure the options with default retryable errors to handle the most common retryable errors encountered in diff --git a/test/terraform_aws_rds_example_test.go b/test/terraform_aws_rds_example_test.go index 5a240c46d..354dab131 100644 --- a/test/terraform_aws_rds_example_test.go +++ b/test/terraform_aws_rds_example_test.go @@ -24,7 +24,8 @@ func TestTerraformAwsRdsExample(t *testing.T) { password := "password" // Pick a random AWS region to test in. This helps ensure your code works in all regions. awsRegion := aws.GetRandomStableRegion(t, nil, nil) - instanceType := aws.GetRecommendedRdsInstanceType(t, awsRegion, "mysql", "5.7.21", []string{"db.t2.micro", "db.t3.micro"}) + engineVersion := aws.GetValidEngineVersion(t, awsRegion, "mysql", "5.7") + instanceType := aws.GetRecommendedRdsInstanceType(t, awsRegion, "mysql", engineVersion, []string{"db.t2.micro", "db.t3.micro", "db.t3.small"}) // Construct the terraform options with default retryable errors to handle the most common retryable errors in // terraform testing. @@ -44,7 +45,7 @@ func TestTerraformAwsRdsExample(t *testing.T) { "password": password, "allocated_storage": 5, "license_model": "general-public-license", - "engine_version": "5.7.21", + "engine_version": engineVersion, "port": expectedPort, "database_name": expectedDatabaseName, "region": awsRegion, diff --git a/test/terraform_aws_ssm_example_test.go b/test/terraform_aws_ssm_example_test.go index a2a01eaf1..bcc6e3642 100644 --- a/test/terraform_aws_ssm_example_test.go +++ b/test/terraform_aws_ssm_example_test.go @@ -14,7 +14,7 @@ func TestTerraformAwsSsmExample(t *testing.T) { region := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, region, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, region, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ TerraformDir: "../examples/terraform-aws-ssm-example", diff --git a/test/terraform_http_example_test.go b/test/terraform_http_example_test.go index 2e7fd6fe2..6438f8731 100644 --- a/test/terraform_http_example_test.go +++ b/test/terraform_http_example_test.go @@ -31,7 +31,7 @@ func TestTerraformHttpExample(t *testing.T) { awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Construct the terraform options with default retryable errors to handle the most common retryable errors in // terraform testing. diff --git a/test/terraform_packer_example_test.go b/test/terraform_packer_example_test.go index 74bea07a7..3afd72162 100644 --- a/test/terraform_packer_example_test.go +++ b/test/terraform_packer_example_test.go @@ -67,7 +67,7 @@ func TestTerraformPackerExample(t *testing.T) { // Build the AMI in packer-docker-example func buildAMI(t *testing.T, awsRegion string, workingDir string) { // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) packerOptions := &packer.Options{ // The path to where the Packer template is located @@ -120,7 +120,7 @@ func deployUsingTerraform(t *testing.T, awsRegion string, workingDir string) { instanceText := fmt.Sprintf("Hello, %s!", uniqueID) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Load the AMI ID saved by the earlier build_ami stage amiID := test_structure.LoadAmiId(t, workingDir) diff --git a/test/terraform_redeploy_example_test.go b/test/terraform_redeploy_example_test.go index 01e6b4933..4fb5edaa0 100644 --- a/test/terraform_redeploy_example_test.go +++ b/test/terraform_redeploy_example_test.go @@ -89,7 +89,7 @@ func initialDeploy(t *testing.T, awsRegion string, workingDir string) { text := fmt.Sprintf("Hello, %s!", uniqueID) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Construct the terraform options with default retryable errors to handle the most common retryable errors in // terraform testing. @@ -129,7 +129,7 @@ func validateAsgRunningWebServer(t *testing.T, awsRegion string, workingDir stri // Wait and verify the ASG is scaled to the desired capacity. It can take a few minutes for the ASG to boot up, so // retry a few times. maxRetries := 30 - timeBetweenRetries := 5 * time.Second + timeBetweenRetries := 10 * time.Second aws.WaitForCapacity(t, asgName, awsRegion, maxRetries, timeBetweenRetries) capacityInfo := aws.GetCapacityInfoForAsg(t, asgName, awsRegion) assert.Equal(t, capacityInfo.DesiredCapacity, int64(3)) diff --git a/test/terraform_remote_exec_example_test.go b/test/terraform_remote_exec_example_test.go index 91f8cfa3c..b99a871ca 100644 --- a/test/terraform_remote_exec_example_test.go +++ b/test/terraform_remote_exec_example_test.go @@ -55,7 +55,7 @@ func TestTerraformRemoteExecExample(t *testing.T) { awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Create an EC2 KeyPair that we can use for SSH access keyPairName := fmt.Sprintf("terratest-remote-exec-example-%s", uniqueID) diff --git a/test/terraform_scp_example_test.go b/test/terraform_scp_example_test.go index 5bac6d156..c6bdc7a86 100644 --- a/test/terraform_scp_example_test.go +++ b/test/terraform_scp_example_test.go @@ -83,7 +83,7 @@ func createTerraformOptions(t *testing.T, exampleFolder string) (*terraform.Opti awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Create an EC2 KeyPair that we can use for SSH access keyPairName := fmt.Sprintf("terratest-asg-scp-example-%s", uniqueID) diff --git a/test/terraform_ssh_example_test.go b/test/terraform_ssh_example_test.go index 02d139cbb..d1a3fc5c5 100644 --- a/test/terraform_ssh_example_test.go +++ b/test/terraform_ssh_example_test.go @@ -73,7 +73,7 @@ func configureTerraformOptions(t *testing.T, exampleFolder string) (*terraform.O awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Create an EC2 KeyPair that we can use for SSH access keyPairName := fmt.Sprintf("terratest-ssh-example-%s", uniqueID) diff --git a/test/terraform_ssh_password_example_test.go b/test/terraform_ssh_password_example_test.go index e044b5c7e..1194301d2 100644 --- a/test/terraform_ssh_password_example_test.go +++ b/test/terraform_ssh_password_example_test.go @@ -61,7 +61,7 @@ func configureTerraformSshPasswordOptions(t *testing.T, exampleFolder string) *t awsRegion := aws.GetRandomStableRegion(t, nil, nil) // Some AWS regions are missing certain instance types, so pick an available type based on the region we picked - instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro", "t3.micro"}) + instanceType := aws.GetRecommendedInstanceType(t, awsRegion, []string{"t2.micro, t3.micro", "t2.small", "t3.small"}) // Create a random password that we can use for SSH access. password := random.UniqueId() @@ -98,7 +98,7 @@ func testSSHPasswordToPublicHost(t *testing.T, terraformOptions *terraform.Optio // It can take a minute or so for the instance to boot up, so retry a few times. maxRetries := 30 - timeBetweenRetries := 5 * time.Second + timeBetweenRetries := 10 * time.Second description := fmt.Sprintf("SSH to public host %s", publicInstanceIP) // Run a simple echo command on the server.