You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified all of my SDK modules are up-to-date (you can perform a bulk update with go get -u github.com/aws/aws-sdk-go-v2/...)
Describe the bug
After creating an amplify app with environment variables configured, there is no way to remove them. The EnvironmentVariables field is a map[string]string and I've attempted the following.
Set to map[string]string{}
Set to nil
Set to map[string]string{"": ""}
I'd expect either 1 or 2 to from above to remove the existing environment variables. 3 at one point worked with AWS SDK for Go V1 (see the Terraform AWS provider implementation and acceptance test), but even V1 now returns an error.
Regression Issue
Select this option if this issue appears to be a regression.
Expected Behavior
The ability to remove configured environment variables.
Current Behavior
Not possible to remove environment variables once configured.
Reproduction Steps
Run the program below.
Observe environment variables persisting in response output.
package main
import (
"context""fmt""log""github.com/aws/aws-sdk-go-v2/aws""github.com/aws/aws-sdk-go-v2/config""github.com/aws/aws-sdk-go-v2/service/amplify"
)
funcmain() {
ctx:=context.TODO()
cfg, err:=config.LoadDefaultConfig(ctx, config.WithRegion("us-west-2"))
iferr!=nil {
log.Fatalf("unable to load SDK config, %v", err)
}
client:=amplify.NewFromConfig(cfg)
fmt.Println("Creating app...")
out, err:=client.CreateApp(ctx, &lify.CreateAppInput{
Name: aws.String("jb-test"),
EnvironmentVariables: map[string]string{
"foo": "bar",
},
})
iferr!=nil {
log.Fatal(err)
}
appId:=out.App.AppIdfmt.Println("Attempt 1 -Updating to an empty map...")
out1, err:=client.UpdateApp(ctx, &lify.UpdateAppInput{
AppId: appId,
EnvironmentVariables: map[string]string{},
})
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("result: %s\n", out1.App.EnvironmentVariables)
fmt.Println("Attempt 2 - Updating to nil...")
out2, err:=client.UpdateApp(ctx, &lify.UpdateAppInput{
AppId: appId,
EnvironmentVariables: nil,
})
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("result: %s\n", out2.App.EnvironmentVariables)
fmt.Println("Attempt 3 - Updating to a map with an empty key/value pair...")
_, err=client.UpdateApp(ctx, &lify.UpdateAppInput{
AppId: appId,
EnvironmentVariables: map[string]string{"": ""},
})
iferr!=nil {
// This previously worked with AWS SDK for Go V1, but is now an error// Ref: https://github.com/hashicorp/terraform-provider-aws/blob/898c9b5a1d8958366b293dad02daa44e24e360ef/internal/service/amplify/app.go#L510-L516fmt.Println(err)
}
fmt.Println("Deleting app...")
_, err=client.DeleteApp(ctx, &lify.DeleteAppInput{
AppId: appId,
})
iferr!=nil {
log.Fatal(err)
}
}
Result:
Creating app...
Attempt 1 -Updating to an empty map...
result: map[foo:bar]
Attempt 2 - Updating to nil...
result: map[foo:bar]
Attempt 3 - Updating to a map with an empty key/value pair...
operation error Amplify: UpdateApp, https response error StatusCode: 400, RequestID: 590409c6-6695-435b-ab03-b579db62576f, BadRequestException: Environment variables cannot have an empty key.
Deleting app...
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:
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
After creating an
amplify
app with environment variables configured, there is no way to remove them. TheEnvironmentVariables
field is amap[string]string
and I've attempted the following.map[string]string{}
nil
map[string]string{"": ""}
I'd expect either 1 or 2 to from above to remove the existing environment variables. 3 at one point worked with AWS SDK for Go V1 (see the Terraform AWS provider implementation and acceptance test), but even V1 now returns an error.
Regression Issue
Expected Behavior
The ability to remove configured environment variables.
Current Behavior
Not possible to remove environment variables once configured.
Reproduction Steps
Result:
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.23.1 darwin/arm64
Operating System and version
MacOS Sonoma 14.6.1
The text was updated successfully, but these errors were encountered: