Configuration template to deploy an Amazon EC2 instance with customizable settings that include Instance Metadata Service (IMDS) settings, volume and interface settings, name tag, key pairs, user data, and more.

The following settings are available in this template:

  • Instance Image (AMI): Deploy a custom AMI (based on AMI ID provided) or dynamically pull the latest AMI for Amazon Linux 2, Windows, or Ubuntu
  • Instance Type: Specify instance size (e.g. Memory and CPU settings) based on the instance type
  • EC2 Launch Template: Specify launch template id and version to import configuration details
  • Instance Metadata Service (IMDS): Enforce IMDSv2 or allow both IMDS v1 and v2 (CloudFormation requires the creation of a Launch Template to enable this setting)
  • Subnet Id: Subnet Id for the instance to be launched in (this setting applies to the first network interface attached)
  • Assign Public IP: Default is to inherit the subnet's settings but can be modified to force enable or disable public IP assignment
  • Customize EBS Volumes: By default one EBS volume is attached, but more can be added with settings that include: volume type, volume size, device name, encryption key, and more
  • Customize Network Interfaces (ENIs): By default one interface is attached, but more interfaces can be added with settings that include: subnet Id, static IP address, security group(s), description, and more
  • (Optional) Instance Name: Set a tag key for the instance name
  • (Optional) SSH Key: Provide the name for a pre-existing Key Pair
  • (Optional) User Data: Provide commands (Windows or Linux) to be run at the time of instance launch
Items
2
Size
0.8 KB
Missing Parameters
AWSTemplateFormatVersion: '2010-09-09'
Description: ''
Resources:
  LaunchTemplate:
    Type: 'AWS::EC2::LaunchTemplate'
    Properties:
      LaunchTemplateData:
        MetadataOptions:
          HttpTokens: required
  Ec2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId:
        Ref: amazon2
      InstanceType: t2.micro
      BlockDeviceMappings:
        - DeviceName: /dev/xvda
          Ebs:
            VolumeSize: 32
            DeleteOnTermination: true
            VolumeType: gp3
      LaunchTemplate:
        LaunchTemplateId:
          Ref: LaunchTemplate
        Version: '1'
Parameters:
  amazon2:
    Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
Metadata: {}
Conditions: {}

Actions



Customize Template


* Required field