Show / Hide Table of Contents

Class Instance

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

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

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

}
Inheritance
System.Object
Resource
CustomResource
Instance
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Ec2
Assembly: Pulumi.Aws.dll
Syntax
public class Instance : CustomResource

Constructors

View Source

Instance(String, InstanceArgs, CustomResourceOptions)

Create a Instance resource with the given unique name, arguments, and options.

Declaration
public Instance(string name, InstanceArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

InstanceArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Ami

The AMI to use for the instance.

Declaration
public Output<string> Ami { get; }
Property Value
Type Description
Output<System.String>
View Source

Arn

The ARN of the instance.

Declaration
public Output<string> Arn { get; }
Property Value
Type Description
Output<System.String>
View Source

AssociatePublicIpAddress

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

Declaration
public Output<bool> AssociatePublicIpAddress { get; }
Property Value
Type Description
Output<System.Boolean>
View Source

AvailabilityZone

The AZ to start the instance in.

Declaration
public Output<string> AvailabilityZone { get; }
Property Value
Type Description
Output<System.String>
View Source

CpuCoreCount

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.

Declaration
public Output<int> CpuCoreCount { get; }
Property Value
Type Description
Output<System.Int32>
View Source

CpuThreadsPerCore

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.

Declaration
public Output<int> CpuThreadsPerCore { get; }
Property Value
Type Description
Output<System.Int32>
View Source

CreditSpecification

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

Declaration
public Output<InstanceCreditSpecification> CreditSpecification { get; }
Property Value
Type Description
Output<InstanceCreditSpecification>
View Source

DisableApiTermination

If true, enables EC2 Instance Termination Protection

Declaration
public Output<bool?> DisableApiTermination { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

EbsBlockDevices

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.

Declaration
public Output<ImmutableArray<InstanceEbsBlockDevice>> EbsBlockDevices { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<InstanceEbsBlockDevice>>
View Source

EbsOptimized

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.

Declaration
public Output<bool?> EbsOptimized { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

EphemeralBlockDevices

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

Declaration
public Output<ImmutableArray<InstanceEphemeralBlockDevice>> EphemeralBlockDevices { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<InstanceEphemeralBlockDevice>>
View Source

GetPasswordData

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.

Declaration
public Output<bool?> GetPasswordData { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Hibernation

If true, the launched EC2 instance will support hibernation.

Declaration
public Output<bool?> Hibernation { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

HostId

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.

Declaration
public Output<string> HostId { get; }
Property Value
Type Description
Output<System.String>
View Source

IamInstanceProfile

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.

Declaration
public Output<string> IamInstanceProfile { get; }
Property Value
Type Description
Output<System.String>
View Source

InstanceInitiatedShutdownBehavior

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.

Declaration
public Output<string> InstanceInitiatedShutdownBehavior { get; }
Property Value
Type Description
Output<System.String>
View Source

InstanceType

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

Declaration
public Output<string> InstanceType { get; }
Property Value
Type Description
Output<System.String>
View Source

Ipv6AddressCount

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

Declaration
public Output<int> Ipv6AddressCount { get; }
Property Value
Type Description
Output<System.Int32>
View Source

Ipv6Addresses

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

Declaration
public Output<ImmutableArray<string>> Ipv6Addresses { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

KeyName

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

Declaration
public Output<string> KeyName { get; }
Property Value
Type Description
Output<System.String>
View Source

MetadataOptions

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

Declaration
public Output<InstanceMetadataOptions> MetadataOptions { get; }
Property Value
Type Description
Output<InstanceMetadataOptions>
View Source

Monitoring

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

Declaration
public Output<bool?> Monitoring { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

NetworkInterfaces

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

Declaration
public Output<ImmutableArray<InstanceNetworkInterface>> NetworkInterfaces { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<InstanceNetworkInterface>>
View Source

OutpostArn

The ARN of the Outpost the instance is assigned to.

Declaration
public Output<string> OutpostArn { get; }
Property Value
Type Description
Output<System.String>
View Source

PasswordData

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.

Declaration
public Output<string> PasswordData { get; }
Property Value
Type Description
Output<System.String>
View Source

PlacementGroup

The Placement Group to start the instance in.

Declaration
public Output<string> PlacementGroup { get; }
Property Value
Type Description
Output<System.String>
View Source

PrimaryNetworkInterfaceId

The ID of the instance's primary network interface.

Declaration
public Output<string> PrimaryNetworkInterfaceId { get; }
Property Value
Type Description
Output<System.String>
View Source

PrivateDns

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

Declaration
public Output<string> PrivateDns { get; }
Property Value
Type Description
Output<System.String>
View Source

PrivateIp

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

Declaration
public Output<string> PrivateIp { get; }
Property Value
Type Description
Output<System.String>
View Source

PublicDns

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

Declaration
public Output<string> PublicDns { get; }
Property Value
Type Description
Output<System.String>
View Source

PublicIp

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.

Declaration
public Output<string> PublicIp { get; }
Property Value
Type Description
Output<System.String>
View Source

RootBlockDevice

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

Declaration
public Output<InstanceRootBlockDevice> RootBlockDevice { get; }
Property Value
Type Description
Output<InstanceRootBlockDevice>
View Source

SecurityGroups

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

Declaration
public Output<ImmutableArray<string>> SecurityGroups { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

SourceDestCheck

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

Declaration
public Output<bool?> SourceDestCheck { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

State

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

Declaration
public Output<string> State { get; }
Property Value
Type Description
Output<System.String>
View Source

SubnetId

The VPC Subnet ID to launch in.

Declaration
public Output<string> SubnetId { get; }
Property Value
Type Description
Output<System.String>
View Source

Tags

A map of tags to assign to the resource.

Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>
View Source

Tenancy

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.

Declaration
public Output<string> Tenancy { get; }
Property Value
Type Description
Output<System.String>
View Source

UserData

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

Declaration
public Output<string> UserData { get; }
Property Value
Type Description
Output<System.String>
View Source

UserDataBase64

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.

Declaration
public Output<string> UserDataBase64 { get; }
Property Value
Type Description
Output<System.String>
View Source

VolumeTags

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

Declaration
public Output<ImmutableDictionary<string, object>> VolumeTags { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>
View Source

VpcSecurityGroupIds

A list of security group IDs to associate with.

Declaration
public Output<ImmutableArray<string>> VpcSecurityGroupIds { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>

Methods

View Source

Get(String, Input<String>, InstanceState, CustomResourceOptions)

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

Declaration
public static Instance Get(string name, Input<string> id, InstanceState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

InstanceState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Instance
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.