I have been following this official doc from AWS on how to us secrets that are stored in Secret Manager in SAM template.yaml
file, and here is what I have done:
Environment:
Variables:
DUMMY_VARIABLE: '{{resolve:secretsmanager:dummy/secret:SecretString:key1}}'
Everything is working fine, and I can see the secrets is being retrieved, however, if I change the secret value in the secret manager, and redeploy the Lambda function via sam deploy
command the value of the environment variable that is coming from Secret Manager remains unchanged.
I am not specifying the version stage, or version id, but I can fix the problem by specifying the versionID of the secret like below:
DUMMY_VARIABLE: '{{resolve:secretsmanager:dummy/secret:SecretString:key3::VERSION_ID_OF_THE_SECRET}}'
According to AWS official doc:
If you don't specify either a version stage or a version ID, then the default is to retrieve the version with the version stage value of AWSCURRENT.
My expection is that it should take the current value from Secret Manager without having to specify the Version ID, and Stage, but it seems not happening!