Repository navigation
Description
Delete E3511 once the IAM role ARN formats land in enhanced-schemas
Problem
E3511 (src/cfnlint/rules/resources/iam/RoleArnPattern.py) duplicates the AWS::IAM::Role.Arn format rule E1156 (src/cfnlint/rules/formats/IamRoleArn.py). It carries a hardcoded list of six property paths and its own inline regex.
On the two properties whose base schema already declares format: AWS::IAM::Role.Arn, a bad value is reported twice:
E1156 'bogusname' is not a 'AWS::IAM::Role.Arn' with pattern '^arn:aws[a-zA-Z-]*:iam::\d{12}:role/.+$'
E3511 'bogusname' does not match '^arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/[a-zA-Z_0-9+=,.@\-_/]+$'
Two rule IDs and two different regexes for one problem. Reproduced on main at 658d6f160.
What the base schemas say for E3511's six paths, and what each property actually accepts (measured in us-east-1, 2026-10-26 — see the enhanced-schemas issue for the verbatim errors):
| Property | Base schema today | Accepts |
|---|---|---|
Backup::BackupSelection BackupSelection/IamRoleArn |
format: AWS::IAM::Role.Arn |
ARN |
ECS::TaskDefinition ExecutionRoleArn |
format: AWS::IAM::Role.Arn |
ARN |
EC2::SpotFleet SpotFleetRequestConfigData/IamFleetRole |
{'type': 'string'} |
ARN only |
S3::Bucket ReplicationConfiguration/Role |
{'type': 'string'} |
ARN only |
Batch::ComputeEnvironment ServiceRole |
{'type': 'string'} |
ARN or name |
Batch::ComputeEnvironment ComputeResources/SpotIamFleetRole |
{'type': 'string'} |
ARN or name |
So E3511 is redundant on two paths, correct-but-duplicable on two, and actively wrong on two — it rejects the bare-name and path-prefixed-name forms that Batch accepts. That last pair is the subject of #4838 and PR #4926.
E3511 produces two false positives on the Batch paths
Both measured against the pattern and confirmed by full lint on main:
'AWSBatchServiceRole' FIRES <- bare name, deploys (#4838)
'/service-role/AWSBatchServiceRole' FIRES <- path-prefixed name, documented form
'/foo/bar' FIRES <- the API model's own example
The path-prefixed form is not in #4838 and has not been reported separately. AWS Batch's API model requires it when the role has a path other than /.
For contrast, a service-role ARN is an ordinary role ARN with a path and already passes both patterns:
'arn:aws:iam::<account>:role/service-role/AWSBatchServiceRole' passes E3511 and E1156
The two regexes disagree
E3511:^arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/[a-zA-Z_0-9+=,.@\-_/]+$— partition optional, path charset restrictedE1156:^arn:aws[a-zA-Z-]*:iam::\d{12}:role/.+$— partition required, path unrestricted
They cannot both be right. E1156 looks closer: arn: with no partition is not a valid ARN, and IAM role paths do contain /. Worth settling as part of this.
Blocked on
An enhanced-schemas change, filed separately there:
- plain
format: AWS::IAM::Role.ArnforEC2::SpotFleetIamFleetRoleandS3::BucketReplicationConfiguration/Role anyOf: [{format: AWS::IAM::Role.Arn}, {pattern: <name or /path/name>}]for the two Batch properties, following the existing precedent in the format generator forAWS::DevOpsAgent::Service
Order matters. Those must ship and reach cfn-lint through a schema sync before E3511 is deleted, or the four properties lose their check in the interval. Because both repositories are ours, this can be verified before release by building the schema set locally and pointing cfn-lint at it with XDG_CACHE_HOME — see .kiro/context/verification.md. The built version.json date must beat the bundled one.
When unblocked
- Delete
src/cfnlint/rules/resources/iam/RoleArnPattern.pyand its test. - Remove the
E3511row fromdocs/rules.md(generated — usecfn-lint --update-documentation). - Note the removal in the changelog: anyone with
ignore_checks: [E3511]will start seeingE1156instead, so a suppression needs updating rather than silently widening. - Confirm by full lint, against the locally built schema set, that:
- all four ARN-only properties still report a bad value, under
E1156 - both Batch properties are silent for a bare name, a path-prefixed name, and a valid ARN
- both Batch properties still report a malformed ARN
- the
good/fixture sweep is unchanged
- all four ARN-only properties still report a bad value, under
Related
PR #4926 fixes the Batch ServiceRole false positive by adding a path-based exemption inside E3511, keyed on the property name ServiceRole. It happens to fix the path-prefixed-name case too, since its guard is not arn.startswith("arn:"). But nine resource types have a top-level ServiceRole, so the exemption would silently apply to any of them added to E3511 later. If this issue is taken, #4926 becomes unnecessary and should be closed in its favour rather than revised.
Activity
refactor: remove E3511 in favour of the E1156 role ARN format (aws-cl…