package test import ( "testing" "github.com/gruntwork-io/terratest/modules/terraform" "github.com/stretchr/testify/assert" ) func TestRDSInstanceExample(t *testing.T) { // Construct the terraform options with default retryable errors to handle the most common // retryable errors in terraform testing. terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ // Set the path to the Terraform code that will be tested. TerraformDir: "../examples/rds-instance", }) // Clean up resources with "terraform destroy" at the end of the test. defer terraform.Destroy(t, terraformOptions) // Run "terraform init" and "terraform apply". Fail the test if there are any errors. terraform.InitAndApply(t, terraformOptions) // Run `terraform output` to get the values of output variables and check they have the expected values. arn := terraform.Output(t, terraformOptions, "aws_db_instance_primary_arn") assert.NotEmpty(t, arn) db_subnet_grp := terraform.Output(t, terraformOptions, "db_subnet_group") assert.NotEmpty(t, db_subnet_grp) }