简体   繁体   中英

What is the right syntax for an IAM policy to add to AWS Secret Manager to restrict access by IP

I am creating a Secret in AWS secret manager and I try to put in a policy to restrict access by IP.
I do it under the Secret console in [Resource Permissions] section.
I keep getting syntax error, but not what is the error.
Here is the policy I am trying ( was create via the visual editor in AWS console).

 {
    "Version":"2012-10-17",
    "Statement": [{
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "secretsmanager:*",
            "Resource": "arn:aws:secretsmanager:us-east-2:722317156788:secret:dev/playAround/junju-MWTXvg",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": "210.75.12.75/32"
                }
            }
        }]
}

It works after making two changes as below:

  • remove leading space in front of opening brace "{" on the first line of policy
  • for resource based policies, Principal is required (in certain circumstances)

Please refer to the attached picture of your updated policy to resolve the issue.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM