Skip to content

E3530, E3512, E3513: IAM principal ARNs are only accepted from the aws, aws-cn and aws-us-gov partitions #4975

Closed

Description

@hoganbr-amzn

CloudFormation Lint Version

1.59.0 (also reproduces on main at b17a430)

What operating system are you using?

Linux

Describe the bug

The principal ARN patterns in the IAM policy schema list only the aws, aws-cn and aws-us-gov partitions. A principal from any other partition, for example aws-eusc, is reported as invalid in trust policies (E3530), resource policies (E3512) and ECR repository policies (E3513), whatever region is linted. The general ARN definition in the same schema (AwsArn) already accepts every partition with the aws[A-Za-z\-]*? group.

cfn-lint -t iam-principal.yaml (the same findings with --regions eusc-de-east-1):

E3530 'arn:aws-eusc:iam::123456789012:root' is not valid under any of the given schemas
iam-principal.yaml:11:15

E3530 '*' was expected
iam-principal.yaml:11:15

E3530 'arn:aws-eusc:iam::123456789012:root' does not match '^\\d{12}$'
iam-principal.yaml:11:15

E3530 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::\\d{12}:(?:root|user|group|role)'
iam-principal.yaml:11:15

E3530 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):sts::\\d{12}:assumed-role'
iam-principal.yaml:11:15

E3530 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::cloudfront:user/.+$'
iam-principal.yaml:11:15

E3512 'arn:aws-eusc:iam::123456789012:role/Reader' is not valid under any of the given schemas
iam-principal.yaml:24:15

E3512 '*' was expected
iam-principal.yaml:24:15

E3512 'arn:aws-eusc:iam::123456789012:role/Reader' does not match '^\\d{12}$'
iam-principal.yaml:24:15

E3512 'arn:aws-eusc:iam::123456789012:role/Reader' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::\\d{12}:(?:root|user|group|role)'
iam-principal.yaml:24:15

E3512 'arn:aws-eusc:iam::123456789012:role/Reader' does not match '^arn:(aws|aws-cn|aws-us-gov):sts::\\d{12}:assumed-role'
iam-principal.yaml:24:15

E3512 'arn:aws-eusc:iam::123456789012:role/Reader' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::cloudfront:user/.+$'
iam-principal.yaml:24:15

E3513 'arn:aws-eusc:iam::123456789012:root' is not valid under any of the given schemas
iam-principal.yaml:35:15

E3513 '*' was expected
iam-principal.yaml:35:15

E3513 'arn:aws-eusc:iam::123456789012:root' does not match '^\\d{12}$'
iam-principal.yaml:35:15

E3513 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::\\d{12}:(?:root|user|group|role)'
iam-principal.yaml:35:15

E3513 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):sts::\\d{12}:assumed-role'
iam-principal.yaml:35:15

E3513 'arn:aws-eusc:iam::123456789012:root' does not match '^arn:(aws|aws-cn|aws-us-gov):iam::cloudfront:user/.+$'
iam-principal.yaml:35:15

Line 11 is the TrustRole principal, line 24 the BucketPolicy principal and line 35 the Repository principal.

Expected behavior

No findings. Principal ARNs are accepted from every AWS partition, the same partitions AwsArn accepts.

Reproduction template

iam-principal.yaml:

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  TrustRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              AWS: arn:aws-eusc:iam::123456789012:root
            Action: sts:AssumeRole
  Bucket:
    Type: AWS::S3::Bucket
  BucketPolicy:
    Type: AWS::S3::BucketPolicy
    Properties:
      Bucket: !Ref Bucket
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              AWS: arn:aws-eusc:iam::123456789012:role/Reader
            Action: s3:GetObject
            Resource: !Sub ${Bucket.Arn}/*
  Repository:
    Type: AWS::ECR::Repository
    Properties:
      RepositoryPolicyText:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              AWS: arn:aws-eusc:iam::123456789012:root
            Action: ecr:BatchGetImage

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions