diff --git a/pkg/resource/aws/aws_dynamodb_table_test.go b/pkg/resource/aws/aws_dynamodb_table_test.go index 46ad17fe1..3706b1930 100644 --- a/pkg/resource/aws/aws_dynamodb_table_test.go +++ b/pkg/resource/aws/aws_dynamodb_table_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsDynamoDBTable(t *testing.T) { +func TestAcc_Aws_DynamoDBTable(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_dynamodb_table"}, diff --git a/pkg/resource/aws/aws_ecr_repository_test.go b/pkg/resource/aws/aws_ecr_repository_test.go index d88dce5f5..d2afd53be 100644 --- a/pkg/resource/aws/aws_ecr_repository_test.go +++ b/pkg/resource/aws/aws_ecr_repository_test.go @@ -15,7 +15,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsECRRepository(t *testing.T) { +func TestAcc_Aws_ECRRepository(t *testing.T) { var mutatedRepositoryID string acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", diff --git a/pkg/resource/aws/aws_eip_test.go b/pkg/resource/aws/aws_eip_test.go index 1f16ad5fc..01293acbc 100644 --- a/pkg/resource/aws/aws_eip_test.go +++ b/pkg/resource/aws/aws_eip_test.go @@ -22,6 +22,17 @@ func TestAcc_Aws_Eip(t *testing.T) { Env: map[string]string{ "AWS_REGION": "us-east-1", }, + // New resources are not visible immediately through AWS API after an apply operation + // (e.g. error attaching EC2 Internet Gateway) + // Logic below retries driftctl scan using a back-off strategy of retrying 'n' times + // and doubling the amount of time waited after each one. + ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool { + if result.IsSync() || retryDuration > 10*time.Minute { + return false + } + time.Sleep((2 * time.Duration(retryCount)) * time.Minute) + return true + }, Check: func(result *test.ScanResult, stdout string, err error) { if err != nil { t.Fatal(err) diff --git a/pkg/resource/aws/aws_iam_policy_attachment_test.go b/pkg/resource/aws/aws_iam_policy_attachment_test.go index 70a071289..45cd7a52d 100644 --- a/pkg/resource/aws/aws_iam_policy_attachment_test.go +++ b/pkg/resource/aws/aws_iam_policy_attachment_test.go @@ -7,13 +7,16 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsIamPolicyAttachment_WithGroupsUsers(t *testing.T) { +func TestAcc_Aws_IamPolicyAttachment_WithGroupsUsers(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_iam_policy_attachment"}, Args: []string{"scan", "--deep"}, Checks: []acceptance.AccCheck{ { + Env: map[string]string{ + "AWS_REGION": "us-east-1", + }, Check: func(result *test.ScanResult, stdout string, err error) { if err != nil { t.Fatal(err) diff --git a/pkg/resource/aws/aws_instance_test.go b/pkg/resource/aws/aws_instance_test.go index 9ca01e524..6f658f024 100644 --- a/pkg/resource/aws/aws_instance_test.go +++ b/pkg/resource/aws/aws_instance_test.go @@ -14,7 +14,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsInstance(t *testing.T) { +func TestAcc_Aws_Instance(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_instance_default"}, @@ -39,7 +39,7 @@ func TestAcc_AwsInstance(t *testing.T) { }) } -func TestAcc_AwsInstance_WithBlockDevices(t *testing.T) { +func TestAcc_Aws_Instance_WithBlockDevices(t *testing.T) { var mutatedInstanceId string acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", diff --git a/pkg/resource/aws/aws_internet_gateway_test.go b/pkg/resource/aws/aws_internet_gateway_test.go index 197192d46..b7915ae76 100644 --- a/pkg/resource/aws/aws_internet_gateway_test.go +++ b/pkg/resource/aws/aws_internet_gateway_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsInternetGateway(t *testing.T) { +func TestAcc_Aws_InternetGateway(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_internet_gateway"}, @@ -22,6 +22,17 @@ func TestAcc_AwsInternetGateway(t *testing.T) { Env: map[string]string{ "AWS_REGION": "us-east-1", }, + // New resources are not visible immediately through AWS API after an apply operation + // (e.g. InvalidVpcID.NotFound) + // Logic below retries driftctl scan using a back-off strategy of retrying 'n' times + // and doubling the amount of time waited after each one. + ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool { + if result.IsSync() || retryDuration > 10*time.Minute { + return false + } + time.Sleep((2 * time.Duration(retryCount)) * time.Minute) + return true + }, Check: func(result *test.ScanResult, stdout string, err error) { if err != nil { t.Fatal(err) diff --git a/pkg/resource/aws/aws_lambda_event_source_mapping_test.go b/pkg/resource/aws/aws_lambda_event_source_mapping_test.go index 832504d0b..fd046a762 100644 --- a/pkg/resource/aws/aws_lambda_event_source_mapping_test.go +++ b/pkg/resource/aws/aws_lambda_event_source_mapping_test.go @@ -10,7 +10,7 @@ import ( // aws lambda list-event-source-mappings to list all event source mappings // aws lambda delete-event-source-mapping --uuid xxx to delete a specific event source mapping -func TestAcc_AwsLambdaEventSourceMapping(t *testing.T) { +func TestAcc_Aws_LambdaEventSourceMapping(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_lambda_event_source_mapping"}, diff --git a/pkg/resource/aws/aws_launch_configuration_test.go b/pkg/resource/aws/aws_launch_configuration_test.go index fbdd24c3d..c258b8660 100644 --- a/pkg/resource/aws/aws_launch_configuration_test.go +++ b/pkg/resource/aws/aws_launch_configuration_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsLaunchConfiguration(t *testing.T) { +func TestAcc_Aws_LaunchConfiguration(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_launch_configuration"}, diff --git a/pkg/resource/aws/aws_launch_template_test.go b/pkg/resource/aws/aws_launch_template_test.go index ce5660a7e..ee5640921 100644 --- a/pkg/resource/aws/aws_launch_template_test.go +++ b/pkg/resource/aws/aws_launch_template_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsLaunchTemplate(t *testing.T) { +func TestAcc_Aws_LaunchTemplate(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_launch_template"}, diff --git a/pkg/resource/aws/aws_nat_gateway_test.go b/pkg/resource/aws/aws_nat_gateway_test.go index ad73c1841..9ea13cf01 100644 --- a/pkg/resource/aws/aws_nat_gateway_test.go +++ b/pkg/resource/aws/aws_nat_gateway_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsNATGateway(t *testing.T) { +func TestAcc_Aws_NATGateway(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_nat_gateway"}, diff --git a/pkg/resource/aws/aws_network_acl_test.go b/pkg/resource/aws/aws_network_acl_test.go index 8a23e3d0d..1b81e3f72 100644 --- a/pkg/resource/aws/aws_network_acl_test.go +++ b/pkg/resource/aws/aws_network_acl_test.go @@ -2,6 +2,7 @@ package aws_test import ( "testing" + "time" "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/acceptance" @@ -41,6 +42,17 @@ func TestAcc_Aws_NetworkAcl_NonDeep(t *testing.T) { Env: map[string]string{ "AWS_REGION": "us-east-1", }, + // New resources are not visible immediately through AWS API after an apply operation + // (e.g. InvalidNetworkAclID.NotFound) + // Logic below retries driftctl scan using a back-off strategy of retrying 'n' times + // and doubling the amount of time waited after each one. + ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool { + if result.IsSync() || retryDuration > 10*time.Minute { + return false + } + time.Sleep((2 * time.Duration(retryCount)) * time.Minute) + return true + }, Check: func(result *test.ScanResult, stdout string, err error) { if err != nil { t.Fatal(err) diff --git a/pkg/resource/aws/aws_route53_health_check_test.go b/pkg/resource/aws/aws_route53_health_check_test.go index 41175c139..45a603349 100644 --- a/pkg/resource/aws/aws_route53_health_check_test.go +++ b/pkg/resource/aws/aws_route53_health_check_test.go @@ -14,7 +14,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsRoute53HealthCheck(t *testing.T) { +func TestAcc_Aws_Route53HealthCheck(t *testing.T) { var mutatedHealthCheckID string acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", diff --git a/pkg/resource/aws/aws_route53_record_test.go b/pkg/resource/aws/aws_route53_record_test.go index 0f4cc04b3..138cd21c2 100644 --- a/pkg/resource/aws/aws_route53_record_test.go +++ b/pkg/resource/aws/aws_route53_record_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsRoute53Record_WithFQDNAsId(t *testing.T) { +func TestAcc_Aws_Route53Record_WithFQDNAsId(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_route53_record"}, @@ -30,13 +30,16 @@ func TestAcc_AwsRoute53Record_WithFQDNAsId(t *testing.T) { }) } -func TestAcc_AwsRoute53Record_WithAlias(t *testing.T) { +func TestAcc_Aws_Route53Record_WithAlias(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_route53_record_with_alias"}, Args: []string{"scan", "--deep"}, Checks: []acceptance.AccCheck{ { + Env: map[string]string{ + "AWS_REGION": "us-east-1", + }, Check: func(result *test.ScanResult, stdout string, err error) { if err != nil { t.Fatal(err) diff --git a/pkg/resource/aws/aws_route_table_association_test.go b/pkg/resource/aws/aws_route_table_association_test.go index c6b126c4d..cda6868c4 100644 --- a/pkg/resource/aws/aws_route_table_association_test.go +++ b/pkg/resource/aws/aws_route_table_association_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsRouteTableAssociation(t *testing.T) { +func TestAcc_Aws_RouteTableAssociation(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_route_table_association"}, diff --git a/pkg/resource/aws/aws_route_table_test.go b/pkg/resource/aws/aws_route_table_test.go index 01dedf2f8..705de4b49 100644 --- a/pkg/resource/aws/aws_route_table_test.go +++ b/pkg/resource/aws/aws_route_table_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsRouteTable(t *testing.T) { +func TestAcc_Aws_RouteTable(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_route_table"}, diff --git a/pkg/resource/aws/aws_route_test.go b/pkg/resource/aws/aws_route_test.go index 6563f7979..4f556e9f4 100644 --- a/pkg/resource/aws/aws_route_test.go +++ b/pkg/resource/aws/aws_route_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsRoute(t *testing.T) { +func TestAcc_Aws_Route(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_route"}, diff --git a/pkg/resource/aws/aws_s3_bucket_test.go b/pkg/resource/aws/aws_s3_bucket_test.go index 976193a11..f9d478d2e 100644 --- a/pkg/resource/aws/aws_s3_bucket_test.go +++ b/pkg/resource/aws/aws_s3_bucket_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsS3Bucket_BucketInUsEast1(t *testing.T) { +func TestAcc_Aws_S3Bucket_BucketInUsEast1(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_s3_bucket"}, diff --git a/pkg/resource/aws/aws_security_group_test.go b/pkg/resource/aws/aws_security_group_test.go index 0bea02199..d7f0b0026 100644 --- a/pkg/resource/aws/aws_security_group_test.go +++ b/pkg/resource/aws/aws_security_group_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsSecurityGroup(t *testing.T) { +func TestAcc_Aws_SecurityGroup(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_security_group"}, diff --git a/pkg/resource/aws/aws_sns_topic_policy_test.go b/pkg/resource/aws/aws_sns_topic_policy_test.go index d17a8ca8e..0f96334df 100644 --- a/pkg/resource/aws/aws_sns_topic_policy_test.go +++ b/pkg/resource/aws/aws_sns_topic_policy_test.go @@ -12,7 +12,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsSNSTopicPolicy(t *testing.T) { +func TestAcc_Aws_SNSTopicPolicy(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_sns_topic_policy"}, diff --git a/pkg/resource/aws/aws_sns_topic_subscription_test.go b/pkg/resource/aws/aws_sns_topic_subscription_test.go index 451617708..fcd4acb4b 100644 --- a/pkg/resource/aws/aws_sns_topic_subscription_test.go +++ b/pkg/resource/aws/aws_sns_topic_subscription_test.go @@ -12,7 +12,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsSNSTopicSubscription(t *testing.T) { +func TestAcc_Aws_SNSTopicSubscription(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_sns_topic_subscription"}, diff --git a/pkg/resource/aws/aws_sns_topic_test.go b/pkg/resource/aws/aws_sns_topic_test.go index b4a8149ef..cf45ddd88 100644 --- a/pkg/resource/aws/aws_sns_topic_test.go +++ b/pkg/resource/aws/aws_sns_topic_test.go @@ -21,7 +21,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsSNSTopic(t *testing.T) { +func TestAcc_Aws_SNSTopic(t *testing.T) { var mutatedTopicArn string acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", diff --git a/pkg/resource/aws/aws_sqs_queue_policy_test.go b/pkg/resource/aws/aws_sqs_queue_policy_test.go index f31cc305c..56a295063 100644 --- a/pkg/resource/aws/aws_sqs_queue_policy_test.go +++ b/pkg/resource/aws/aws_sqs_queue_policy_test.go @@ -12,7 +12,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsSQSQueuePolicy(t *testing.T) { +func TestAcc_Aws_SQSQueuePolicy(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_sqs_queue_policy"}, diff --git a/pkg/resource/aws/aws_sqs_queue_test.go b/pkg/resource/aws/aws_sqs_queue_test.go index 9205d24b0..6ace47494 100644 --- a/pkg/resource/aws/aws_sqs_queue_test.go +++ b/pkg/resource/aws/aws_sqs_queue_test.go @@ -19,7 +19,7 @@ import ( "github.com/snyk/driftctl/test/acceptance/awsutils" ) -func TestAcc_AwsSQSQueue(t *testing.T) { +func TestAcc_Aws_SQSQueue(t *testing.T) { var mutatedQueue string acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", diff --git a/pkg/resource/aws/aws_subnet_test.go b/pkg/resource/aws/aws_subnet_test.go index 870fc9921..596ee5331 100644 --- a/pkg/resource/aws/aws_subnet_test.go +++ b/pkg/resource/aws/aws_subnet_test.go @@ -7,7 +7,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsSubnet(t *testing.T) { +func TestAcc_Aws_Subnet(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_subnet"}, diff --git a/pkg/resource/aws/aws_vpc_test.go b/pkg/resource/aws/aws_vpc_test.go index f690c73c3..1ef902b28 100644 --- a/pkg/resource/aws/aws_vpc_test.go +++ b/pkg/resource/aws/aws_vpc_test.go @@ -8,7 +8,7 @@ import ( "github.com/snyk/driftctl/test/acceptance" ) -func TestAcc_AwsVPC(t *testing.T) { +func TestAcc_Aws_VPC(t *testing.T) { acceptance.Run(t, acceptance.AccTestCase{ TerraformVersion: "0.15.5", Paths: []string{"./testdata/acc/aws_vpc"},