I am trying to connect a Lambda to a secret as per AWS docs.
I set the following resource-based policy on the secret, and verified that it has indeed been set:
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789:role/my-lambda-execution-role" }, "Action": ["secretsmanager:GetSecret", "secretsmanager:GetSecretValue"], "Resource": "*", "Condition": { "ForAnyValue:StringEquals": { "secretsmanager:VersionStage": "AWSCURRENT" } } }] }
However, I am getting timeouts when attempting to actually retrieve the policy (using Amazon's generated starter code for python3 client). I am executing the Lambda in the web IDE.
I tried it with and without the Condition filter. I also, just to be safe, granted the SecretsManagerReadWrite policy to the lambda execution role. No effect -- still timeouts.
I have a feeling that I am missing some important step there, but I have no idea what it could be...
Can anyone help? Thanks!