Skip to content

fix(E3511): accept a role name for AWS::Batch::ComputeEnvironment ServiceRole - #4926

Closed
pcbeingused333 wants to merge 1 commit into
aws-cloudformation:mainfrom
pcbeingused333:fix/e3511-batch-servicerole-name
Closed

pcbeingused333 wants to merge 1 commit into
aws-cloudformation:mainfrom
pcbeingused333:fix/e3511-batch-servicerole-name

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Issue #, if available: #4838

Description of changes:

E3511 requires an IAM role ARN for every property it checks, including AWS::Batch::ComputeEnvironment ServiceRole. For ServiceRole, Batch accepts either the full ARN or just the role name (the property documentation says that with only a name, Batch assumes the ARN doesn't use the service-role path prefix), and CloudFormation creates the compute environment with a name, so the rule reported a false positive.

The rule now treats a ServiceRole value that does not start with arn: as a role name and accepts it, with or without a path prefix (the documentation says: "If your specified role has a path other than /, you must specify either the full role ARN or prefix the role name with the path ... specify /foo/bar as the role name"). A value that starts with arn: is still checked against the ARN pattern, so a malformed ARN is still reported. The other properties the rule covers (SpotIamFleetRole, ExecutionRoleArn, IamFleetRole, ...) still require an ARN.

Tests: test_role_arn_pattern.py gets cases on ServiceRole for a role name, a path-prefixed name, a name with a custom path, an ARN and a malformed ARN (still reported), and for a role name on ExecutionRoleArn, which is still reported. The role-name case fails without the change. The IAM rule tests and test_rules_collections.py pass (121 tests), and the template from the issue no longer produces E3511. Not tested: creating the stack in AWS (the issue reports CREATE_COMPLETE with a role name).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This change was prepared with Claude Code.

…viceRole

Batch takes either the role's full ARN or its name for ServiceRole, with the
path prefix when the role's path is not "/" (the resource documentation:
"specify /foo/bar as the role name"), and CloudFormation creates the
environment with a name. E3511 required an ARN for every property it checks,
so a role name was reported. For ServiceRole only, a value that does not start
with "arn:" is a role name and is accepted; a value that does is still checked
against the ARN pattern. The other properties still need an ARN.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kddejong

Copy link
Copy Markdown
Contributor

Superseded by #4942, which deletes E3511 entirely. The enhanced-schemas change (resource-provider-enhanced-schemas#74) is merged and published, so all six properties now carry format: AWS::IAM::Role.Arn or anyOf: [Role.Arn, Role.Name], and E1156/E1165 own the check. That also fixes the Batch false positive this PR targeted, including the path-prefixed name form (/foo/bar) that wasn't in #4838. See #4941.

@kddejong kddejong closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants