Skip to content

Commit 75f6ff0

Browse files
authored
Fixes for china (#188)
1 parent d78417f commit 75f6ff0

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

data-collection/test/utils.py

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def launch_(state_machine_arns, lambda_arns=None, lambda_norun_arns=None, wait=T
274274
# Extract Lambda function ARNs from the state machine definition
275275
state_machine_definition = json.loads(stepfunctions.describe_state_machine(stateMachineArn=state_machine_arn)['definition'])
276276
def _extract_lambda_arns(state):
277-
if str(state).startswith('arn:aws:lambda:'):
277+
if str(state).startswith('arn:aws:lambda:') or str(state).startswith('arn:aws-cn:lambda:'):
278278
lambda_arns.add(state)
279279
elif isinstance(state, dict):
280280
for value in state.values():
@@ -334,46 +334,48 @@ def _extract_lambda_arns(state):
334334

335335

336336
def trigger_update(account_id):
337-
region = boto3.session.Session().region_name
337+
session = boto3.session.Session()
338+
region = session.region_name
339+
partition = session.get_partition_for_region(session.region_name)
338340
state_machine_arns = [
339-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}budgets-StateMachine',
340-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}ecs-chargeback-StateMachine',
341-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-OpensearchDomains-StateMachine',
342-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-ElasticacheClusters-StateMachine',
343-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-RdsDbInstances-StateMachine',
344-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-EBS-StateMachine',
345-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-AMI-StateMachine',
346-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-Snapshot-StateMachine',
347-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-Ec2Instances-StateMachine',
348-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-VpcInstances-StateMachine',
349-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-RdsDbSnapshots-StateMachine',
350-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-LambdaFunctions-StateMachine',
351-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}rds-usage-StateMachine',
352-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}transit-gateway-StateMachine',
353-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}trusted-advisor-StateMachine',
354-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}cost-anomaly-StateMachine",
355-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}support-cases-StateMachine",
356-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}cost-explorer-rightsizing-StateMachine",
357-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}organizations-StateMachine",
358-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}compute-optimizer-StateMachine",
359-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonRDS-StateMachine",
360-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonEC2-StateMachine",
361-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonElastiCache-StateMachine",
362-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonES-StateMachine",
363-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AWSComputeSavingsPlan-StateMachine",
364-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AWSLambda-StateMachine",
365-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-RegionalServices-StateMachine",
366-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-RegionNames-StateMachine",
367-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}backup-CopyJobs-StateMachine",
368-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}backup-RestoreJobs-StateMachine",
369-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}backup-BackupJobs-StateMachine",
370-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Blog-Post-StateMachine",
371-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Whats-New-StateMachine",
372-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Security-Bulletin-StateMachine",
373-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-YouTube-StateMachine",
374-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}health-events-StateMachine",
375-
f"arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}license-manager-StateMachine",
376-
f'arn:aws:states:{region}:{account_id}:stateMachine:{PREFIX}quicksight-StateMachine',
341+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}budgets-StateMachine',
342+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}ecs-chargeback-StateMachine',
343+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-OpensearchDomains-StateMachine',
344+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-ElasticacheClusters-StateMachine',
345+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-RdsDbInstances-StateMachine',
346+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-EBS-StateMachine',
347+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-AMI-StateMachine',
348+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-Snapshot-StateMachine',
349+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-Ec2Instances-StateMachine',
350+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-VpcInstances-StateMachine',
351+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-RdsDbSnapshots-StateMachine',
352+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}inventory-LambdaFunctions-StateMachine',
353+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}rds-usage-StateMachine',
354+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}transit-gateway-StateMachine',
355+
f'arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}trusted-advisor-StateMachine',
356+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}cost-anomaly-StateMachine",
357+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}support-cases-StateMachine",
358+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}cost-explorer-rightsizing-StateMachine",
359+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}organizations-StateMachine",
360+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}compute-optimizer-StateMachine",
361+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonRDS-StateMachine",
362+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonEC2-StateMachine",
363+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonElastiCache-StateMachine",
364+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AmazonES-StateMachine",
365+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AWSComputeSavingsPlan-StateMachine",
366+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-AWSLambda-StateMachine",
367+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-RegionalServices-StateMachine",
368+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}pricing-RegionNames-StateMachine",
369+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}backup-CopyJobs-StateMachine",
370+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}backup-RestoreJobs-StateMachine",
371+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}backup-BackupJobs-StateMachine",
372+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Blog-Post-StateMachine",
373+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Whats-New-StateMachine",
374+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-Security-Bulletin-StateMachine",
375+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}aws-feeds-YouTube-StateMachine",
376+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}health-events-StateMachine",
377+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}license-manager-StateMachine",
378+
f"arn:{partition}:states:{region}:{account_id}:stateMachine:{PREFIX}quicksight-StateMachine",
377379
]
378380
lambda_arns = []
379381
lambda_norun_arns = []

0 commit comments

Comments
 (0)