Reputation: 101
I am trying to access secret managers using Serverless secrets framework this way:
Approach1 (Old)
supersecret: ${ssm(us-east-1, raw):/aws/reference/secretsmanager/secret-name~true}
Approach2 (New)
variablesResolutionMode: 20210326 in serverless.yaml
supersecret: ${ssm(us-east-1, raw):/aws/reference/secretsmanager/secret-name}
Approach1 works fine, but I get the below error with Approach2 on serverless deploy-
Cannot resolve serverless.yml: Variables resolution errored with:
- Cannot resolve variable at "custom.lambdas.test.custom.supersecret": An error occurred while calling one AWS dependency service.
Serverless version - Framework Core: 2.69.1 (local) Plugin: 5.5.1 SDK: 4.3.0 Components: 3.18.1
The secrets are not replicated and only exist in us-east-1. Any idea what I could be doing wrong?
Upvotes: 10
Views: 3682
Reputation: 119
Yesterday, I had the same error. Well, the error comes from serverless's version I was using. In my local environment, I had the version 2.3 and it works fine with the flag ~true
after my secret_name
ID, but in my CD I had version 3.*, and that was generating the error. After reading the docs, I searched:
Note: The method described below works by default in Serverless v3, but it requires the variablesResolutionMode: 20210326
option in v2.
So, if you're using v3 use:
ssm:/aws/reference/secretsmanager/my_secret_name
or
ssm:/aws/reference/secretsmanager/my_secret_name~true
instead
Upvotes: 9