Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support china partition merge #687

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Alexpngal
Copy link

Why?

ADF Support for China Partition

This pull request introduces support for the China partition in the AWS Deployment Framework (ADF). It adds necessary support for the unique requirements and configurations specific to the China region endpoints, base region and core ADF services.

This addition enables users in Beijing region to leverage the full capabilities of ADF tailored to their environment. The changes have been tested to guarantee compatibility with Global and Govcloud.

Any feedback, suggestions, or required adjustments are highly appreciated.

What?

Description of changes:

  • Selectors for right partition based on region
  • Mirrors for npm and Python dependencies behind the Firewall
  • Adapt infrastructure to support listener for AWS organizations API in cn-northwest-1
  • Adding tests and documentation

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

@Alexpngal Alexpngal requested a review from sbkok January 19, 2024 09:55
@Alexpngal Alexpngal changed the title Feat/support china partition merge Draft: Feat/support china partition merge Jan 19, 2024
@Alexpngal Alexpngal changed the title Draft: Feat/support china partition merge Feat/support china partition merge Jan 19, 2024
Comment on lines +11 to +20
import os
from boto3.session import Session

REGION = os.getenv("AWS_REGION", "us-east-1")
PARTITION = Session().get_partition_for_region(REGION)

if PARTITION == "aws-cn":
from .stubs import stub_iam_cn as stub_iam
else:
from .stubs import stub_iam
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we not just having separate tests for each region here? Adding this logic to the tests doesnt' seem right.


@fixture
def iam_client():
client = Mock()
client.get_role_policy.side_effect = (
lambda **kwargs: deepcopy(stub_iam.get_role_policy)
lambda **kwargs: deepcopy(stub_iam.get_role_policy) if PARTITION == "aws-cn" else deepcopy(stub_iam.get_role_policy)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the same logic each side of the if check here. Is this needed?

@@ -188,7 +196,10 @@ def test_grant_access_to_kms_keys_new_key_single_resource(iam_client):
)
policy_doc_before = deepcopy(instance.policy_document)

new_key_arn = 'arn:aws:kms:eu-west-1:111111111111:key/new_key'

test_region = "eu-west-1" if PARTITION == "aws-cn" else "cn-north-1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Logic in the tests seems like a red flag. Also "eu-west-1" IF partition == aws-cn seems incorrect

if region != "cn-north-1":
return
else:
extra_deploy_region = "cn-northwest-1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be statically defined, or supplied by the user?

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