How to use describe_launch_templates method in localstack

Best Python code snippet using localstack_python

test_launch_templates.py

Source:test_launch_templates.py Github

copy

Full Screen

...231 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(232 "ami-hij789"233 )234@mock_ec2235def test_describe_launch_templates():236 cli = boto3.client("ec2", region_name="us-east-1")237 lt_ids = []238 r = cli.create_launch_template(239 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}240 )241 lt_ids.append(r["LaunchTemplate"]["LaunchTemplateId"])242 r = cli.create_launch_template(243 LaunchTemplateName="test-template2",244 LaunchTemplateData={"ImageId": "ami-abc123"},245 )246 lt_ids.append(r["LaunchTemplate"]["LaunchTemplateId"])247 # general call, all templates248 resp = cli.describe_launch_templates()249 resp.should.have.key("LaunchTemplates")250 resp["LaunchTemplates"].should.have.length_of(2)251 resp["LaunchTemplates"][0]["LaunchTemplateName"].should.equal("test-template")252 resp["LaunchTemplates"][1]["LaunchTemplateName"].should.equal("test-template2")253 # filter by names254 resp = cli.describe_launch_templates(255 LaunchTemplateNames=["test-template2", "test-template"]256 )257 resp.should.have.key("LaunchTemplates")258 resp["LaunchTemplates"].should.have.length_of(2)259 resp["LaunchTemplates"][0]["LaunchTemplateName"].should.equal("test-template2")260 resp["LaunchTemplates"][1]["LaunchTemplateName"].should.equal("test-template")261 # filter by ids262 resp = cli.describe_launch_templates(LaunchTemplateIds=lt_ids)263 resp.should.have.key("LaunchTemplates")264 resp["LaunchTemplates"].should.have.length_of(2)265 resp["LaunchTemplates"][0]["LaunchTemplateName"].should.equal("test-template")266 resp["LaunchTemplates"][1]["LaunchTemplateName"].should.equal("test-template2")267@mock_ec2268def test_describe_launch_templates_with_filters():269 cli = boto3.client("ec2", region_name="us-east-1")270 r = cli.create_launch_template(271 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}272 )273 cli.create_tags(274 Resources=[r["LaunchTemplate"]["LaunchTemplateId"]],275 Tags=[276 {"Key": "tag1", "Value": "a value"},277 {"Key": "another-key", "Value": "this value"},278 ],279 )280 cli.create_launch_template(281 LaunchTemplateName="no-tags", LaunchTemplateData={"ImageId": "ami-abc123"}282 )283 resp = cli.describe_launch_templates(284 Filters=[{"Name": "tag:tag1", "Values": ["a value"]}]285 )286 resp["LaunchTemplates"].should.have.length_of(1)287 resp["LaunchTemplates"][0]["LaunchTemplateName"].should.equal("test-template")288 resp = cli.describe_launch_templates(289 Filters=[{"Name": "launch-template-name", "Values": ["no-tags"]}]290 )291 resp["LaunchTemplates"].should.have.length_of(1)292 resp["LaunchTemplates"][0]["LaunchTemplateName"].should.equal("no-tags")293@mock_ec2294def test_create_launch_template_with_tag_spec():295 cli = boto3.client("ec2", region_name="us-east-1")296 cli.create_launch_template(297 LaunchTemplateName="test-template",298 LaunchTemplateData={"ImageId": "ami-abc123"},299 TagSpecifications=[300 {"ResourceType": "instance", "Tags": [{"Key": "key", "Value": "value"}]}301 ],302 )...

Full Screen

Full Screen

aws_ec2_enum_launch_templates.py

Source:aws_ec2_enum_launch_templates.py Github

copy

Full Screen

...30 filename = "./workspaces/{}/{}".format(workspace, file)31 if variables['TEMPLATEID']['value']:32 id = (variables['TEMPLATEID']['value']).split(",")33 try:34 response = profile.describe_launch_templates(35 LaunchTemplateIds=id,36 MaxResults=100037 )38 while response.get('NextToken'):39 response = profile.describe_launch_templates(40 LaunchTemplateIds=id,41 MaxResults=1000,42 NextToken=response['NextToken']43 )44 with open(filename, 'w') as outfile:45 json.dump(response['LaunchTemplates'], outfile, indent=4, default=str)46 print(colored("[*] Content dumped on file '{}'.".format(filename), "green"))47 print_output(response)48 except:49 print(colored("[*] {}".format("The template ID is incorrect or the template does not exist."), "red"))50 else:51 response = profile.describe_launch_templates()52 while response.get('NextToken'):53 response = profile.describe_launch_templates(54 NextToken=response['NextToken']55 )56 with open(filename, 'w') as outfile:57 json.dump(response['LaunchTemplates'], outfile, indent=4, default=str)58 print(colored("[*] Content dumped on file '{}'.".format(filename), "green"))59 print_output(response)60def print_output(response):61 output = ""62 for instance in response['LaunchTemplates']:63 output += colored("-------------------------------------\n", "yellow", attrs=['bold'])64 output += "{}: {}\n".format(colored("LaunchTemplateName", "yellow", attrs=['bold']), instance['LaunchTemplateName'])65 output += colored("-------------------------------------\n", "yellow", attrs=['bold'])66 for key,value in instance.items():67 output += "\t{}: {}\n".format(colored(key, "red", attrs=['bold']), colored(value, "blue"))...

Full Screen

Full Screen

launch_template.py

Source:launch_template.py Github

copy

Full Screen

...14 self.current_version = current_version15 self.description = None16 self.get_description()17 def get_description(self):18 describe_launch_templates = self.client.describe_launch_templates(19 LaunchTemplateIds=[self.id]20 )21 logger.debug(describe_launch_templates)22 description = describe_launch_templates["LaunchTemplates"][0]23 self.description = description24 def create_new_default_version(self, launch_template_data):25 create_launch_template_version = self.client.create_launch_template_version(26 LaunchTemplateId=self.id,27 SourceVersion=self.current_version,28 LaunchTemplateData=launch_template_data,29 )30 logger.debug(create_launch_template_version)31 version = str(32 create_launch_template_version["LaunchTemplateVersion"]["VersionNumber"]...

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