Skip to content

Malformed principal not detected #4287

@gbudge

Description

@gbudge

CloudFormation Lint Version

1.40.4

What operating system are you using?

Mac

Describe the bug

Malformed ARN not detected by cfn-lint, but is detected by CloudFormation.

CloudFormation Error:

Resource handler returned message: "Invalid principal in policy: "AWS":"arn:aws::iam:::root" (Service: Iam, Status Code: 400, Request ID: ) (SDK Attempt Count: 1)" (RequestToken: , HandlerErrorCode: InvalidRequest)

Expected behavior

cfn-lint identifies the malformed ARN and raised an Invalid principal in policy error.

Reproduction template

---
AWSTemplateFormatVersion: '2010-09-09'
Description: demo

Resources:
  Role:
    Type: AWS::IAM::Role
    Properties:
      RoleName: SomeRoleName
      Description: Role for something
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Action:
              - sts:AssumeRole
            Principal:
              AWS: !Sub 'arn:${AWS::Partition}::iam::${AWS::AccountId}:root'

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