created a secret manager key (non-rotational)with plain text option and encrypted. When i tried to get the value in lambda function , I am getting the error as permission denied. Could you please help how to resolve the issue
1 Answer
You need to assign the role to lambda function to read from the secret manager.
AWS role The following IAM policy allows read access to all resources that you create in AWS Secrets Manager. This policy applies to resources that you have created already and all resources that you create in the future.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetResourcePolicy",
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
"secretsmanager:ListSecretVersionIds"
],
"Resource": ["*"]
}
]
}
You can find more specific example below
iam-policy-examples-asm-secrets
3 Comments
sanjay
Thanks or the help.. I have added the policy in the SAM template
GuilleOjeda
Note that this policy grants access to all secrets. It's a better practice to only grant access to the secrets your application actually needs.
Adiii
@Blueriver yes and normally we do like
api-* or prod-* if there is prefix per env or per application