Best Python code snippet using localstack_python
cloudformation_starter.py
Source:cloudformation_starter.py
...235 return aws_stack.role_arn(self.name)236 raise237 IAM_Role_get_cfn_attribute_orig = iam_models.Role.get_cfn_attribute238 iam_models.Role.get_cfn_attribute = IAM_Role_get_cfn_attribute239 # Patch LambdaFunction create_from_cloudformation_json(..) method in moto240 @classmethod241 def Lambda_create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):242 resource_name = cloudformation_json.get('Properties', {}).get('FunctionName') or resource_name243 return Lambda_create_from_cloudformation_json_orig(resource_name, cloudformation_json, region_name)244 Lambda_create_from_cloudformation_json_orig = lambda_models.LambdaFunction.create_from_cloudformation_json245 lambda_models.LambdaFunction.create_from_cloudformation_json = Lambda_create_from_cloudformation_json246 # add CloudWatch types247 parsing.MODEL_MAP['AWS::ApiGateway::Deployment'] = apigw_models.Deployment248 parsing.MODEL_MAP['AWS::ApiGateway::Method'] = apigw_models.Method249 parsing.MODEL_MAP['AWS::ApiGateway::Resource'] = apigw_models.Resource250 parsing.MODEL_MAP['AWS::ApiGateway::RestApi'] = apigw_models.RestAPI251 parsing.MODEL_MAP['AWS::StepFunctions::StateMachine'] = sfn_models.StateMachine252 @classmethod253 def RestAPI_create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):254 props = cloudformation_json['Properties']255 name = props['Name']256 region_name = props.get('Region') or DEFAULT_REGION257 description = props.get('Description') or ''258 id = props.get('Id') or short_uid()259 return apigw_models.RestAPI(id, region_name, name, description)260 def RestAPI_get_cfn_attribute(self, attribute_name):261 if attribute_name == 'Id':262 return self.id263 if attribute_name == 'Region':264 return self.region_name265 if attribute_name == 'Name':266 return self.name267 if attribute_name == 'Description':268 return self.description269 if attribute_name == 'RootResourceId':270 for id, resource in self.resources.items():271 if resource.parent_id is None:272 return resource.id273 return None274 raise UnformattedGetAttTemplateException()275 @classmethod276 def Deployment_create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):277 props = cloudformation_json['Properties']278 name = props['StageName']279 deployment_id = props.get('Id') or short_uid()280 description = props.get('Description') or ''281 return apigw_models.Deployment(deployment_id, name, description)282 @classmethod283 def Resource_create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):284 props = cloudformation_json['Properties']285 region_name = props.get('Region') or DEFAULT_REGION286 path_part = props.get('PathPart')287 api_id = props.get('RestApiId')288 parent_id = props.get('ParentId')289 id = props.get('Id') or short_uid()290 return apigw_models.Resource(id, region_name, api_id, path_part, parent_id)291 @classmethod292 def Method_create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):293 props = cloudformation_json['Properties']294 method_type = props.get('HttpMethod')295 authorization_type = props.get('AuthorizationType')296 return apigw_models.Method(method_type, authorization_type)297 apigw_models.RestAPI.create_from_cloudformation_json = RestAPI_create_from_cloudformation_json298 apigw_models.RestAPI.get_cfn_attribute = RestAPI_get_cfn_attribute299 apigw_models.Deployment.create_from_cloudformation_json = Deployment_create_from_cloudformation_json300 apigw_models.Resource.create_from_cloudformation_json = Resource_create_from_cloudformation_json301 apigw_models.Method.create_from_cloudformation_json = Method_create_from_cloudformation_json302 # TODO: add support for AWS::ApiGateway::Model, AWS::ApiGateway::RequestValidator, ...303 # fix AttributeError in moto's CloudFormation describe_stack_resource304 def describe_stack_resource(self):305 stack_name = self._get_param('StackName')306 stack = self.cloudformation_backend.get_stack(stack_name)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!