How to use delete_stack_set method in localstack

Best Python code snippet using localstack_python

framework_nuke_environment.py

Source:framework_nuke_environment.py Github

copy

Full Screen

...75 'logs', options.management_east_id, region='us-gov-east-1')76org_client = boto3.client('organizations')77delete_stack(cfn_clients['Central']['West1'], 'federation-stack')78delete_stack(cfn_clients['Logging']['West1'], 'federation-stack')79delete_stack_set(cfn_client=cfn_clients['Central']['West1'],80 org_client=org_client,81 stack_set_name='federation-stackset-us-gov-west-1',82 ou_name='environment-usgw1',83 region='us-gov-west-1')84delete_stack_set(cfn_client=cfn_clients['Central']['West1'], # Stacksets are in west85 org_client=org_client,86 stack_set_name='federation-stackset-us-gov-east-1',87 ou_name='environment-usge1',88 region='us-gov-east-1')89delete_stack_set(cfn_client=cfn_clients['Central']['West1'],90 org_client=org_client,91 stack_set_name='backup-services-stackset-us-gov-west-1',92 ou_name='environment-usgw1',93 region='us-gov-west-1')94delete_stack_set(cfn_client=cfn_clients['Central']['West1'], # Stacksets are in west95 org_client=org_client,96 stack_set_name='backup-services-stackset-us-gov-east-1',97 ou_name='environment-usge1',98 region='us-gov-east-1')99delete_stack_set(cfn_client=cfn_clients['Central']['West1'],100 org_client=org_client,101 stack_set_name='security-baseline-stackset-us-gov-west-1',102 ou_name='environment-usgw1',103 region='us-gov-west-1')104delete_stack_set(cfn_client=cfn_clients['Central']['West1'], # Stacksets are in west105 org_client=org_client,106 stack_set_name='security-baseline-stackset-us-gov-east-1',107 ou_name='environment-usge1',108 region='us-gov-east-1')109if (options.transit_west_id):110 delete_stack(cfn_clients['Transit']['West1'], 'transit-gateway-routes')111if (options.transit_east_id):112 delete_stack(cfn_clients['Transit']['East1'], 'transit-gateway-routes')113if (options.management_west_id):114 delete_stack(cfn_clients['Management']['West1'],115 'management-services-init')116if (options.management_east_id):117 delete_stack(cfn_clients['Management']['East1'],118 'management-services-init')...

Full Screen

Full Screen

delete_stack_set.py

Source:delete_stack_set.py Github

copy

Full Screen

...8import time9Helpers = helpers.Helpers()10Cfn_helpers = cfn_helpers.CfnHelpers()11Org_helpers = org_helpers.Organization_Helpers()12def delete_stack_set(session,stack_set_name, accounts):13 cfn = session.client('cloudformation')14 print()15 try:16 print(f"Deleting Stack Set Instances for {stack_set_name}")17 response = cfn.delete_stack_instances(18 StackSetName=stack_set_name,19 Accounts=accounts,20 Regions=[session.region_name],21 RetainStacks=False,22 OperationId=str(uuid.uuid1())23 )24 print(response)25 inprogress = True26 while inprogress:27 try:28 response = cfn.delete_stack_set(29 StackSetName=stack_set_name30 )31 inprogress = False32 except botocore.exceptions.ClientError as e:33 if e.response['Error']['Code'] == 'OperationInProgressException':34 print(e.response['Error']['Code'])35 inprogress = True36 time.sleep(30)37 except Exception as e:38 raise e39 print(f"Operation Out of Progress")40 response = cfn.delete_stack_set(41 StackSetName=stack_set_name42 )43 except botocore.exceptions.ClientError as e:44 if e.response['Error']['Code'] == 'StackSetNotFoundException':45 print(f"Stack Set Not Found: {stack_set_name}")46 response = cfn.delete_stack_set(47 StackSetName=stack_set_name48 )49 print(response)50 else:51 print(e)52 return53def main():54 shared_session = boto3.session.Session(profile_name='aws2')55 shared_session = boto3.session.Session(profile_name='orgmaster')56 org_session = boto3.session.Session(profile_name='orgmaster')57 org_accounts = Org_helpers.get_org_accounts(org_session,remove_org_master=False)58 print(org_accounts)59 cfn = org_session.client('cloudformation')60 stack_set_name = 'devops-boundary'61 response = cfn.list_stack_sets(62 Status='ACTIVE'63 )64 stack_sets = [s['StackSetName'] for s in response['Summaries']]65 print(stack_sets)66 for stack_set_name in stack_sets:67 delete_stack_set(shared_session, stack_set_name, org_accounts)68 return69if __name__ == '__main__':...

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