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

AWS: Switching a secret from created to imported causes a runtime error #656

Open
jyecusch opened this issue Aug 2, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@jyecusch
Copy link
Member

jyecusch commented Aug 2, 2024

Bug Report

Issue

When a previously deployed nitric AWS stack, which includes a secret, changes the secret to be an imported secret an error occurs due to duplicate resource name resolution.

The cause is that the original secret is deleted and replaced with the imported secret. However, AWS Secrets Manager doesn't immediately delete secrets, instead they are soft deleted and removed after a number of days. In the meantime both secrets exist, tagged with the same nitric name. This causes the nitric runtime code to fail to uniquely identity which is the correct secret to use.

This issue can be confirmed by looking at the Secrets Manager dashboard, which will only show the imported secret:

Secrets Manager view

However, viewing the resource group for the stack will show both the imported secret and the soft deleted secret:

resource group view

Steps

Steps to reproduce the behavior:

  1. Create a new nitric project
  2. Add a secret to the project (e.g.)
code example which includes a secret definition
  1. Create a new AWS stack
  2. Deploy the stack
  3. Create a secret manually in AWS Secrets Manager
  4. Update the stack file to import the manually created secret (using the name for the existing secret in the application code)
stack file showing the added import config
  1. Redeploy the stack

If the stack hasn't been deployed previously, imports won't cause an issue

Expected

The soft deleted secret should be untagged or otherwise identified so that it isn't returned when attempting to resolve resource names.

Workaround

When redeploying a stack with an existing secret that is being replaced by an imported secret, rename the secret in the code (and stack file) before redeploying. This ensures the newly imported secret's name won't conflict with the soft deleted secret.

Eventually the soft deleted secret will be deleted and the issue with resolve on its own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant