From 25383ad5a34f02c9aea65b3737175bf7803c95f7 Mon Sep 17 00:00:00 2001 From: Oleg Chunikhin Date: Sat, 12 Mar 2016 22:22:28 +0000 Subject: [PATCH] aws: Fix CloudFormation update for parameters & capabilities if not modified --- .../aws/resource_aws_cloudformation_stack.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/resource_aws_cloudformation_stack.go b/builtin/providers/aws/resource_aws_cloudformation_stack.go index d3c678780..fc9dc3736 100644 --- a/builtin/providers/aws/resource_aws_cloudformation_stack.go +++ b/builtin/providers/aws/resource_aws_cloudformation_stack.go @@ -268,7 +268,7 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface StackName: aws.String(d.Get("name").(string)), } - // Either TemplateBody or TemplateURL are required for each change + // Either TemplateBody, TemplateURL or UsePreviousTemplate are required if v, ok := d.GetOk("template_url"); ok { input.TemplateURL = aws.String(v.(string)) } @@ -276,15 +276,20 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface input.TemplateBody = aws.String(normalizeJson(v.(string))) } - if d.HasChange("capabilities") { - input.Capabilities = expandStringList(d.Get("capabilities").(*schema.Set).List()) + // Capabilities must be present whether they are changed or not + if v, ok := d.GetOk("capabilities"); ok { + input.Capabilities = expandStringList(v.(*schema.Set).List()) } + if d.HasChange("notification_arns") { input.NotificationARNs = expandStringList(d.Get("notification_arns").(*schema.Set).List()) } - if d.HasChange("parameters") { - input.Parameters = expandCloudFormationParameters(d.Get("parameters").(map[string]interface{})) + + // Parameters must be present whether they are changed or not + if v, ok := d.GetOk("parameters"); ok { + input.Parameters = expandCloudFormationParameters(v.(map[string]interface{})) } + if d.HasChange("policy_body") { input.StackPolicyBody = aws.String(normalizeJson(d.Get("policy_body").(string))) }