I have a CF template with a simple secret inside, like this:
Credentials:
Type: 'AWS::SecretsManager::Secret'
Properties:
Name: !Sub ${ProjectKey}.${StageName}.${ComponentId}.credentials
Description: client credentials
SecretString: !Sub
'{"client_id":"${ClientId}","client_secret":"${ClientSecret}"}'
The stack is created successfully and the secret is correctly generated.
However when I delete the stack and recreate it again I get the following error message:
The operation failed because the secret pk.stage.compid.credentials already exists. (Service: AWSSecretsManager; Status Code: 400; Error Code: ResourceExistsException; Request ID: ###)
I guess this is because the secret is not really deleted but only marked for deletion for x days.
It is possible to delete a secret immediately via CLI, but how can this be done within the CF Template?
I need to delete and recreate the stacks because it is part of a continous integration/delivery pipeline which is automatically triggered on source code commits.