Skip to content

Commit

Permalink
r/aws_amplify_app: fix removal of environment_variables (#39397)
Browse files Browse the repository at this point in the history
Previously existing `environment_variables` were removed by sending a map with an empty key/value pair. The `UpdateApp` API appears to have added restrictions around keys with empty values, so this approach began to fail the corresponding acceptance test. After reporting the issue to the AWS Go SDK V2, the new method for removing environment variables is to pass a key containing a single space character and an empty string value.

```console
% make testacc PKG=amplify TESTS=TestAccAmplify_serial/App/EnvironmentVariables
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.7 test ./internal/service/amplify/... -v -count 1 -parallel 20 -run='TestAccAmplify_serial/App/EnvironmentVariables'  -timeout 360m

--- PASS: TestAccAmplify_serial (301.10s)
    --- PASS: TestAccAmplify_serial/App (301.10s)
        --- PASS: TestAccAmplify_serial/App/EnvironmentVariables (301.10s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/amplify    307.329s
```
  • Loading branch information
jar-b authored Sep 19, 2024
1 parent 786d53d commit 8be8181
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/39397.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_amplify_app: Fix failure when unsetting the `environment_variables` argument
```
5 changes: 4 additions & 1 deletion internal/service/amplify/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ func resourceAppUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
if v := d.Get("environment_variables").(map[string]interface{}); len(v) > 0 {
input.EnvironmentVariables = flex.ExpandStringValueMap(v)
} else {
input.EnvironmentVariables = map[string]string{"": ""}
// To remove environment variables, set the key to a single space
// character and the value to an empty string.
// Ref: https://github.com/aws/aws-sdk-go-v2/issues/2788
input.EnvironmentVariables = map[string]string{" ": ""}
}
}

Expand Down

0 comments on commit 8be8181

Please sign in to comment.