# IAM policy example: read Secrets Manager secrets by tag, with a least privilege rewrite

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

Allows a role to read the value of secrets tagged Team with the same value as the caller's Team principal tag. Access follows tags, so new secrets need no policy edit. The original allows reading every secret and listing them all.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadSecrets",
      "Effect": "Allow",
      "Action": [
        "secretsmanager:GetSecretValue",
        "secretsmanager:List*",
        "secretsmanager:Describe*"
      ],
      "Resource": "*"
    }
  ]
}
```

## What it allows

- Allows reading secret values, listing and describing all secrets in the account.

- Allows 5 actions (secretsmanager:GetSecretValue, secretsmanager:List*, secretsmanager:Describe*) on every resource.

Checks:
- No flags.

The wildcard read on all secrets exposes every team's credentials. The wildcards cover 3 and 1 actions.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadTeamSecrets",
      "Effect": "Allow",
      "Action": "secretsmanager:GetSecretValue",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "secretsmanager:ResourceTag/Team": "${aws:PrincipalTag/Team}"
        }
      }
    },
    {
      "Sid": "ListSecrets",
      "Effect": "Allow",
      "Action": "secretsmanager:ListSecrets",
      "Resource": "*"
    }
  ]
}
```

The rewrite lets the caller read a secret only when its Team tag matches the caller's Team tag. Listing secrets stays available.

- Allows 1 action (secretsmanager:GetSecretValue) on every resource when secretsmanager:ResourceTag/Team StringEquals ${aws:PrincipalTag/Team}.
- Allows 1 action (secretsmanager:ListSecrets) on every resource.

Checks:
- No flags.

- [Paste it into the workbench](/)
- [Every Secrets Manager action and its access level](/actions/secretsmanager/)

## Related pages

- [IAM policy example: read a Parameter Store path](/examples/ssm-read-parameter-path/)
- [IAM policy example: write parameters under a team path](/examples/ssm-write-own-parameter-path/)
- [IAM policy example: read one CloudWatch Logs group](/examples/logs-read-one-log-group/)
- [All of them](/examples/)

## Sources

- AWS Secrets Manager User Guide: permissions policy examples: https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_examples.html (read 16 Nov 2026)
- IAM User Guide: attribute-based access control tutorial: https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html (read 16 Nov 2026)
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026): https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/examples/secretsmanager-read-secrets-by-tag/

This site is not affiliated with Amazon Web Services. AWS service and product names are used only to describe AWS services.
