Repository navigation
Conversation
This was referenced Nov 1, 2026
kddejong
approved these changes
Nov 3, 2026
Three copies of the region-to-partition table existed (context, the LanguageExtensions transform, and E3716) and disagreed with each other. The first two knew only aws, aws-cn and aws-us-gov, so AWS::Partition resolved to aws for every other region in REGIONS; E3716 mapped eusc-* to aws-iso-f and us-isof-* to aws-iso. Replace them with one table in helpers that follows botocore's endpoints.json regionRegex and dnsSuffix values. Signed-off-by: Brenden Hogan <hoganbr@amazon.com>
kddejong
force-pushed
the
fix/partition-url-suffix-table
branch
from
November 3, 2026 20:46
ed84e19 to
3fa150d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4980 +/- ##
==========================================
+ Coverage 94.74% 94.80% +0.06%
==========================================
Files 441 441
Lines 16142 16124 -18
Branches 3140 3130 -10
==========================================
- Hits 15293 15287 -6
+ Misses 469 463 -6
+ Partials 380 374 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: Fixes #4979
Description of changes:
This PR is stacked on #4976 and #4978 and shows their commits until they merge; the change here is the last commit. The reason is under Why this stacks below.
Three copies of the region-to-partition mapping exist and disagree:
context/context.py_get_partition(pseudo-parameter values used when resolving functions)aws,aws-us-gov,aws-cntemplate/transforms/_language_extensions.py(Fn::ForEachrefs)aws,aws-us-gov,aws-cnFunctionLayerArnLength._get_partitioneusc-*toaws-iso-fandus-isof-*toaws-isoREGIONSalready includes regions from every partition, so linting for a region of any other partition, for exampleeusc-de-east-1, resolvesAWS::PartitiontoawsandAWS::URLSuffixtoamazonaws.com.This adds one table,
PARTITIONSinhelpers.py, withget_partition(region)andget_url_suffix(region), and uses it in all three places. The region patterns and DNS suffixes match each partition'sregionRegexanddnsSuffixin botocore'sendpoints.json. An unrecognised region falls back toaws/amazonaws.com, as today.What changes for users. Nothing in commercial, GovCloud and China regions. In regions of the other partitions:
eusc-*it falls by 1 (199 to 198 ineusc-de-east-1), because a real ARN there carriesaws-eusc, notaws-iso-f. Inus-isof-*it rises by 2 (197 to 199 inus-isof-east-1).New W1031 findings in the other partitions. Some provider schemas hard-code the commercial partition in their patterns:
aws|aws-cn|aws-us-govin an ARN, a longer partition list that still leaves outaws-eusc,arn:aws:, or anamazonaws.comhost. A!Subbuilt from${AWS::Partition}or${AWS::URLSuffix}used to resolve to the commercial values and pass those patterns in every region. It now resolves to the region's real values and fails them. For example:is silent on
mainin every region. With this change,eusc-de-east-1and the regions of every other partition report:Commercial, GovCloud and China regions stay silent. The same pattern already rejects a literal value:
RoleARN: arn:aws-eusc:iam::123456789012:role/configgets E3031 ineusc-de-east-1onmain. This change carries that schema gap over to the!Subform as W1031, which still gives a non-zero exit code by default (--non-zero-exit-codedefaults toinformational).The same happens for, among others,
AWS::ServiceCatalog::LaunchRoleConstraint.RoleArn,AWS::ServiceCatalog::PortfolioPrincipalAssociation.PrincipalARN,AWS::ApiGatewayV2::Integration.CredentialsArnandAWS::Amplify::Branch(arn:aws:patterns), and for twoAWS::AppRunner::Serviceproperties: the ECR image identifier built from${AWS::URLSuffix}, and the access role ARN, whose pattern listsaws-isoandaws-iso-bbut notaws-eusc,aws-iso-eoraws-iso-f. Counting everypatternin the cached provider schemas (2026-10-31) that containsarn:aws:,aws|aws-cn|aws-us-gov, a partition list withoutaws-eusc, or a literalamazonaws.comhost, roughly 120 of the 1876 resource types in theeusc-de-east-1index have at least one, about 90 of them on a property that is not read-only. The W1031 only appears where a template builds that property with${AWS::Partition}or${AWS::URLSuffix}. A template of common resources (bucket, key and trust policies, Lambda with layers, Events,AWS::Lambda::Permissionwith${AWS::URLSuffix}service principals, ECS with an ECR image, Step Functions, a VPC endpoint, outputs) gets no new findings in any region.The ARN patterns are fixed at the source by aws-cloudformation/resource-provider-enhanced-schemas#78, which widens every partition-bound ARN pattern in the published schemas. With those schemas, the example above and the ARN properties listed get no W1031 in any region. The App Runner image identifier is a host pattern, which #78 does not touch. cfn-lint's own schemas had one partition-bound ARN pattern, the Step Functions Task
Resource, which #4978 widens.Why this stacks on #4976 and #4978. With the real partition resolved, a principal written as
!Sub arn:${AWS::Partition}:iam::123456789012:rootis checked against the principal pattern asarn:aws-eusc:...ineusc-de-east-1. Without #4976 that adds six W1031 findings ongood/resources/properties/hard_coded_arn_properties.yamlin the regions of every other partition. With it, there are none. Without #4978, a Step FunctionsDefinitionwhose TaskResourceis!Sub arn:${AWS::Partition}:lambda:...gets a new W1031 in those regions too (it already gets one in China and GovCloud onmain).Verification.
test/unit/module/helpers/test_partitions.py: every region of the non-commercial partitions plus two commercial ones, the commercial fallback, and every region inREGIONSis either commercial or matched by the table.test/unit/module/context/test_pseudo_values.py:AWS::Partition,AWS::URLSuffix,AWS::StackIdandAWS::NotificationARNsfollow the partition.test_language_extensions.py:Fn::ForEachresolvesAWS::PartitionandAWS::URLSuffixforus-iso-east-1.test_function_layer_arn_length.py: cases at and one past the limit forus-isof-east-1andeusc-de-east-1. Three of them fail without this change.pytest testandpre-commit run --all-filespass.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.