How to use create_account_alias method in localstack

Best Python code snippet using localstack_python

configure_account_alias.py

Source:configure_account_alias.py Github

copy

Full Screen

...9from logger import configure_logger10patch_all()11LOGGER = configure_logger(__name__)12ADF_ROLE_NAME = os.getenv("ADF_ROLE_NAME")13def create_account_alias(account, iam_client):14 LOGGER.info(15 f"Ensuring Account: {account.get('account_full_name')} has alias {account.get('alias')}"16 )17 try:18 iam_client.create_account_alias(AccountAlias=account.get("alias"))19 except iam_client.exceptions.EntityAlreadyExistsException:20 pass21 return account22def lambda_handler(event, _):23 if event.get("alias"):24 sts = STS()25 account_id = event.get("account_id")26 role = sts.assume_cross_account_role(27 f"arn:aws:iam::{account_id}:role/{ADF_ROLE_NAME}",28 "adf_account_alias_config",29 )30 create_account_alias(event, role.client("iam"))31 else:32 LOGGER.info(33 f"Account: {event.get('account_full_name')} does not need an alias"34 )...

Full Screen

Full Screen

test_account_alias.py

Source:test_account_alias.py Github

copy

Full Screen

...15 stubber.add_response(16 "create_account_alias", create_alias_response, {"AccountAlias": "MyCoolAlias"}17 ),18 stubber.activate()19 response = create_account_alias(test_account, iam_client)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful