From 41c535dc68ec5ff19cb6a6bba8d0c06a3c3acf19 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sat, 16 Apr 2016 09:18:47 -0700 Subject: [PATCH] Unconditionally set opsworks layer custom_json Previously in Update we would only set req.CustomJson if a non-empty value was provided in the config. It seems that the Opsworks API considers a null CustomJson to mean "do not change" rather than "set to empty", so we need to explicitly set the empty string in the request body in order to successfully remove an already-configured custom JSON. --- builtin/providers/aws/opsworks_layers.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/opsworks_layers.go b/builtin/providers/aws/opsworks_layers.go index 1b0800348b..7959c61a98 100644 --- a/builtin/providers/aws/opsworks_layers.go +++ b/builtin/providers/aws/opsworks_layers.go @@ -356,9 +356,7 @@ func (lt *opsworksLayerType) Create(d *schema.ResourceData, client *opsworks.Ops req.Shortname = aws.String(lt.TypeName) } - if customJson, ok := d.GetOk("custom_json"); ok { - req.CustomJson = aws.String(customJson.(string)) - } + req.CustomJson = aws.String(d.Get("custom_json").(string)) log.Printf("[DEBUG] Creating OpsWorks layer: %s", d.Id()) @@ -411,9 +409,7 @@ func (lt *opsworksLayerType) Update(d *schema.ResourceData, client *opsworks.Ops req.Shortname = aws.String(lt.TypeName) } - if customJson, ok := d.GetOk("custom_json"); ok { - req.CustomJson = aws.String(customJson.(string)) - } + req.CustomJson = aws.String(d.Get("custom_json").(string)) log.Printf("[DEBUG] Updating OpsWorks layer: %s", d.Id())