How to use estimate_template_cost method in localstack

Best Python code snippet using localstack_python

boto_client.py

Source:boto_client.py Github

copy

Full Screen

...111 else:112 logger.error("Must specify TemplateUrl or TemplateBody!")113 def get_template(self, **kwargs):114 return super(BotoClient, self).get_template(kwargs['StackName'])115 def estimate_template_cost(self, **kwargs):116 if 'TemplateUrl' in kwargs:117 return super(BotoClient, self).estimate_template_cost(118 kwargs['StackName'],119 template_url=kwargs['TemplateUrl'],120 parameters=kwargs['Parameters'])121 elif 'TemplateBody' in kwargs:122 return super(BotoClient, self).estimate_template_cost(123 kwargs['StackName'],124 template_body=kwargs['TemplateBody'],125 parameters=kwargs['Parameters'])126 else:127 logger.error("Must specify TemplateUrl or TemplateBody!")128 def format_stack_event(self, events):129 '''130 Return string formatted representation of131 boto.cloudformation.stack.StackEvent objects132 '''133 ret = []134 for event in events:135 ret.append("EventId : %s" % event.event_id)136 ret.append("LogicalResourceId : %s" % event.logical_resource_id)...

Full Screen

Full Screen

plan.py

Source:plan.py Github

copy

Full Screen

...22 parameters=parameters,23 bucket=bucket,24 job_identifier=job_identifier)25 try:26 cost_url = cfn_client.estimate_template_cost(27 TemplateURL=template_url, Parameters=stack_parameters)['Url']28 except (botocore.exceptions.ClientError, botocore.exceptions.ParamValidationError):29 cost_url = None30 click.echo("Estimated template cost URL: {}".format(cost_url))31 display_changes(32 changes=template_summary['ResourceTypes'], change_set=False)33def update_plan(34 session,35 stack_name,36 s3_object_key,37 template_url,38 job_identifier,39 parameters,40 bucket):41 """Shows a plan of what CloudFormation might update and how much it might cost"""42 cfn_client = session.client('cloudformation')43 click.echo("\nCreating change set for {}...".format(stack_name))44 change_set_name = 'changeset-{}-{}'.format(stack_name, int(time.time()))45 stack_capabilities = get_capabilities(46 template_url=template_url, session=session)47 stack_parameters = gather(session=session,48 key_object=s3_object_key,49 parameters=parameters,50 bucket=bucket,51 job_identifier=job_identifier)52 try:53 change_set = cfn_client.create_change_set(54 StackName=stack_name,55 TemplateURL=template_url,56 Parameters=stack_parameters,57 Capabilities=stack_capabilities,58 ChangeSetName=change_set_name,59 Description="Change set for {} created by Leo".format(stack_name),60 )61 except botocore.exceptions.ClientError as ChangeSetCreationError:62 raise ChangeSetCreationError63 try:64 cfn_client.get_waiter('change_set_create_complete').wait(65 ChangeSetName=change_set['Id'])66 except botocore.exceptions.WaiterError as change_set_creation_error:67 long_string_err = "The submitted information didn't contain changes. " \68 "Submit different information to create a change set."69 if str(70 cfn_client.describe_change_set(71 ChangeSetName=change_set['Id'])['StatusReason']) in (72 long_string_err,73 "No updates are to be performed."):74 click.echo(cfn_client.describe_change_set(75 ChangeSetName=change_set['Id'])['StatusReason'])76 pass77 else:78 raise change_set_creation_error79 # Checks for the changes80 change_set_details = cfn_client.describe_change_set(81 ChangeSetName=change_set['Id'])82 change_set_changes = change_set_details['Changes']83 try:84 cost_url = cfn_client.estimate_template_cost(85 TemplateURL=template_url, Parameters=stack_parameters)['Url']86 except (botocore.exceptions.ClientError, botocore.exceptions.ParamValidationError):87 cost_url = None88 click.echo("Cost estimate for these resources : {}".format(cost_url))89 if change_set_changes:90 display_changes(changes=change_set_changes, change_set=True)91 else:92 click.echo("No changes to be found")93def plan_deployment(**kwargs):94 """Displays what CloudFormation might create/update and what it might cost """95 cfn_ext = ('.json', '.template', '.txt', 'yaml', 'yml')96 session = kwargs['session']97 bucket = kwargs['bucket']98 job_identifier = kwargs['job_identifier']...

Full Screen

Full Screen

cost_template.py

Source:cost_template.py Github

copy

Full Screen

...41 click.secho('Use the parameter file: %s' % baseName, fg=const.FG_INF)42 else:43 paramList = list()44 try:45 eResponse = _session.cf.estimate_template_cost(TemplateURL=templateUrl,46 Parameters=paramList) 47 url = eResponse.get(const.URL)48 click.secho('\nThe estimated montly cost can be found at the following URL:', fg=const.FG_INF) 49 click.echo(url)50 except botocore.exceptions.ClientError as error:...

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