Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data sources to acceptance test syntax workflow #15110

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/acctest-terraform-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
pull_request:
paths:
- .github/workflows/acctest-terraform-lint.yml
- aws/core_acceptance_test.go
- aws/data_source_aws_*_test.go
- aws/resource_aws_[a-d]*_test.go

env:
GO_VERSION: "1.14"
GO111MODULE: on
TFLINT_VERSION: "v0.19.0"
TFLINT_VERSION: "v0.20.0" # Not yet available

jobs:
terrafmt:
Expand All @@ -36,7 +38,9 @@ jobs:
# - run: terrafmt diff ./aws --check --pattern '*_test.go' --quiet --fmtcompat
- run: |
find ./aws -type f \( \
-name 'resource_aws_a*_test.go' \
-name 'core_acceptance_test.go' \
-o -name 'data_source_aws_*_test.go' \
-o -name 'resource_aws_a*_test.go' \
-o -name 'resource_aws_b*_test.go' \
-o -name 'resource_aws_c*_test.go' \
-o -name 'resource_aws_d*_test.go' \
Expand Down Expand Up @@ -64,10 +68,17 @@ jobs:
git clone --branch tracking-main --single-branch https://github.com/gdavison/terrafmt terrafmt
cd terrafmt
go install
- run: curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | sh
# - run: curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | sh
- run: |
git clone --no-checkout https://github.com/terraform-linters/tflint tflint
cd tflint
git checkout --recurse-submodules 5a002e926848899d4bfbb006f95c39285a5e9afa
go install
- run: |
find ./aws -type f \( \
-name 'resource_aws_a*_test.go' \
-name 'core_acceptance_test.go' \
-o -name 'data_source_aws_*_test.go' \
-o -name 'resource_aws_a*_test.go' \
-o -name 'resource_aws_b*_test.go' \
-o -name 'resource_aws_c*_test.go' \
-o -name 'resource_aws_d*_test.go' \
Expand Down
15 changes: 8 additions & 7 deletions aws/core_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ func TestAccAWSVpc_coreMismatchedDiffs(t *testing.T) {
})
}

const testMatchedDiffs = `resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
const testMatchedDiffs = `
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"

tags = {
Name = "terraform-testacc-repro-GH-4965"
}
Name = "terraform-testacc-repro-GH-4965"
}

lifecycle {
ignore_changes = ["tags"]
}
lifecycle {
ignore_changes = ["tags"]
}
}`
4 changes: 2 additions & 2 deletions aws/data_source_aws_cur_report_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ POLICY
}

resource "aws_cur_report_definition" "test" {
depends_on = [aws_s3_bucket_policy.test] # needed to avoid "ValidationException: Failed to verify customer bucket permission."
depends_on = [aws_s3_bucket_policy.test] # needed to avoid "ValidationException: Failed to verify customer bucket permission."

report_name = "%[1]s"
time_unit = "DAILY"
Expand Down Expand Up @@ -212,7 +212,7 @@ POLICY
}

resource "aws_cur_report_definition" "test" {
depends_on = [aws_s3_bucket_policy.test] # needed to avoid "ValidationException: Failed to verify customer bucket permission."
depends_on = [aws_s3_bucket_policy.test] # needed to avoid "ValidationException: Failed to verify customer bucket permission."

report_name = "%[1]s"
time_unit = "DAILY"
Expand Down
6 changes: 5 additions & 1 deletion aws/data_source_aws_docdb_orderable_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ data "aws_docdb_orderable_db_instance" "test" {
engine_version = %q
license_model = %q

preferred_instance_classes = ["db.xyz.xlarge", %q, "db.t3.small"]
preferred_instance_classes = [
"db.xyz.xlarge",
%q,
"db.t3.small",
]
}
`, engine, version, license, preferredOption)
}
4 changes: 2 additions & 2 deletions aws/data_source_aws_lex_slot_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func TestAccDataSourceAwsLexSlotType_withVersion(t *testing.T) {
func testAccDataSourceAwsLexSlotTypeConfig_basic() string {
return `
data "aws_lex_slot_type" "test" {
name = "${aws_lex_slot_type.test.name}"
name = aws_lex_slot_type.test.name
}
`
}

func testAccDataSourceAwsLexSlotTypeConfig_withVersion() string {
return `
data "aws_lex_slot_type" "test" {
name = "${aws_lex_slot_type.test.name}"
name = aws_lex_slot_type.test.name
version = "1"
}
`
Expand Down
6 changes: 5 additions & 1 deletion aws/data_source_aws_neptune_orderable_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ data "aws_neptune_orderable_db_instance" "test" {
engine_version = %q
license_model = %q

preferred_instance_classes = ["db.xyz.xlarge", %q, "db.t3.small"]
preferred_instance_classes = [
"db.xyz.xlarge",
%q,
"db.t3.small",
]
}
`, engine, version, license, preferredOption)
}
24 changes: 20 additions & 4 deletions aws/data_source_aws_rds_orderable_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ data "aws_rds_orderable_db_instance" "test" {
engine_version = "5.7.22"
license_model = "general-public-license"

preferred_instance_classes = ["db.xyz.xlarge", %q, "db.t3.small"]
preferred_instance_classes = [
"db.xyz.xlarge",
%q,
"db.t3.small",
]
}
`, preferredClass)
}
Expand All @@ -280,7 +284,11 @@ data "aws_rds_orderable_db_instance" "test" {
license_model = "general-public-license"
storage_type = "standard"

preferred_engine_versions = ["18.42.32", %q, "not.a.version"]
preferred_engine_versions = [
"18.42.32",
%q,
"not.a.version",
]
}
`, preferredVersion)
}
Expand All @@ -291,8 +299,16 @@ data "aws_rds_orderable_db_instance" "test" {
engine = "mysql"
license_model = "general-public-license"

preferred_instance_classes = ["db.xyz.xlarge", %q, "db.t3.small"]
preferred_engine_versions = ["18.42.32", %q, "not.a.version"]
preferred_instance_classes = [
"db.xyz.xlarge",
%q,
"db.t3.small",
]
preferred_engine_versions = [
"18.42.32",
%q,
"not.a.version",
]
}
`, preferredClass, preferredVersion)
}
Expand Down
8 changes: 4 additions & 4 deletions aws/data_source_aws_vpc_peering_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ resource "aws_vpc" "baz" {
}

resource "aws_vpc_peering_connection" "conn1" {
vpc_id = aws_vpc.foo.id
vpc_id = aws_vpc.foo.id
peer_vpc_id = aws_vpc.bar.id
auto_accept = true

tags = {
Name = "terraform-testacc-vpc-peering-connection-data-source-foo-to-bar"
Name = "terraform-testacc-vpc-peering-connection-data-source-foo-to-bar"
Environment = "test"
}
}

resource "aws_vpc_peering_connection" "conn2" {
vpc_id = aws_vpc.foo.id
vpc_id = aws_vpc.foo.id
peer_vpc_id = aws_vpc.baz.id
auto_accept = true

tags = {
Name = "terraform-testacc-vpc-peering-connection-data-source-foo-to-baz"
Name = "terraform-testacc-vpc-peering-connection-data-source-foo-to-baz"
Environment = "test"
}
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_db_proxy_default_target_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ resource "aws_vpc" "test" {
}

resource "aws_security_group" "test" {
name = "%[1]s"
vpc_id = aws_vpc.test.id
name = "%[1]s"
vpc_id = aws_vpc.test.id
}

resource "aws_subnet" "test" {
Expand Down
99 changes: 7 additions & 92 deletions scripts/validate-terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,100 +16,15 @@ exit_code=0
# The *_invalid_* rules disabled here prevent evaluation of expressions.
rules=(
# Syntax checks
"--enable-rule=terraform_deprecated_interpolation"
"--enable-rule=terraform_deprecated_index"
"--enable-rule=terraform_comment_syntax"
"--only=terraform_deprecated_interpolation"
"--only=terraform_deprecated_index"
"--only=terraform_comment_syntax"
# Ensure modern instance types
"--enable-rule=aws_instance_previous_type"
"--enable-rule=aws_db_instance_previous_type"
"--enable-rule=aws_elasticache_cluster_previous_type"
"--only=aws_instance_previous_type"
"--only=aws_db_instance_previous_type"
"--only=aws_elasticache_cluster_previous_type"
# Prevent some configuration errors
"--enable-rule=aws_route_specified_multiple_targets"
# Prevent expression evaluation
"--disable-rule=aws_acm_certificate_invalid_certificate_body"
"--disable-rule=aws_acm_certificate_invalid_certificate_chain"
"--disable-rule=aws_acm_certificate_invalid_private_key"
"--disable-rule=aws_acmpca_certificate_authority_invalid_type"
"--disable-rule=aws_appsync_datasource_invalid_name"
"--disable-rule=aws_appsync_function_invalid_name"
"--disable-rule=aws_appsync_graphql_api_invalid_authentication_type"
"--disable-rule=aws_athena_workgroup_invalid_name"
"--disable-rule=aws_athena_workgroup_invalid_state"
"--disable-rule=aws_backup_selection_invalid_name"
"--disable-rule=aws_backup_vault_invalid_name"
"--disable-rule=aws_batch_compute_environment_invalid_state"
"--disable-rule=aws_batch_job_queue_invalid_state"
"--disable-rule=aws_budgets_budget_invalid_account_id"
"--disable-rule=aws_budgets_budget_invalid_budget_type"
"--disable-rule=aws_budgets_budget_invalid_time_unit"
"--disable-rule=aws_cloudformation_stack_set_invalid_execution_role_name"
"--disable-rule=aws_cloudwatch_event_permission_invalid_action"
"--disable-rule=aws_cloudwatch_event_permission_invalid_principal"
"--disable-rule=aws_cloudwatch_event_permission_invalid_statement_id"
"--disable-rule=aws_cloudwatch_log_subscription_filter_invalid_distribution"
"--disable-rule=aws_cloudwatch_event_rule_invalid_name"
"--disable-rule=aws_cloudwatch_event_target_invalid_target_id"
"--disable-rule=aws_cloudwatch_log_group_invalid_name"
"--disable-rule=aws_cloudwatch_log_stream_invalid_name"
"--disable-rule=aws_cloudwatch_log_subscription_filter_invalid_name"
"--disable-rule=aws_codebuild_source_credential_invalid_auth_type"
"--disable-rule=aws_codebuild_source_credential_invalid_server_type"
"--disable-rule=aws_codecommit_repository_invalid_repository_name"
"--disable-rule=aws_codedeploy_app_invalid_compute_platform"
"--disable-rule=aws_codepipeline_invalid_name"
"--disable-rule=aws_codepipeline_webhook_invalid_name"
"--disable-rule=aws_cognito_identity_pool_invalid_identity_pool_name"
"--disable-rule=aws_cognito_resource_server_invalid_name"
"--disable-rule=aws_cognito_user_pool_client_invalid_name"
"--disable-rule=aws_cognito_user_pool_domain_invalid_certificate_arn"
"--disable-rule=aws_cognito_user_pool_domain_invalid_domain"
"--disable-rule=aws_cognito_user_pool_invalid_email_verification_message"
"--disable-rule=aws_cognito_user_pool_invalid_mfa_configuration"
"--disable-rule=aws_cognito_user_pool_invalid_name"
"--disable-rule=aws_cognito_user_pool_invalid_sms_authentication_message"
"--disable-rule=aws_cognito_user_pool_invalid_sms_verification_message"
"--disable-rule=aws_config_aggregate_authorization_invalid_account_id"
"--disable-rule=aws_config_configuration_aggregator_invalid_name"
"--disable-rule=aws_config_organization_custom_rule_invalid_maximum_execution_frequency"
"--disable-rule=aws_config_organization_managed_rule_invalid_maximum_execution_frequency"
"--disable-rule=aws_cur_report_definition_invalid_compression"
"--disable-rule=aws_cur_report_definition_invalid_format"
"--disable-rule=aws_cur_report_definition_invalid_report_name"
"--disable-rule=aws_cur_report_definition_invalid_s3_prefix"
"--disable-rule=aws_datasync_agent_invalid_name"
"--disable-rule=aws_datasync_location_efs_invalid_subdirectory"
"--disable-rule=aws_datasync_location_nfs_invalid_subdirectory"
"--disable-rule=aws_datasync_task_invalid_name"
"--disable-rule=aws_db_instance_default_parameter_group"
"--disable-rule=aws_dlm_lifecycle_policy_invalid_description"
"--disable-rule=aws_dynamodb_global_table_invalid_name"
"--disable-rule=aws_dynamodb_table_invalid_stream_view_type"
"--disable-rule=aws_dynamodb_table_invalid_name"
"--disable-rule=aws_ecr_repository_invalid_name"
"--disable-rule=aws_elasticsearch_domain_invalid_domain_name"
"--disable-rule=aws_iam_group_invalid_name"
"--disable-rule=aws_iam_instance_profile_invalid_name"
"--disable-rule=aws_iam_policy_invalid_name"
"--disable-rule=aws_iam_role_invalid_name"
"--disable-rule=aws_iam_role_policy_invalid_name"
"--disable-rule=aws_iam_saml_provider_invalid_name"
"--disable-rule=aws_iam_saml_provider_invalid_saml_metadata_document"
"--disable-rule=aws_iam_server_certificate_invalid_name"
"--disable-rule=aws_iam_server_certificate_invalid_path"
"--disable-rule=aws_iam_user_invalid_name"
"--disable-rule=aws_iam_user_invalid_path"
"--disable-rule=aws_iam_user_invalid_permissions_boundary"
"--disable-rule=aws_kinesis_firehose_delivery_stream_invalid_name"
"--disable-rule=aws_kinesis_stream_invalid_name"
"--disable-rule=aws_kms_alias_invalid_name"
"--disable-rule=aws_lambda_function_invalid_function_name"
"--disable-rule=aws_lambda_layer_version_invalid_layer_name"
"--disable-rule=aws_launch_template_invalid_name"
"--disable-rule=aws_lb_target_group_invalid_protocol"
"--disable-rule=aws_lb_target_group_invalid_target_type"
"--disable-rule=aws_lightsail_key_pair_invalid_name"
"--disable-rule=aws_ssm_document_invalid_name"
"--disable-rule=aws_ssm_patch_baseline_invalid_name"
"--only=aws_route_specified_multiple_targets"
)
while read -r filename ; do
echo "$filename"
Expand Down