How to use describe_stack_resource method in localstack

Best Python code snippet using localstack_python

lambda_configuration.py

Source:lambda_configuration.py Github

copy

Full Screen

...175def _create_role_policy(stack_arn, function_name):176 cf = boto3.client('cloudformation', region_name=discovery_utils.get_region_from_stack_arn(stack_arn))177 try:178 res = discovery_utils.try_with_backoff(lambda : cf.describe_stack_resources(StackName=stack_arn))179 print 'describe_stack_resource(StackName="{}") result: {}'.format(stack_arn, res)180 except Exception as e:181 print 'describe_stack_resource(StackName="{}") error: {}'.format(stack_arn, getattr(e, 'response', e))182 raise e183 policy = {184 'Version': '2012-10-17',185 'Statement': [186 {187 "Sid": "WriteLogs",188 "Effect": "Allow",189 "Action": [190 "logs:CreateLogGroup",191 "logs:CreateLogStream",192 "logs:PutLogEvents"193 ],194 "Resource": "arn:aws:logs:*:*:*"195 }196 ]197 }198 for resource in res['StackResources']:199 statement = _make_resource_statement(cf, stack_arn, function_name, resource['LogicalResourceId'])200 if statement is not None:201 policy['Statement'].append(statement)202 203 print 'generated policy: {}'.format(policy)204 return json.dumps(policy, indent=4)205def _make_resource_statement(cf, stack_arn, function_name, logical_resource_name):206 print 'describe_stack_resource on resource {} in stack {}.'.format(logical_resource_name, stack_arn)207 try:208 res = discovery_utils.try_with_backoff(lambda : cf.describe_stack_resource(StackName=stack_arn, LogicalResourceId=logical_resource_name))209 print 'describe_stack_resource {} result: {}'.format(logical_resource_name, res)210 except Exception as e:211 print 'describe_stack_resource {} error: {}'.format(logical_resource_name, getattr(e, 'response', e))212 raise e213 resource = res['StackResourceDetail']214 metadata = _get_metadata_for_function(resource, function_name)215 if metadata is None: 216 return217 metadata_actions = metadata.get('Action', None)218 if metadata_actions is None:219 raise ValidationError('No Action was specified for CloudCanvas FunctionAccess metdata on the {} resource in stack {}.'.format(220 resource['LogicalResourceId'], 221 stack_arn))222 if not isinstance(metadata_actions, list):...

Full Screen

Full Screen

aws.py

Source:aws.py Github

copy

Full Screen

...150 return (151 'aws:cloudformation:stack-name' in resource.tags and152 'aws:cloudformation:logical-id' in resource.tags153 )154def describe_stack_resource(resource):155 return cxn.cloudformation().describe_stack_resource(156 resource.tags['aws:cloudformation:stack-name'],157 resource.tags['aws:cloudformation:logical-id']158 )159def stack_resource_metadata(resource, *args):160 result = (161 describe_stack_resource(resource)162 ['DescribeStackResourceResponse']163 ['DescribeStackResourceResult']164 ['StackResourceDetail']165 )166 v = result.get('Metadata', *args)167 if isinstance(v, basestring):168 v = json.loads(result['Metadata'])169 return v170def retry(sleep=1, max_sleep=60, max_count=10):171 """172 https://github.com/ansible/ansible-modules-core/blob/7fb0605824df897548e5cd3fd00789365c8f20df/cloud/amazon/ec2_elb_lb.py#L404173 """174 def _loop(func, *args, **kwargs):175 count = 0...

Full Screen

Full Screen

create.py

Source:create.py Github

copy

Full Screen

...31 if dict['OutputKey'] == 'appbucketurl':32 appbucketurl = dict['OutputValue']33 #print(dict['OutputValue'])34## get the resources from VPC stack needed to run the application stack35vpc = client.describe_stack_resource(StackName=VPCStack,LogicalResourceId='VPC')['StackResourceDetail']['PhysicalResourceId']36s3appbucket = client.describe_stack_resource(StackName=VPCStack,LogicalResourceId='S3AppBucket')['StackResourceDetail']['PhysicalResourceId']37privateroutetablea = client.describe_stack_resource(StackName=VPCStack,LogicalResourceId='RouteTablePrivateA')['StackResourceDetail']['PhysicalResourceId']38privateroutetableb = client.describe_stack_resource(StackName=VPCStack,LogicalResourceId='RouteTablePrivateB')['StackResourceDetail']['PhysicalResourceId']39publicroutetable = client.describe_stack_resource(StackName=VPCStack,LogicalResourceId='RouteTablePublic')['StackResourceDetail']['PhysicalResourceId']40s3 = boto3.client('s3')41# Add the App and Test files to the newly created S3 bucket42for x in range(1,4):43 content = open('App' + str(x) + '.zip','rb')44 s3.put_object(Bucket=s3appbucket,Key='App' + str(x) + '.zip',Body=content)45 content = open('Test' + str(x) + '.zip','rb')46 s3.put_object(Bucket=s3appbucket,Key='Test' + str(x) + '.zip',Body=content)47# create the application stack48app_file = open('cfn-app1.yaml')49app_template = app_file.read()50app_response = client.create_stack(StackName=AppStack,TemplateBody=app_template,Parameters=[{'ParameterKey':'APPBucketURL','ParameterValue':appbucketurl},\51 {'ParameterKey':'PRIVATERTA','ParameterValue':privateroutetablea},\52 {'ParameterKey':'PRIVATERTB','ParameterValue':privateroutetableb},\53 {'ParameterKey':'PUBLICRT','ParameterValue':publicroutetable},\...

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