IAM policy are complicated beasts. It would be nice to add a comment when crafting them. For example,
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1422979261000", "Effect": "Allow", "Action": [ "route53:ListHostedZones", ], "Comment": "Foo" # or Bar "Resource": [ "*" ] } ] }
Neither of these work. Does there exist a way to add comments to these policies?
Overview of JSON policies. Most policies are stored in AWS as JSON documents. Identity-based policies and policies used to set permissions boundaries are JSON policy documents that you attach to a user or role. Resource-based policies are JSON policy documents that you attach to a resource.
To edit a customer managed policy (console)Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/ . In the navigation pane, choose Policies. In the list of policies, choose the policy name of the policy to edit. You can use the search box to filter the list of policies.
PDFRSS. You can provide an optional identifier, Sid (statement ID) for the policy statement. You can assign a Sid value to each statement in a statement array. In services that let you specify an ID element, such as SQS and SNS, the Sid value is just a sub-ID of the policy document ID.
Hyper Anthony's answer is correct in the strict sense of 'comment' - however, in most situations you can at least use the Sid
for pseudo comments to communicate the intent or any constraints etc.:
The Sid (statement ID) is an optional identifier that you provide for the policy statement. You can assign a Sid value to each statement in a statement array. In services that let you specify an ID element, such as SQS and SNS, the Sid value is just a sub-ID of the policy document's ID. In IAM, the Sid value must be unique within a policy. [emphasis mine]
This is e.g. exemplified by the use of TheseActionsSupportResourceLevelPermissions
within the (very helpful) AWS blog post Demystifying EC2 Resource-Level Permissions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "TheseActionsSupportResourceLevelPermissions", "Effect": "Allow", "Action": [ "ec2:RunInstances", "ec2:TerminateInstances", "ec2:StopInstances", "ec2:StartInstances" ], "Resource": "arn:aws:ec2:us-east-1:accountid:instance/*" } ] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With