How to use create_launch_template_version method in localstack

Best Python code snippet using localstack_python

test_launch_templates.py

Source:test_launch_templates.py Github

copy

Full Screen

...65 )66 templ = resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]67 templ.should.equal(template_data)68@mock_ec269def test_create_launch_template_version():70 cli = boto3.client("ec2", region_name="us-east-1")71 create_resp = cli.create_launch_template(72 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}73 )74 version_resp = cli.create_launch_template_version(75 LaunchTemplateName="test-template",76 LaunchTemplateData={"ImageId": "ami-def456"},77 VersionDescription="new ami",78 )79 version_resp.should.have.key("LaunchTemplateVersion")80 version = version_resp["LaunchTemplateVersion"]81 version["DefaultVersion"].should.equal(False)82 version["LaunchTemplateId"].should.equal(83 create_resp["LaunchTemplate"]["LaunchTemplateId"]84 )85 version["VersionDescription"].should.equal("new ami")86 version["VersionNumber"].should.equal(2)87@mock_ec288def test_create_launch_template_version_by_id():89 cli = boto3.client("ec2", region_name="us-east-1")90 create_resp = cli.create_launch_template(91 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}92 )93 version_resp = cli.create_launch_template_version(94 LaunchTemplateId=create_resp["LaunchTemplate"]["LaunchTemplateId"],95 LaunchTemplateData={"ImageId": "ami-def456"},96 VersionDescription="new ami",97 )98 version_resp.should.have.key("LaunchTemplateVersion")99 version = version_resp["LaunchTemplateVersion"]100 version["DefaultVersion"].should.equal(False)101 version["LaunchTemplateId"].should.equal(102 create_resp["LaunchTemplate"]["LaunchTemplateId"]103 )104 version["VersionDescription"].should.equal("new ami")105 version["VersionNumber"].should.equal(2)106@mock_ec2107def test_describe_launch_template_versions_with_multiple_versions():108 cli = boto3.client("ec2", region_name="us-east-1")109 cli.create_launch_template(110 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}111 )112 cli.create_launch_template_version(113 LaunchTemplateName="test-template",114 LaunchTemplateData={"ImageId": "ami-def456"},115 VersionDescription="new ami",116 )117 resp = cli.describe_launch_template_versions(LaunchTemplateName="test-template")118 resp["LaunchTemplateVersions"].should.have.length_of(2)119 resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]["ImageId"].should.equal(120 "ami-abc123"121 )122 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(123 "ami-def456"124 )125@mock_ec2126def test_describe_launch_template_versions_with_versions_option():127 cli = boto3.client("ec2", region_name="us-east-1")128 cli.create_launch_template(129 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}130 )131 cli.create_launch_template_version(132 LaunchTemplateName="test-template",133 LaunchTemplateData={"ImageId": "ami-def456"},134 VersionDescription="new ami",135 )136 cli.create_launch_template_version(137 LaunchTemplateName="test-template",138 LaunchTemplateData={"ImageId": "ami-hij789"},139 VersionDescription="new ami, again",140 )141 resp = cli.describe_launch_template_versions(142 LaunchTemplateName="test-template", Versions=["2", "3"]143 )144 resp["LaunchTemplateVersions"].should.have.length_of(2)145 resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]["ImageId"].should.equal(146 "ami-def456"147 )148 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(149 "ami-hij789"150 )151@mock_ec2152def test_describe_launch_template_versions_with_min():153 cli = boto3.client("ec2", region_name="us-east-1")154 cli.create_launch_template(155 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}156 )157 cli.create_launch_template_version(158 LaunchTemplateName="test-template",159 LaunchTemplateData={"ImageId": "ami-def456"},160 VersionDescription="new ami",161 )162 cli.create_launch_template_version(163 LaunchTemplateName="test-template",164 LaunchTemplateData={"ImageId": "ami-hij789"},165 VersionDescription="new ami, again",166 )167 resp = cli.describe_launch_template_versions(168 LaunchTemplateName="test-template", MinVersion="2"169 )170 resp["LaunchTemplateVersions"].should.have.length_of(2)171 resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]["ImageId"].should.equal(172 "ami-def456"173 )174 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(175 "ami-hij789"176 )177@mock_ec2178def test_describe_launch_template_versions_with_max():179 cli = boto3.client("ec2", region_name="us-east-1")180 cli.create_launch_template(181 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}182 )183 cli.create_launch_template_version(184 LaunchTemplateName="test-template",185 LaunchTemplateData={"ImageId": "ami-def456"},186 VersionDescription="new ami",187 )188 cli.create_launch_template_version(189 LaunchTemplateName="test-template",190 LaunchTemplateData={"ImageId": "ami-hij789"},191 VersionDescription="new ami, again",192 )193 resp = cli.describe_launch_template_versions(194 LaunchTemplateName="test-template", MaxVersion="2"195 )196 resp["LaunchTemplateVersions"].should.have.length_of(2)197 resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]["ImageId"].should.equal(198 "ami-abc123"199 )200 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(201 "ami-def456"202 )203@mock_ec2204def test_describe_launch_template_versions_with_min_and_max():205 cli = boto3.client("ec2", region_name="us-east-1")206 cli.create_launch_template(207 LaunchTemplateName="test-template", LaunchTemplateData={"ImageId": "ami-abc123"}208 )209 cli.create_launch_template_version(210 LaunchTemplateName="test-template",211 LaunchTemplateData={"ImageId": "ami-def456"},212 VersionDescription="new ami",213 )214 cli.create_launch_template_version(215 LaunchTemplateName="test-template",216 LaunchTemplateData={"ImageId": "ami-hij789"},217 VersionDescription="new ami, again",218 )219 cli.create_launch_template_version(220 LaunchTemplateName="test-template",221 LaunchTemplateData={"ImageId": "ami-345abc"},222 VersionDescription="new ami, because why not",223 )224 resp = cli.describe_launch_template_versions(225 LaunchTemplateName="test-template", MinVersion="2", MaxVersion="3"226 )227 resp["LaunchTemplateVersions"].should.have.length_of(2)228 resp["LaunchTemplateVersions"][0]["LaunchTemplateData"]["ImageId"].should.equal(229 "ami-def456"230 )231 resp["LaunchTemplateVersions"][1]["LaunchTemplateData"]["ImageId"].should.equal(232 "ami-hij789"233 )...

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