Come join Pulumi for the industry's first Cloud Engineering Summit! October 7–8. Save Your Spot

Instance

Provides an EC2 instance resource. This allows instances to be created, updated, and deleted.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var ubuntu = Output.Create(Aws.GetAmi.InvokeAsync(new Aws.GetAmiArgs
        {
            MostRecent = true,
            Filters = 
            {
                new Aws.Inputs.GetAmiFilterArgs
                {
                    Name = "name",
                    Values = 
                    {
                        "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*",
                    },
                },
                new Aws.Inputs.GetAmiFilterArgs
                {
                    Name = "virtualization-type",
                    Values = 
                    {
                        "hvm",
                    },
                },
            },
            Owners = 
            {
                "099720109477",
            },
        }));
        var web = new Aws.Ec2.Instance("web", new Aws.Ec2.InstanceArgs
        {
            Ami = ubuntu.Apply(ubuntu => ubuntu.Id),
            InstanceType = "t3.micro",
            Tags = 
            {
                { "Name", "HelloWorld" },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v3/go/aws"
    "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/ec2"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        opt0 := true
        ubuntu, err := aws.GetAmi(ctx, &aws.GetAmiArgs{
            MostRecent: &opt0,
            Filters: []aws.GetAmiFilter{
                aws.GetAmiFilter{
                    Name: "name",
                    Values: []string{
                        "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*",
                    },
                },
                aws.GetAmiFilter{
                    Name: "virtualization-type",
                    Values: []string{
                        "hvm",
                    },
                },
            },
            Owners: []string{
                "099720109477",
            },
        }, nil)
        if err != nil {
            return err
        }
        _, err = ec2.NewInstance(ctx, "web", &ec2.InstanceArgs{
            Ami:          pulumi.String(ubuntu.Id),
            InstanceType: pulumi.String("t3.micro"),
            Tags: pulumi.StringMap{
                "Name": pulumi.String("HelloWorld"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

ubuntu = aws.get_ami(most_recent=True,
    filters=[
        aws.GetAmiFilterArgs(
            name="name",
            values=["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"],
        ),
        aws.GetAmiFilterArgs(
            name="virtualization-type",
            values=["hvm"],
        ),
    ],
    owners=["099720109477"])
web = aws.ec2.Instance("web",
    ami=ubuntu.id,
    instance_type="t3.micro",
    tags={
        "Name": "HelloWorld",
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const ubuntu = aws.getAmi({
    mostRecent: true,
    filters: [
        {
            name: "name",
            values: ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"],
        },
        {
            name: "virtualization-type",
            values: ["hvm"],
        },
    ],
    owners: ["099720109477"],
});
const web = new aws.ec2.Instance("web", {
    ami: ubuntu.then(ubuntu => ubuntu.id),
    instanceType: "t3.micro",
    tags: {
        Name: "HelloWorld",
    },
});

Create a Instance Resource

def Instance(resource_name: str, opts: Optional[ResourceOptions] = None, ami: Optional[str] = None, associate_public_ip_address: Optional[bool] = None, availability_zone: Optional[str] = None, cpu_core_count: Optional[int] = None, cpu_threads_per_core: Optional[int] = None, credit_specification: Optional[InstanceCreditSpecificationArgs] = None, disable_api_termination: Optional[bool] = None, ebs_block_devices: Optional[Sequence[InstanceEbsBlockDeviceArgs]] = None, ebs_optimized: Optional[bool] = None, ephemeral_block_devices: Optional[Sequence[InstanceEphemeralBlockDeviceArgs]] = None, get_password_data: Optional[bool] = None, hibernation: Optional[bool] = None, host_id: Optional[str] = None, iam_instance_profile: Optional[str] = None, instance_initiated_shutdown_behavior: Optional[str] = None, instance_type: Optional[str] = None, ipv6_address_count: Optional[int] = None, ipv6_addresses: Optional[Sequence[str]] = None, key_name: Optional[str] = None, metadata_options: Optional[InstanceMetadataOptionsArgs] = None, monitoring: Optional[bool] = None, network_interfaces: Optional[Sequence[InstanceNetworkInterfaceArgs]] = None, placement_group: Optional[str] = None, private_ip: Optional[str] = None, root_block_device: Optional[InstanceRootBlockDeviceArgs] = None, secondary_private_ips: Optional[Sequence[str]] = None, security_groups: Optional[Sequence[str]] = None, source_dest_check: Optional[bool] = None, subnet_id: Optional[str] = None, tags: Optional[Mapping[str, str]] = None, tenancy: Optional[str] = None, user_data: Optional[str] = None, user_data_base64: Optional[str] = None, volume_tags: Optional[Mapping[str, str]] = None, vpc_security_group_ids: Optional[Sequence[str]] = None)
func NewInstance(ctx *Context, name string, args InstanceArgs, opts ...ResourceOption) (*Instance, error)
public Instance(string name, InstanceArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args InstanceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args InstanceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args InstanceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Instance Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Instance resource accepts the following input properties:

Ami string

The AMI to use for the instance.

InstanceType string

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

AssociatePublicIpAddress bool

Associate a public ip address with an instance in a VPC. Boolean value.

AvailabilityZone string

The AZ to start the instance in.

CpuCoreCount int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

CpuThreadsPerCore int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

CreditSpecification InstanceCreditSpecificationArgs

Customize the credit specification of the instance. See Credit Specification below for more details.

DisableApiTermination bool

If true, enables EC2 Instance Termination Protection

EbsBlockDevices List<InstanceEbsBlockDeviceArgs>

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

EbsOptimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

EphemeralBlockDevices List<InstanceEphemeralBlockDeviceArgs>

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

GetPasswordData bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

Hibernation bool

If true, the launched EC2 instance will support hibernation.

HostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

IamInstanceProfile string

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

InstanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

Ipv6AddressCount int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

Ipv6Addresses List<string>

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

KeyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

MetadataOptions InstanceMetadataOptionsArgs

Customize the metadata options of the instance. See Metadata Options below for more details.

Monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

NetworkInterfaces List<InstanceNetworkInterfaceArgs>

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

PlacementGroup string

The Placement Group to start the instance in.

PrivateIp string

Private IP address to associate with the instance in a VPC.

RootBlockDevice InstanceRootBlockDeviceArgs

Customize details about the root block device of the instance. See Block Devices below for details.

SecondaryPrivateIps List<string>

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

SecurityGroups List<string>

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

SourceDestCheck bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

SubnetId string

The VPC Subnet ID to launch in.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

Tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

UserData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

UserDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

VolumeTags Dictionary<string, string>

A map of tags to assign to the devices created by the instance at launch time.

VpcSecurityGroupIds List<string>

A list of security group IDs to associate with.

Ami string

The AMI to use for the instance.

InstanceType string

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

AssociatePublicIpAddress bool

Associate a public ip address with an instance in a VPC. Boolean value.

AvailabilityZone string

The AZ to start the instance in.

CpuCoreCount int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

CpuThreadsPerCore int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

CreditSpecification InstanceCreditSpecification

Customize the credit specification of the instance. See Credit Specification below for more details.

DisableApiTermination bool

If true, enables EC2 Instance Termination Protection

EbsBlockDevices []InstanceEbsBlockDevice

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

EbsOptimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

EphemeralBlockDevices []InstanceEphemeralBlockDevice

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

GetPasswordData bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

Hibernation bool

If true, the launched EC2 instance will support hibernation.

HostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

IamInstanceProfile interface{}

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

InstanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

Ipv6AddressCount int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

Ipv6Addresses []string

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

KeyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

MetadataOptions InstanceMetadataOptions

Customize the metadata options of the instance. See Metadata Options below for more details.

Monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

NetworkInterfaces []InstanceNetworkInterface

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

PlacementGroup string

The Placement Group to start the instance in.

PrivateIp string

Private IP address to associate with the instance in a VPC.

RootBlockDevice InstanceRootBlockDevice

Customize details about the root block device of the instance. See Block Devices below for details.

SecondaryPrivateIps []string

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

SecurityGroups []string

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

SourceDestCheck bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

SubnetId string

The VPC Subnet ID to launch in.

Tags map[string]string

A map of tags to assign to the resource.

Tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

UserData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

UserDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

VolumeTags map[string]string

A map of tags to assign to the devices created by the instance at launch time.

VpcSecurityGroupIds []string

A list of security group IDs to associate with.

ami string

The AMI to use for the instance.

instanceType InstanceType

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

associatePublicIpAddress boolean

Associate a public ip address with an instance in a VPC. Boolean value.

availabilityZone string

The AZ to start the instance in.

cpuCoreCount number

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

cpuThreadsPerCore number

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

creditSpecification InstanceCreditSpecification

Customize the credit specification of the instance. See Credit Specification below for more details.

disableApiTermination boolean

If true, enables EC2 Instance Termination Protection

ebsBlockDevices InstanceEbsBlockDevice[]

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

ebsOptimized boolean

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

ephemeralBlockDevices InstanceEphemeralBlockDevice[]

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

getPasswordData boolean

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

hibernation boolean

If true, the launched EC2 instance will support hibernation.

hostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

iamInstanceProfile string | InstanceProfile

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

instanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

ipv6AddressCount number

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

ipv6Addresses string[]

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

keyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

metadataOptions InstanceMetadataOptions

Customize the metadata options of the instance. See Metadata Options below for more details.

monitoring boolean

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

networkInterfaces InstanceNetworkInterface[]

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

placementGroup string

The Placement Group to start the instance in.

privateIp string

Private IP address to associate with the instance in a VPC.

rootBlockDevice InstanceRootBlockDevice

Customize details about the root block device of the instance. See Block Devices below for details.

secondaryPrivateIps string[]

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

securityGroups string[]

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

sourceDestCheck boolean

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

subnetId string

The VPC Subnet ID to launch in.

tags {[key: string]: string}

A map of tags to assign to the resource.

tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

userData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

userDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

volumeTags {[key: string]: string}

A map of tags to assign to the devices created by the instance at launch time.

vpcSecurityGroupIds string[]

A list of security group IDs to associate with.

ami str

The AMI to use for the instance.

instance_type str

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

associate_public_ip_address bool

Associate a public ip address with an instance in a VPC. Boolean value.

availability_zone str

The AZ to start the instance in.

cpu_core_count int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

cpu_threads_per_core int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

credit_specification InstanceCreditSpecificationArgs

Customize the credit specification of the instance. See Credit Specification below for more details.

disable_api_termination bool

If true, enables EC2 Instance Termination Protection

ebs_block_devices Sequence[InstanceEbsBlockDeviceArgs]

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

ebs_optimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

ephemeral_block_devices Sequence[InstanceEphemeralBlockDeviceArgs]

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

get_password_data bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

hibernation bool

If true, the launched EC2 instance will support hibernation.

host_id str

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

iam_instance_profile str

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

instance_initiated_shutdown_behavior str

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

ipv6_address_count int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

ipv6_addresses Sequence[str]

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

key_name str

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

metadata_options InstanceMetadataOptionsArgs

Customize the metadata options of the instance. See Metadata Options below for more details.

monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

network_interfaces Sequence[InstanceNetworkInterfaceArgs]

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

placement_group str

The Placement Group to start the instance in.

private_ip str

Private IP address to associate with the instance in a VPC.

root_block_device InstanceRootBlockDeviceArgs

Customize details about the root block device of the instance. See Block Devices below for details.

secondary_private_ips Sequence[str]

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

security_groups Sequence[str]

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

source_dest_check bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

subnet_id str

The VPC Subnet ID to launch in.

tags Mapping[str, str]

A map of tags to assign to the resource.

tenancy str

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

user_data str

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

user_data_base64 str

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

volume_tags Mapping[str, str]

A map of tags to assign to the devices created by the instance at launch time.

vpc_security_group_ids Sequence[str]

A list of security group IDs to associate with.

Outputs

All input properties are implicitly available as output properties. Additionally, the Instance resource produces the following output properties:

Arn string

The ARN of the instance.

Id string
The provider-assigned unique ID for this managed resource.
OutpostArn string

The ARN of the Outpost the instance is assigned to.

PasswordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

PrimaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

PrivateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

PublicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

PublicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

State string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

Arn string

The ARN of the instance.

Id string
The provider-assigned unique ID for this managed resource.
InstanceState string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

OutpostArn string

The ARN of the Outpost the instance is assigned to.

PasswordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

PrimaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

PrivateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

PublicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

PublicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

arn string

The ARN of the instance.

id string
The provider-assigned unique ID for this managed resource.
instanceState string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

outpostArn string

The ARN of the Outpost the instance is assigned to.

passwordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

primaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

privateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

publicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

publicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

arn str

The ARN of the instance.

id str
The provider-assigned unique ID for this managed resource.
instance_state str

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

outpost_arn str

The ARN of the Outpost the instance is assigned to.

password_data str

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

primary_network_interface_id str

The ID of the instance’s primary network interface.

private_dns str

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

public_dns str

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

public_ip str

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

Look up an Existing Instance Resource

Get an existing Instance resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: InstanceState, opts?: CustomResourceOptions): Instance
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, ami: Optional[str] = None, arn: Optional[str] = None, associate_public_ip_address: Optional[bool] = None, availability_zone: Optional[str] = None, cpu_core_count: Optional[int] = None, cpu_threads_per_core: Optional[int] = None, credit_specification: Optional[InstanceCreditSpecificationArgs] = None, disable_api_termination: Optional[bool] = None, ebs_block_devices: Optional[Sequence[InstanceEbsBlockDeviceArgs]] = None, ebs_optimized: Optional[bool] = None, ephemeral_block_devices: Optional[Sequence[InstanceEphemeralBlockDeviceArgs]] = None, get_password_data: Optional[bool] = None, hibernation: Optional[bool] = None, host_id: Optional[str] = None, iam_instance_profile: Optional[str] = None, instance_initiated_shutdown_behavior: Optional[str] = None, instance_state: Optional[str] = None, instance_type: Optional[str] = None, ipv6_address_count: Optional[int] = None, ipv6_addresses: Optional[Sequence[str]] = None, key_name: Optional[str] = None, metadata_options: Optional[InstanceMetadataOptionsArgs] = None, monitoring: Optional[bool] = None, network_interfaces: Optional[Sequence[InstanceNetworkInterfaceArgs]] = None, outpost_arn: Optional[str] = None, password_data: Optional[str] = None, placement_group: Optional[str] = None, primary_network_interface_id: Optional[str] = None, private_dns: Optional[str] = None, private_ip: Optional[str] = None, public_dns: Optional[str] = None, public_ip: Optional[str] = None, root_block_device: Optional[InstanceRootBlockDeviceArgs] = None, secondary_private_ips: Optional[Sequence[str]] = None, security_groups: Optional[Sequence[str]] = None, source_dest_check: Optional[bool] = None, subnet_id: Optional[str] = None, tags: Optional[Mapping[str, str]] = None, tenancy: Optional[str] = None, user_data: Optional[str] = None, user_data_base64: Optional[str] = None, volume_tags: Optional[Mapping[str, str]] = None, vpc_security_group_ids: Optional[Sequence[str]] = None) -> Instance
func GetInstance(ctx *Context, name string, id IDInput, state *InstanceState, opts ...ResourceOption) (*Instance, error)
public static Instance Get(string name, Input<string> id, InstanceState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Ami string

The AMI to use for the instance.

Arn string

The ARN of the instance.

AssociatePublicIpAddress bool

Associate a public ip address with an instance in a VPC. Boolean value.

AvailabilityZone string

The AZ to start the instance in.

CpuCoreCount int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

CpuThreadsPerCore int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

CreditSpecification InstanceCreditSpecificationArgs

Customize the credit specification of the instance. See Credit Specification below for more details.

DisableApiTermination bool

If true, enables EC2 Instance Termination Protection

EbsBlockDevices List<InstanceEbsBlockDeviceArgs>

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

EbsOptimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

EphemeralBlockDevices List<InstanceEphemeralBlockDeviceArgs>

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

GetPasswordData bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

Hibernation bool

If true, the launched EC2 instance will support hibernation.

HostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

IamInstanceProfile string

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

InstanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

InstanceType string

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

Ipv6AddressCount int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

Ipv6Addresses List<string>

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

KeyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

MetadataOptions InstanceMetadataOptionsArgs

Customize the metadata options of the instance. See Metadata Options below for more details.

Monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

NetworkInterfaces List<InstanceNetworkInterfaceArgs>

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

OutpostArn string

The ARN of the Outpost the instance is assigned to.

PasswordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

PlacementGroup string

The Placement Group to start the instance in.

PrimaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

PrivateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

PrivateIp string

Private IP address to associate with the instance in a VPC.

PublicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

PublicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

RootBlockDevice InstanceRootBlockDeviceArgs

Customize details about the root block device of the instance. See Block Devices below for details.

SecondaryPrivateIps List<string>

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

SecurityGroups List<string>

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

SourceDestCheck bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

State string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

SubnetId string

The VPC Subnet ID to launch in.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

Tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

UserData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

UserDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

VolumeTags Dictionary<string, string>

A map of tags to assign to the devices created by the instance at launch time.

VpcSecurityGroupIds List<string>

A list of security group IDs to associate with.

Ami string

The AMI to use for the instance.

Arn string

The ARN of the instance.

AssociatePublicIpAddress bool

Associate a public ip address with an instance in a VPC. Boolean value.

AvailabilityZone string

The AZ to start the instance in.

CpuCoreCount int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

CpuThreadsPerCore int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

CreditSpecification InstanceCreditSpecification

Customize the credit specification of the instance. See Credit Specification below for more details.

DisableApiTermination bool

If true, enables EC2 Instance Termination Protection

EbsBlockDevices []InstanceEbsBlockDevice

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

EbsOptimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

EphemeralBlockDevices []InstanceEphemeralBlockDevice

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

GetPasswordData bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

Hibernation bool

If true, the launched EC2 instance will support hibernation.

HostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

IamInstanceProfile interface{}

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

InstanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

InstanceState string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

InstanceType string

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

Ipv6AddressCount int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

Ipv6Addresses []string

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

KeyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

MetadataOptions InstanceMetadataOptions

Customize the metadata options of the instance. See Metadata Options below for more details.

Monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

NetworkInterfaces []InstanceNetworkInterface

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

OutpostArn string

The ARN of the Outpost the instance is assigned to.

PasswordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

PlacementGroup string

The Placement Group to start the instance in.

PrimaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

PrivateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

PrivateIp string

Private IP address to associate with the instance in a VPC.

PublicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

PublicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

RootBlockDevice InstanceRootBlockDevice

Customize details about the root block device of the instance. See Block Devices below for details.

SecondaryPrivateIps []string

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

SecurityGroups []string

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

SourceDestCheck bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

SubnetId string

The VPC Subnet ID to launch in.

Tags map[string]string

A map of tags to assign to the resource.

Tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

UserData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

UserDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

VolumeTags map[string]string

A map of tags to assign to the devices created by the instance at launch time.

VpcSecurityGroupIds []string

A list of security group IDs to associate with.

ami string

The AMI to use for the instance.

arn string

The ARN of the instance.

associatePublicIpAddress boolean

Associate a public ip address with an instance in a VPC. Boolean value.

availabilityZone string

The AZ to start the instance in.

cpuCoreCount number

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

cpuThreadsPerCore number

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

creditSpecification InstanceCreditSpecification

Customize the credit specification of the instance. See Credit Specification below for more details.

disableApiTermination boolean

If true, enables EC2 Instance Termination Protection

ebsBlockDevices InstanceEbsBlockDevice[]

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

ebsOptimized boolean

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

ephemeralBlockDevices InstanceEphemeralBlockDevice[]

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

getPasswordData boolean

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

hibernation boolean

If true, the launched EC2 instance will support hibernation.

hostId string

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

iamInstanceProfile string | InstanceProfile

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

instanceInitiatedShutdownBehavior string

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

instanceState string

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

instanceType InstanceType

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

ipv6AddressCount number

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

ipv6Addresses string[]

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

keyName string

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

metadataOptions InstanceMetadataOptions

Customize the metadata options of the instance. See Metadata Options below for more details.

monitoring boolean

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

networkInterfaces InstanceNetworkInterface[]

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

outpostArn string

The ARN of the Outpost the instance is assigned to.

passwordData string

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

placementGroup string

The Placement Group to start the instance in.

primaryNetworkInterfaceId string

The ID of the instance’s primary network interface.

privateDns string

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

privateIp string

Private IP address to associate with the instance in a VPC.

publicDns string

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

publicIp string

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

rootBlockDevice InstanceRootBlockDevice

Customize details about the root block device of the instance. See Block Devices below for details.

secondaryPrivateIps string[]

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

securityGroups string[]

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

sourceDestCheck boolean

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

subnetId string

The VPC Subnet ID to launch in.

tags {[key: string]: string}

A map of tags to assign to the resource.

tenancy string

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

userData string

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

userDataBase64 string

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

volumeTags {[key: string]: string}

A map of tags to assign to the devices created by the instance at launch time.

vpcSecurityGroupIds string[]

A list of security group IDs to associate with.

ami str

The AMI to use for the instance.

arn str

The ARN of the instance.

associate_public_ip_address bool

Associate a public ip address with an instance in a VPC. Boolean value.

availability_zone str

The AZ to start the instance in.

cpu_core_count int

Sets the number of CPU cores for an instance. This option is only supported on creation of instance type that support CPU Options CPU Cores and Threads Per CPU Core Per Instance Type - specifying this option for unsupported instance types will return an error from the EC2 API.

cpu_threads_per_core int

If set to to 1, hyperthreading is disabled on the launched instance. Defaults to 2 if not set. See Optimizing CPU Options for more information.

credit_specification InstanceCreditSpecificationArgs

Customize the credit specification of the instance. See Credit Specification below for more details.

disable_api_termination bool

If true, enables EC2 Instance Termination Protection

ebs_block_devices Sequence[InstanceEbsBlockDeviceArgs]

Additional EBS block devices to attach to the instance. Block device configurations only apply on resource creation. See Block Devices below for details on attributes and drift detection.

ebs_optimized bool

If true, the launched EC2 instance will be EBS-optimized. Note that if this is not set on an instance type that is optimized by default then this will show as disabled but if the instance type is optimized by default then there is no need to set this and there is no effect to disabling it. See the EBS Optimized section of the AWS User Guide for more information.

ephemeral_block_devices Sequence[InstanceEphemeralBlockDeviceArgs]

Customize Ephemeral (also known as “Instance Store”) volumes on the instance. See Block Devices below for details.

get_password_data bool

If true, wait for password data to become available and retrieve it. Useful for getting the administrator password for instances running Microsoft Windows. The password data is exported to the password_data attribute. See GetPasswordData for more information.

hibernation bool

If true, the launched EC2 instance will support hibernation.

host_id str

The Id of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host.

iam_instance_profile str

The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. Ensure your credentials have the correct permission to assign the instance profile according to the EC2 documentation, notably iam:PassRole.

instance_initiated_shutdown_behavior str

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instances. See Shutdown Behavior for more information.

instance_state str

The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped. See Instance Lifecycle for more information.

instance_type str

The type of instance to start. Updates to this field will trigger a stop/start of the EC2 instance.

ipv6_address_count int

A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet.

ipv6_addresses Sequence[str]

Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface

key_name str

The key name of the Key Pair to use for the instance; which can be managed using the aws.ec2.KeyPair resource.

metadata_options InstanceMetadataOptionsArgs

Customize the metadata options of the instance. See Metadata Options below for more details.

monitoring bool

If true, the launched EC2 instance will have detailed monitoring enabled. (Available since v0.6.0)

network_interfaces Sequence[InstanceNetworkInterfaceArgs]

Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.

outpost_arn str

The ARN of the Outpost the instance is assigned to.

password_data str

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if get_password_data is true. Note that this encrypted value will be stored in the state file, as with all exported attributes. See GetPasswordData for more information.

placement_group str

The Placement Group to start the instance in.

primary_network_interface_id str

The ID of the instance’s primary network interface.

private_dns str

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you’ve enabled DNS hostnames for your VPC

private_ip str

Private IP address to associate with the instance in a VPC.

public_dns str

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you’ve enabled DNS hostnames for your VPC

public_ip str

The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws.ec2.Eip with your instance, you should refer to the EIP’s address directly and not use public_ip, as this field will change after the EIP is attached.

root_block_device InstanceRootBlockDeviceArgs

Customize details about the root block device of the instance. See Block Devices below for details.

secondary_private_ips Sequence[str]

A list of secondary private IPv4 addresses to assign to the instance’s primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a network_interface block. Refer to the Elastic network interfaces documentation to see the maximum number of private IP addresses allowed per instance type.

security_groups Sequence[str]

A list of security group names (EC2-Classic) or IDs (default VPC) to associate with.

Deprecated: Use of securityGroups is discouraged as it does not allow for changes and will force your instance to be replaced if changes are made. To avoid this, use vpcSecurityGroupIds which allows for updates.

source_dest_check bool

Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. Defaults true.

subnet_id str

The VPC Subnet ID to launch in.

tags Mapping[str, str]

A map of tags to assign to the resource.

tenancy str

The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware. The host tenancy is not supported for the import-instance command.

user_data str

The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.

user_data_base64 str

Can be used instead of user_data to pass base64-encoded binary data directly. Use this instead of user_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption.

volume_tags Mapping[str, str]

A map of tags to assign to the devices created by the instance at launch time.

vpc_security_group_ids Sequence[str]

A list of security group IDs to associate with.

Supporting Types

InstanceCreditSpecification

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

CpuCredits string

The credit option for CPU usage. Can be "standard" or "unlimited". T3 instances are launched as unlimited by default. T2 instances are launched as standard by default.

CpuCredits string

The credit option for CPU usage. Can be "standard" or "unlimited". T3 instances are launched as unlimited by default. T2 instances are launched as standard by default.

cpuCredits string

The credit option for CPU usage. Can be "standard" or "unlimited". T3 instances are launched as unlimited by default. T2 instances are launched as standard by default.

cpu_credits str

The credit option for CPU usage. Can be "standard" or "unlimited". T3 instances are launched as unlimited by default. T2 instances are launched as standard by default.

InstanceEbsBlockDevice

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

DeviceName string

The name of the device to mount.

DeleteOnTermination bool

Whether the volume should be destroyed on instance termination (Default: true).

Encrypted bool

Enables EBS encryption on the volume (Default: false). Cannot be used with snapshot_id. Must be configured to perform drift detection.

Iops int

The amount of provisioned IOPS. This must be set with a volume_type of "io1/io2".

KmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

SnapshotId string

The Snapshot ID to mount.

VolumeId string
VolumeSize int

The size of the volume in gibibytes (GiB).

VolumeType string

The type of volume. Can be "standard", "gp2", "io1" or "io2". (Default: "gp2").

DeviceName string

The name of the device to mount.

DeleteOnTermination bool

Whether the volume should be destroyed on instance termination (Default: true).

Encrypted bool

Enables EBS encryption on the volume (Default: false). Cannot be used with snapshot_id. Must be configured to perform drift detection.

Iops int

The amount of provisioned IOPS. This must be set with a volume_type of "io1/io2".

KmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

SnapshotId string

The Snapshot ID to mount.

VolumeId string
VolumeSize int

The size of the volume in gibibytes (GiB).

VolumeType string

The type of volume. Can be "standard", "gp2", "io1" or "io2". (Default: "gp2").

deviceName string

The name of the device to mount.

deleteOnTermination boolean

Whether the volume should be destroyed on instance termination (Default: true).

encrypted boolean

Enables EBS encryption on the volume (Default: false). Cannot be used with snapshot_id. Must be configured to perform drift detection.

iops number

The amount of provisioned IOPS. This must be set with a volume_type of "io1/io2".

kmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

snapshotId string

The Snapshot ID to mount.

volumeId string
volumeSize number

The size of the volume in gibibytes (GiB).

volumeType string

The type of volume. Can be "standard", "gp2", "io1" or "io2". (Default: "gp2").

device_name str

The name of the device to mount.

delete_on_termination bool

Whether the volume should be destroyed on instance termination (Default: true).

encrypted bool

Enables EBS encryption on the volume (Default: false). Cannot be used with snapshot_id. Must be configured to perform drift detection.

iops int

The amount of provisioned IOPS. This must be set with a volume_type of "io1/io2".

kms_key_id str

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

snapshot_id str

The Snapshot ID to mount.

volume_id str
volume_size int

The size of the volume in gibibytes (GiB).

volume_type str

The type of volume. Can be "standard", "gp2", "io1" or "io2". (Default: "gp2").

InstanceEphemeralBlockDevice

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

DeviceName string

The name of the block device to mount on the instance.

NoDevice bool

Suppresses the specified device included in the AMI’s block device mapping.

VirtualName string

The Instance Store Device Name (e.g. "ephemeral0").

DeviceName string

The name of the block device to mount on the instance.

NoDevice bool

Suppresses the specified device included in the AMI’s block device mapping.

VirtualName string

The Instance Store Device Name (e.g. "ephemeral0").

deviceName string

The name of the block device to mount on the instance.

noDevice boolean

Suppresses the specified device included in the AMI’s block device mapping.

virtualName string

The Instance Store Device Name (e.g. "ephemeral0").

device_name str

The name of the block device to mount on the instance.

no_device bool

Suppresses the specified device included in the AMI’s block device mapping.

virtual_name str

The Instance Store Device Name (e.g. "ephemeral0").

InstanceMetadataOptions

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

HttpEndpoint string

Whether the metadata service is available. Can be "enabled" or "disabled". (Default: "enabled").

HttpPutResponseHopLimit int

The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Can be an integer from 1 to 64. (Default: 1).

HttpTokens string

Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2. Can be "optional" or "required". (Default: "optional").

HttpEndpoint string

Whether the metadata service is available. Can be "enabled" or "disabled". (Default: "enabled").

HttpPutResponseHopLimit int

The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Can be an integer from 1 to 64. (Default: 1).

HttpTokens string

Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2. Can be "optional" or "required". (Default: "optional").

httpEndpoint string

Whether the metadata service is available. Can be "enabled" or "disabled". (Default: "enabled").

httpPutResponseHopLimit number

The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Can be an integer from 1 to 64. (Default: 1).

httpTokens string

Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2. Can be "optional" or "required". (Default: "optional").

http_endpoint str

Whether the metadata service is available. Can be "enabled" or "disabled". (Default: "enabled").

http_put_response_hop_limit int

The desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Can be an integer from 1 to 64. (Default: 1).

http_tokens str

Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2. Can be "optional" or "required". (Default: "optional").

InstanceNetworkInterface

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

DeviceIndex int

The integer index of the network interface attachment. Limited by instance type.

NetworkInterfaceId string

The ID of the network interface to attach.

DeleteOnTermination bool

Whether or not to delete the network interface on instance termination. Defaults to false. Currently, the only valid value is false, as this is only supported when creating new network interfaces when launching an instance.

DeviceIndex int

The integer index of the network interface attachment. Limited by instance type.

NetworkInterfaceId string

The ID of the network interface to attach.

DeleteOnTermination bool

Whether or not to delete the network interface on instance termination. Defaults to false. Currently, the only valid value is false, as this is only supported when creating new network interfaces when launching an instance.

deviceIndex number

The integer index of the network interface attachment. Limited by instance type.

networkInterfaceId string

The ID of the network interface to attach.

deleteOnTermination boolean

Whether or not to delete the network interface on instance termination. Defaults to false. Currently, the only valid value is false, as this is only supported when creating new network interfaces when launching an instance.

device_index int

The integer index of the network interface attachment. Limited by instance type.

network_interface_id str

The ID of the network interface to attach.

delete_on_termination bool

Whether or not to delete the network interface on instance termination. Defaults to false. Currently, the only valid value is false, as this is only supported when creating new network interfaces when launching an instance.

InstanceRootBlockDevice

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

DeleteOnTermination bool

Whether the volume should be destroyed on instance termination (Default: true).

DeviceName string

The name of the device to mount.

Encrypted bool

Enable volume encryption. (Default: false). Must be configured to perform drift detection.

Iops int

The amount of provisioned IOPS. This is only valid for volume_type of "io1/io2", and must be specified if using that type

KmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

VolumeId string
VolumeSize int

The size of the volume in gibibytes (GiB).

VolumeType string

The type of volume. Can be "standard", "gp2", "io1", "io2", "sc1", or "st1". (Default: "gp2").

DeleteOnTermination bool

Whether the volume should be destroyed on instance termination (Default: true).

DeviceName string

The name of the device to mount.

Encrypted bool

Enable volume encryption. (Default: false). Must be configured to perform drift detection.

Iops int

The amount of provisioned IOPS. This is only valid for volume_type of "io1/io2", and must be specified if using that type

KmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

VolumeId string
VolumeSize int

The size of the volume in gibibytes (GiB).

VolumeType string

The type of volume. Can be "standard", "gp2", "io1", "io2", "sc1", or "st1". (Default: "gp2").

deleteOnTermination boolean

Whether the volume should be destroyed on instance termination (Default: true).

deviceName string

The name of the device to mount.

encrypted boolean

Enable volume encryption. (Default: false). Must be configured to perform drift detection.

iops number

The amount of provisioned IOPS. This is only valid for volume_type of "io1/io2", and must be specified if using that type

kmsKeyId string

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

volumeId string
volumeSize number

The size of the volume in gibibytes (GiB).

volumeType string

The type of volume. Can be "standard", "gp2", "io1", "io2", "sc1", or "st1". (Default: "gp2").

delete_on_termination bool

Whether the volume should be destroyed on instance termination (Default: true).

device_name str

The name of the device to mount.

encrypted bool

Enable volume encryption. (Default: false). Must be configured to perform drift detection.

iops int

The amount of provisioned IOPS. This is only valid for volume_type of "io1/io2", and must be specified if using that type

kms_key_id str

Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume. Must be configured to perform drift detection.

volume_id str
volume_size int

The size of the volume in gibibytes (GiB).

volume_type str

The type of volume. Can be "standard", "gp2", "io1", "io2", "sc1", or "st1". (Default: "gp2").

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.