How to use list_type_versions method in localstack

Best Python code snippet using localstack_python

lambda_function.py

Source:lambda_function.py Github

copy

Full Screen

...52 if version_arn:53 cfn.set_type_default_version(Arn=version_arn)54 return version_arn55def delete_oldest(name):56 versions = cfn.list_type_versions(Type='RESOURCE', TypeName=name)['TypeVersionSummaries']57 if len(versions) < 2:58 return59 try:60 try:61 cfn.deregister_type(Arn=versions[0]['Arn'])62 except cfn.exceptions.CFNRegistryException as e:63 if "is the default version" not in str(e):64 raise65 cfn.deregister_type(Arn=versions[1]['Arn'])66 except cfn.exceptions.TypeNotFoundException:67 print("version already deleted...")68@helper.delete69def delete(event, _):70 if not event['PhysicalResourceId'].startswith("arn:"):71 print("no valid arn to delete")72 return73 retries = 074 while True:75 try:76 try:77 cfn.deregister_type(Arn=event['PhysicalResourceId'])78 except cfn.exceptions.CFNRegistryException as e:79 if "is the default version" not in str(e):80 raise81 versions = cfn.list_type_versions(Type='RESOURCE', TypeName=event['ResourceProperties']['TypeName'])['TypeVersionSummaries']82 if len(versions) > 1:83 versions = [v['Arn'] for v in versions if v['Arn'] != event['PhysicalResourceId']]84 versions.sort(reverse=True)85 cfn.set_type_default_version(Arn=versions[0])86 cfn.deregister_type(Arn=event['PhysicalResourceId'])87 else:88 cfn.deregister_type(Type='RESOURCE', TypeName=event['ResourceProperties']['TypeName'])89 return90 except cfn.exceptions.TypeNotFoundException:91 print("type already deleted...")92 return93 except Exception as e:94 retries += 195 if retries > 5:...

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