create_launch_template
¶
create_launch_template(
*,
config_overrides: Optional[EC2ClientConfig] = None,
dry_run: Optional[Boolean] = None,
client_token: Optional[String] = None,
launch_template_name: Optional[String] = None,
version_description: Optional[VersionDescription] = None,
launch_template_data: Optional[RequestLaunchTemplateData] = None,
operator: Optional[OperatorRequest] = None,
tag_specifications: Optional[TagSpecificationList] = None,
) -> CreateLaunchTemplateResult
Creates a launch template.
A launch template contains the parameters to launch an instance. When you launch an instance using RunInstances, you can specify a launch template instead of providing the launch parameters in the request. For more information, see Store instance launch parameters in Amazon EC2 launch templates in the Amazon EC2 User Guide.
To clone an existing launch template as the basis for a new launch template, use the Amazon EC2 console. The API, SDKs, and CLI do not support cloning a template. For more information, see Create a launch template from an existing launch template in the Amazon EC2 User Guide.
Parameters:
-
dry_run(Optional[Boolean], default:None) –Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is
DryRunOperation. Otherwise, it isUnauthorizedOperation. -
client_token(Optional[String], default:None) –Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If a client token isn't specified, a randomly generated token is used in the request to ensure idempotency.
For more information, see Ensuring idempotency.
Constraint: Maximum 128 ASCII characters.
-
launch_template_name(Optional[String], default:None) –A name for the launch template.
-
version_description(Optional[VersionDescription], default:None) –A description for the first version of the launch template.
-
launch_template_data(Optional[RequestLaunchTemplateData], default:None) –The information for the launch template.
-
operator(Optional[OperatorRequest], default:None) –Reserved for internal use.
-
tag_specifications(Optional[TagSpecificationList], default:None) –The tags to apply to the launch template on creation. To tag the launch template, the resource type must be
launch-template.To specify the tags for the resources that are created when an instance is launched, you must use the
TagSpecificationsparameter in the launch template data structure.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a launch template This example creates a launch template that specifies the subnet in which to launch the instance, assigns a public IP address and an IPv6 address to the instance, and creates a tag for the instance.
>>> client.create_launch_template(launch_template_name='my-template', version_description='WebVersion1', launch_template_data={'NetworkInterfaces': [{'AssociatePublicIpAddress': True, 'DeviceIndex': 0, 'Ipv6AddressCount': 1, 'SubnetId': 'subnet-7b16de0c'}], 'ImageId': 'ami-8c1be5f6', 'InstanceType': 't2.small', 'TagSpecifications': [{'ResourceType': 'instance', 'Tags': [{'Key': 'Name', 'Value': 'webserver'}]}]})
Source code in docs_src/capo_ec2/_services/ec2.py
9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 | |