How to use update_termination_protection method in localstack

Best Python code snippet using localstack_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...138 if self.check_termination_protection() and not overrideTerminationProtection:139 print('Error: Termination protection is enabled')140 sys.exit(1)141 elif self.check_termination_protection() and overrideTerminationProtection:142 if self.update_termination_protection(False):143 print('Removed termination protection from %s' % self.stackName)144 print('Waiting for Stack to update')145 while self.check_termination_protection:146 # FIX: Never seems to update status147 print('.')148 time.sleep(2)149 else:150 print('Unable to remove termination protection on stack')151 print('Remove protection and try again')152 sys.exit(1)153 print('Deleting stack %s' % self.stackName)154 response = self.cf.delete_stack(StackName='string')155 return self.check_response(response)156 #TODO Add delete checker157 # waiter = client.get_waiter('stack_delete_complete')158 # waiter.wait(159 # StackName='string',160 # NextToken='string',161 # WaiterConfig={162 # 'Delay': 123,163 # 'MaxAttempts': 123164 # }165 # )166 def update_termination_protection(self, enabled: bool):167 """Add or remove termination protection"""168 response = self.cf.update_termination_protection(169 StackName=self.stackName,170 EnableTerminationProtection=enabled171 )172 return self.check_response(response)173 def get_output_url(self):174 """Gets the output URL"""175 for output in self.get_stack()[0]['Outputs']:176 if output['OutputKey'] == 'WebsiteURL':177 return output['OutputValue']178 def check_response(self, response):179 """Checks if the response is 200 OK"""180 if response['ResponseMetadata']['HTTPStatusCode'] == 200:181 return True182 return False

Full Screen

Full Screen

cloudformation_termination_protection.py

Source:cloudformation_termination_protection.py Github

copy

Full Screen

...17 StackName = stack_det[i]['StackName']18 Stacklist.append(StackName)19 for stack in range(len(Stacklist)): 20 try:21 result = cloudformation.update_termination_protection(EnableTerminationProtection=True, StackName=Stacklist[stack])22 responseCode = result['ResponseMetadata']['HTTPStatusCode']23 if responseCode >= 400:24 output = "Unexpected error: %s \n" % str(result)25 else:26 output = "Enabled Termination Protection feature for CloudFormation stack : %s \n" % Stacklist[stack]27 28 except ClientError as e:29 responseCode = 40030 output = "Unexpected error: " + str(e)31 print(output)32 except Exception as e:33 responseCode = 40034 output = "Unexpected error: " + str(e)35 print(output)36 else: 37 try:38 response = cloudformation.describe_stacks(StackName=StackName)['Stacks']39 termination_protection=response[0]['EnableTerminationProtection']40 except ClientError as e:41 responseCode = 40042 output = "Unexpected error: " + str(e)43 except Exception as e:44 responseCode = 40045 output = "Unexpected error: " + str(e) 46 if not termination_protection: 47 try:48 result = cloudformation.update_termination_protection(EnableTerminationProtection=True, StackName=StackName)49 responseCode = result['ResponseMetadata']['HTTPStatusCode']50 if responseCode >= 400:51 output = "Unexpected error: %s \n" % str(result)52 else:53 output = "Enabled Termination Protection feature for CloudFormation stack : %s \n" % StackName54 55 except ClientError as e:56 responseCode = 40057 output = "Unexpected error: " + str(e)58 print(output)59 except Exception as e:60 responseCode = 40061 output = "Unexpected error: " + str(e)62 print(output)...

Full Screen

Full Screen

stack_delete_command.py

Source:stack_delete_command.py Github

copy

Full Screen

...22 self.ppt.pprint_parameters(parameters)23 # call boto324 stack = cfn.Stack(parameters['StackName'])25 try:26 update_termination_protection(27 session,28 parameters.pop('EnableTerminationProtection', None),29 parameters['StackName'],30 self.ppt)31 self.ppt.pprint_stack(stack)32 stack.delete()33 except Exception as ex:34 if self.options.ignore_missing and \35 is_stack_does_not_exist_exception(ex):36 self.ppt.secho(str(ex), fg='red')37 return38 else:39 raise40 # wait until delete complete...

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