Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-DLMEMR-99146.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "DLM, EMR",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't have existing changelog entries in this format with two entities separated by a comma. may be worth considering using a single more generic category that captures both.

"description": "Dynamically load AWS partition information using partitions.json instead of hardcoded region mappings. Affects ``dlm create-default-role``, ``emr create-default-roles``, ``emr-containers create-role-associations``, and ``emr-containers update-role-trust-policy`` commands."
}
14 changes: 7 additions & 7 deletions awscli/customizations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import xml

from botocore.exceptions import ClientError
from botocore.loaders import Loader
from botocore.endpoint_provider import RuleSetStandardLibary

from awscli.customizations.exceptions import ParamValidationError

Expand Down Expand Up @@ -207,13 +209,11 @@ def uni_print(statement, out_file=None):

def get_policy_arn_suffix(region):
"""Method to return region value as expected by policy arn"""
region_string = region.lower()
if region_string.startswith("cn-"):
return "aws-cn"
elif region_string.startswith("us-gov"):
return "aws-us-gov"
else:
return "aws"
loader = Loader()
partitions_data = loader.load_data('partitions')
rule_lib = RuleSetStandardLibary(partitions_data)
partition_result = rule_lib.aws_partition(region.lower())
return partition_result['name']


def get_shape_doc_overview(shape):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/customizations/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def test_get_policy_arn_suffix(self):
self.assertEqual("aws", utils.get_policy_arn_suffix("us-east-1"))
self.assertEqual("aws", utils.get_policy_arn_suffix("sa-east-1"))
self.assertEqual("aws", utils.get_policy_arn_suffix("ap-south-1"))
self.assertEqual("aws-eusc", utils.get_policy_arn_suffix("eusc-de-east-1"))


class TestGetShapeDocOverview(unittest.TestCase):
Expand Down
Loading