diff --git a/aws/resource_aws_cloudformation_stack.go b/aws/resource_aws_cloudformation_stack.go index 4da9ed3af24..68280373216 100644 --- a/aws/resource_aws_cloudformation_stack.go +++ b/aws/resource_aws_cloudformation_stack.go @@ -289,7 +289,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 9431e13c8cb..799bafd55f9 100644 --- a/aws/resource_aws_cloudformation_stack_test.go +++ b/aws/resource_aws_cloudformation_stack_test.go @@ -291,6 +291,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] @@ -743,3 +769,58 @@ resource "aws_cloudformation_stack" "test" { } `, rName, bucketKey, vpcCidr) } + +func testAccAWSCloudFormationStackConfig_withTransform(rName string) string { + return fmt.Sprintf(` +resource "aws_cloudformation_stack" "with-transform" { + name = "%[1]s" + + template_body = <