Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: r/aws_amplify_app: environment_variables cannot be unset once configured #39327

Closed
jar-b opened this issue Sep 13, 2024 · 5 comments · Fixed by #39397
Closed

[Bug]: r/aws_amplify_app: environment_variables cannot be unset once configured #39327

jar-b opened this issue Sep 13, 2024 · 5 comments · Fixed by #39397
Labels
bug Addresses a defect in current functionality. service/amplify Issues and PRs that pertain to the amplify service.
Milestone

Comments

@jar-b
Copy link
Member

jar-b commented Sep 13, 2024

Terraform Core Version

1.9.5

AWS Provider Version

5.67.0

Affected Resource(s)

  • aws_amplify_app

Expected Behavior

When the environment_variables argument is removed, the existing values should be removed on the remote resource.

Actual Behavior

Terraform fails with an error like:

        Error: updating Amplify App (d3uac3jivrfkjf): operation error Amplify: UpdateApp, https response error StatusCode: 400, RequestID: e0eb1198-08a2-4d93-8b23-bbcc2201eb1f, BadRequ
estException: Environment variables cannot have an empty key.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_amplify_app" "test" {
  name = "jb-test"

  # remove this on a subsequent apply
  environment_variables = {
    ENVVAR1 = "1",
  }
}

Steps to Reproduce

  1. Apply the configuration above.
  2. Remove the environment_variables argument
  3. Observe error on subsequent apply.

Debug Output

No response

Panic Output

No response

Important Factoids

After some initial investigation, it isn't apparent how to remove existing environment variables with the AWS SDK for Go V2 now that empty keys are no longer permitted (at one point this worked to remove values with AWS SDK for Go V1, but now this pattern does not work with either SDK). A bug report has been filed here: aws/aws-sdk-go-v2#2788.

The following acceptance test captures this workflow:

% 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.6 test ./internal/service/amplify/... -v -count 1 -parallel 20 -run='TestAccAmplify_serial/App/EnvironmentVariables'  -timeout 360m
=== RUN   TestAccAmplify_serial
=== PAUSE TestAccAmplify_serial
=== CONT  TestAccAmplify_serial
=== RUN   TestAccAmplify_serial/App
=== RUN   TestAccAmplify_serial/App/EnvironmentVariables
    app_test.go:427: Step 4/4 error: Error running apply: exit status 1

        Error: updating Amplify App (d3uac3jivrfkjf): operation error Amplify: UpdateApp, https response error StatusCode: 400, RequestID: e0eb1198-08a2-4d93-8b23-bbcc2201eb1f, BadRequ
estException: Environment variables cannot have an empty key.

          with aws_amplify_app.test,
          on terraform_plugin_test.tf line 12, in resource "aws_amplify_app" "test":
          12: resource "aws_amplify_app" "test" {

--- FAIL: TestAccAmplify_serial (25.38s)
    --- FAIL: TestAccAmplify_serial/App (25.37s)
        --- FAIL: TestAccAmplify_serial/App/EnvironmentVariables (25.37s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/amplify    31.543s

References

Would you like to implement a fix?

None

@jar-b jar-b added the bug Addresses a defect in current functionality. label Sep 13, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/amplify Issues and PRs that pertain to the amplify service. label Sep 13, 2024
@jar-b
Copy link
Member Author

jar-b commented Sep 19, 2024

Response from the upstream bug report:

To delete the environment variables, you need to set the key to a space character and the value to an empty string. Here is the code that will delete the environment variables:

fmt.Println("Deleting environment variables...")
	out1, err := client.UpdateApp(ctx, &amplify.UpdateAppInput{
		AppId: aws.String(appId),
		EnvironmentVariables: map[string]string{
			" ": "",
		},
	})

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.68.0 milestone Sep 19, 2024
Copy link

This functionality has been released in v5.68.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/amplify Issues and PRs that pertain to the amplify service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant