Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can two IAM statements have the same Sid?

I have just stumbled upon an s3 bucket policy within my organisation containing multiple statements, two of which are:

        {
            "Sid": "ReadFromEKS",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:role/redacted"
            },
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:DeleteObject",
                "s3:GetObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name",
                "arn:aws:s3:::bucket-name/*"
            ]
        }
        {
            "Sid": "ReadFromEKS",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::210987654321:role/redacted"
            },
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:DeleteObject",
                "s3:GetObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name",
                "arn:aws:s3:::bucket-name/*"
            ]
        }

(These were copy/pasted from the AWS console, then I changed the bucket and role ARNs)

I am confused because my understanding was that Statement ID (Sids) had to be unique within a policy. Clearly here they are not.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Am I incorrect in my belief that Sids are unique within a policy?
If that belief is not incorrect, how could this policy possibly exist?

>Solution :

The Sid is not required to be unique everywhere, see the docs

In IAM, the Sid value must be unique within a JSON policy.

and

Some AWS services (for example, Amazon SQS or Amazon SNS) might require this element and have uniqueness requirements for it. For service-specific information about writing policies, refer to the documentation for the service you work with.

S3 only recommends the uniqueness while IAM requires it, you can verify it by writing the policies in JSON in the AWS console and inspect the resulting warning / error.

Unfortunately I have not been able to find a documentation for S3 explicitly only recommending it, that may be because the default simply is non-unique and IAM enforces uniqueness and therefore only that is explicitly mentioned in the docs.
The example bucket policies already include a few policies with non-unique Sids.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading