diff --git a/aws/resource_aws_cloudformation_stack.go b/aws/resource_aws_cloudformation_stack.go index 50fb922575bb..470eb4ec2c8c 100644 --- a/aws/resource_aws_cloudformation_stack.go +++ b/aws/resource_aws_cloudformation_stack.go @@ -291,7 +291,8 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{} } tInput := cloudformation.GetTemplateInput{ - StackName: aws.String(d.Id()), + StackName: aws.String(d.Id()), + TemplateStage: aws.String("Original"), } out, err := conn.GetTemplate(&tInput) if err != nil { diff --git a/aws/resource_aws_cloudformation_stack_test.go b/aws/resource_aws_cloudformation_stack_test.go index 65716ab7db4c..5b62c8467887 100644 --- a/aws/resource_aws_cloudformation_stack_test.go +++ b/aws/resource_aws_cloudformation_stack_test.go @@ -258,6 +258,32 @@ func TestAccAWSCloudFormationStack_withUrl_withParams_noUpdate(t *testing.T) { }) } +func TestAccAWSCloudFormationStack_withTransform(t *testing.T) { + var stack cloudformation.Stack + rName := fmt.Sprintf("tf-acc-test-with-transform-%s", acctest.RandString(10)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCloudFormationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCloudFormationStackConfig_withTransform(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckCloudFormationStackExists("aws_cloudformation_stack.with-transform", &stack), + ), + }, + { + PlanOnly: true, + Config: testAccAWSCloudFormationStackConfig_withTransform(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckCloudFormationStackExists("aws_cloudformation_stack.with-transform", &stack), + ), + }, + }, + }) +} + func testAccCheckCloudFormationStackExists(n string, stack *cloudformation.Stack) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -710,3 +736,58 @@ resource "aws_cloudformation_stack" "with-url-and-params-and-yaml" { } `, rName, bucketKey, vpcCidr) } + +func testAccAWSCloudFormationStackConfig_withTransform(rName string) string { + return fmt.Sprintf(` +resource "aws_cloudformation_stack" "with-transform" { + name = "%[1]s" + + template_body = <