Prerequisites and required IAM permissions for the Secrets Manager extension in AWS Systems Manager Cloud Extensions
Review the IAM permissions and resources that you need before you use the Secrets Manager extension.
Prerequisites
Before you use the Secrets Manager extension:
-
Create secrets in Secrets Manager.
-
Install the Cloud Extensions runtime in your Lambda function or container.
-
Create an IAM execution role that has permissions to read the secrets. For the permissions, see Required IAM permissions.
-
For secrets that a customer managed AWS Key Management Service (AWS KMS) key encrypts, make sure that the role can use the key.
-
Approve the capabilities of the extension on the profile entry. For the steps, see step 4 of Adding the extension with the AWS CLI.
Required IAM permissions
The execution role of the extension needs the following permissions. If neither the profile entry nor the profile sets an execution role, the credentials of the runtime need the permissions.
-
secretsmanager:GetSecretValue -
secretsmanager:DescribeSecret -
secretsmanager:BatchGetSecretValueon*, for prefetch -
secretsmanager:ListSecrets, for prefetch by tag -
kms:Decrypt, for secrets that a customer managed KMS key encrypts -
sts:AssumeRoleon each role that you pass asroleArn
The following example policy allows the extension to read the secrets that start with myapp/:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:region:account-id:secret:myapp/*" }, { "Effect": "Allow", "Action": "kms:Decrypt", "Resource": "arn:aws:kms:region:account-id:key/key-id" } ] }
You need the KMS permission only if a customer managed KMS key encrypts your secrets. Add the other permissions in the preceding list for the features that you use.
The trust policy of the role must allow the role that the runtime runs as to assume the role. The name of the role can contain only letters, numbers, /, _, and -. To set an execution role, you need iam:PassRole with iam:PassedToService set to cloudextensions.amazonaws.com. The runtime retrieves the profile with the credentials that it uses for AWS calls. In Lambda, those credentials belong to the function role. In a container, the credentials depend on how you run the container. Grant the credentials that the runtime uses cloudextensions:SyncState on all resources. For more information, see IAM permissions for the Cloud Extensions API.
After a secret is in the cache, any caller that can reach the extension and pass its caller authentication can read the secret. For more information, see Security considerations for the Secrets Manager extension in AWS Systems Manager Cloud Extensions.