AWS Fundamentals Logo
AWS Fundamentals
AWS::EC2::Instance

EC2 Instance

Resource Type definition for AWS::EC2::Instance

Properties

41 configurable properties. Click a row to see details.

Filter:
PropertyTypeFlags
AdditionalInfo
string
Write-only
Affinity
string
AvailabilityZone
string
Create-only
BlockDeviceMappings
Array<BlockDeviceMapping>
CpuOptions
object
Create-only
CreditSpecification
object
DisableApiTermination
boolean
EbsOptimized
boolean
ElasticGpuSpecifications
Array<ElasticGpuSpecification>
Create-only
ElasticInferenceAccelerators
Array<ElasticInferenceAccelerator>
Create-only
EnclaveOptions
object
Create-only
HibernationOptions
object
Create-only
HostId
string
HostResourceGroupArn
string
Create-only
IamInstanceProfile
string
ImageId
string
Create-only
InstanceInitiatedShutdownBehavior
string
InstanceType
string
Ipv6AddressCount
integer
Create-onlyWrite-only
Ipv6Addresses
Array<InstanceIpv6Address>
Create-onlyWrite-only
KernelId
string
KeyName
string
Create-only
LaunchTemplate
LaunchTemplateSpecification
Create-onlyWrite-only
LicenseSpecifications
Array<LicenseSpecification>
Create-only
MetadataOptions
MetadataOptions
Monitoring
boolean
NetworkInterfaces
Array<NetworkInterface>
Create-only
PlacementGroupName
string
Create-only
PrivateDnsNameOptions
PrivateDnsNameOptions
PrivateIpAddress
string
Create-only
PropagateTagsToVolumeOnCreation
boolean
Write-only
RamdiskId
string
SecurityGroupIds
Array<string>
SecurityGroups
Array<string>
Create-only
SourceDestCheck
boolean
SsmAssociations
Array<SsmAssociation>
SubnetId
string
Create-only
Tags
Array<Tag>
Tenancy
string
UserData
string
Volumes
Array<Volume>

Return Values

Values returned after the resource is created. Access these with Fn::GetAtt.

AttributeTypeDescription
InstanceIdstringThe EC2 Instance ID.
PrivateDnsNamestringThe private DNS name of the specified instance. For example: ip-10-24-34-0.ec2.internal.
PrivateIpstringThe private IP address of the specified instance. For example: 10.24.34.0.
PublicDnsNamestringThe public DNS name of the specified instance. For example: ec2-107-20-50-45.compute-1.amazonaws.com.
PublicIpstringThe public IP address of the specified instance. For example: 192.0.2.0.
StateStateThe current state of the instance.
VpcIdstringThe ID of the VPC that the instance is running in.

Sample CloudFormation Template

A minimal template with required properties and common optional ones.

template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: Sample template for AWS::EC2::Instance

Resources:
  MyResource:
    Type: AWS::EC2::Instance
    Properties:
      Tags:
        - Key: Environment
          Value: Production

Required IAM Permissions

Permissions CloudFormation needs in your IAM role to manage this resource.

read

ec2:DescribeNetworkInterfacesec2:DescribeVolumesec2:DescribeInstancesec2:DescribeInstanceAttributeec2:DescribeInstanceCreditSpecificationsec2:DescribeLaunchTemplatesssm:DescribeAssociationssm:ListAssociations

create

iam:PassRoleec2:ModifyPrivateDnsNameOptionsec2:DescribeNetworkInterfacesec2:DescribeVolumesec2:RunInstancesec2:AssociateIamInstanceProfileec2:DescribeIamInstanceProfileAssociationsec2:DescribeInstances

update

ec2:ModifyPrivateDnsNameOptionsec2:DescribeNetworkInterfacesec2:AssociateIamInstanceProfileec2:DescribeIamInstanceProfileAssociationsec2:DescribeInstancesec2:DescribeSubnetsec2:DescribeKeyPairsec2:DescribeSecurityGroups

list

ec2:DescribeInstances

delete

ec2:DescribeInstancesec2:TerminateInstancesec2:DescribeNetworkInterfacesec2:DescribeVolumesec2:DescribeInstancesec2:DescribeInstanceAttributeec2:DescribeInstanceCreditSpecificationsec2:DescribeLaunchTemplates

Get the EC2 Cheat Sheet

Everything you need to know about EC2 on one page. HD quality, print-friendly.

Download Free Infographic

Quick Facts

ServiceEC2
Properties48
Required0
TaggingSupported
Primary IDInstanceId

Supported Operations

ReadCreateUpdateListDelete

Immutable After Creation

These properties cannot be changed after the resource is created. Updating them triggers a replacement.

AvailabilityZoneCpuOptionsElasticGpuSpecificationsElasticInferenceAcceleratorsEnclaveOptionsHibernationOptionsHostResourceGroupArnImageIdIpv6AddressCountIpv6AddressesKeyNameLaunchTemplateLicenseSpecificationsNetworkInterfacesPlacementGroupNamePrivateIpAddressSecurityGroupsSubnetId

External Links