By Implementation

Service Control PoliciesConfig RulesAuto Remediation RulesConformance PacksAmazon GuardDutyAmazon InspectorAWS Security HubAWS Network FirewallRoute53 Resolver SecurityAmazon MacieS3 Bucket PoliciesCloudWatch Alarms and Event RulesAWS WAFAWS Secrets ManagerAWS Systems ManagerSecurity Groups & NACLsAWS KMSIAM PoliciesAmazon ECRRDS Event Subscriptions

By Service Protected

Configuration Packages

Strategy Guides

Other

EC2 Security Controls

EC2 Instance

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, 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
  • 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, 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
Items
2
Size
0.8 KB
Missing Parameters
AWSTemplateFormatVersion: "2010-09-09"
Description: ""
Resources:
  Ec2Instance:
    Type: "AWS::EC2::Instance"
    Properties:
      ImageId:
        Ref: "amazon2"
      InstanceType: "t2.micro"
      BlockDeviceMappings:
        - DeviceName: "/dev/xvda"
          Ebs:
            VolumeSize: 32
            DeleteOnTermination: true
            VolumeType: "gp3"
      SubnetId: ""
      LaunchTemplate:
        LaunchTemplateId:
          Ref: "LaunchTemplate"
        Version: "1"
  LaunchTemplate:
    Type: "AWS::EC2::LaunchTemplate"
    Properties:
      LaunchTemplateData:
        MetadataOptions:
          HttpTokens: "required"
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