Ec2Instance
A resource of the AWS provider, version 0.3.0, in its Compute group. Import it with:
import Ec2Instance from "aws/compute"Example
resource Ec2Instance example {
ami = "example-value"
instanceType = "example-value"
subnetId = "example-value"
securityGroupIds = "..."
keyName = "example-value"
associatePublicIpAddress = false
iamInstanceProfile = "example-value"
userData = "example-value"
availabilityZone = "example-value"
monitoring = false
tenancy = "default"
rootVolumeSize = 3.14
rootVolumeType = "gp3"
deleteRootVolumeOnTermination = true
tags = "..."
ebsOptimized = false
cpuCredits = "standard"
hibernation = false
placementGroup = "example-value"
metadataHttpTokens = "optional"
metadataHttpPutResponseHopLimit = 1
}Properties
Set by your code in the resource block. A required one must be set; any other you leave out takes the value under Default, if it has one.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ami | string | — | No | The AMI ID to use for the instance |
instanceType | string | — | No | The instance type (e.g., t3.micro, m5.large) |
subnetId | string | — | No | The subnet ID to launch the instance in |
securityGroupIds | any[] | — | No | List of security group IDs to attach |
keyName | string | — | No | The name of the key pair for SSH access |
associatePublicIpAddress | boolean | false | No | Whether to associate a public IP address |
iamInstanceProfile | string | — | No | The IAM instance profile name or ARN |
userData | string | — | No | User data script for instance initialization (base64 encoded) |
availabilityZone | string | — | No | The availability zone to launch in |
monitoring | boolean | false | No | Enable detailed monitoring |
tenancy | string | "default" | No | Instance tenancy option Allowed: "default", "dedicated", "host" |
rootVolumeSize | number | — | No | Root volume size in GiB |
rootVolumeType | string | "gp3" | No | Root volume type Allowed: "gp2", "gp3", "io1", "io2", "st1", "sc1" |
deleteRootVolumeOnTermination | boolean | true | No | Delete root volume on termination |
tags | object | — | No | Tags to apply to the instance |
ebsOptimized | boolean | false | No | Whether the instance is optimized for Amazon EBS I/O |
cpuCredits | string | — | No | CPU credit option for burstable instances Allowed: "standard", "unlimited" |
hibernation | boolean | false | No | Whether instance hibernation is enabled |
placementGroup | string | — | No | The name of the placement group for cluster networking |
metadataHttpTokens | string | "optional" | No | HTTP tokens requirement for instance metadata service (IMDSv2) Allowed: "optional", "required" |
metadataHttpPutResponseHopLimit | number | 1 | No | HTTP PUT response hop limit for instance metadata requests (1-64) |
Set by AWS after the resource is created: your code can read them but not set them. An importable one identifies an existing resource.
| Name | Type | Importable | Description |
|---|---|---|---|
instanceId | string | No | The instance ID assigned by AWS |
state | string | No | Instance state: pending, running, stopping, stopped, terminated |
publicIp | string | No | The public IP address (if assigned) |
privateIp | string | No | The private IP address |
publicDnsName | string | No | The public DNS name |
privateDnsName | string | No | The private DNS name |
vpcId | string | No | The VPC ID the instance is in |
architecture | string | No | The architecture: x86_64 or arm64 |
rootDeviceName | string | No | The root device name |