Show / Hide Table of Contents

Class LaunchConfiguration

Provides a resource to create a new launch configuration, used for autoscaling groups.

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 asConf = new Aws.Ec2.LaunchConfiguration("asConf", new Aws.Ec2.LaunchConfigurationArgs
    {
        ImageId = ubuntu.Apply(ubuntu => ubuntu.Id),
        InstanceType = "t2.micro",
    });
}

}

Using with AutoScaling Groups

Launch Configurations cannot be updated after creation with the Amazon Web Service API. In order to update a Launch Configuration, this provider will destroy the existing resource and create a replacement. In order to effectively use a Launch Configuration resource with an AutoScaling Group resource, it's recommended to specify create_before_destroy in a lifecycle block. Either omit the Launch Configuration name attribute, or specify a partial name with name_prefix. Example:

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 asConf = new Aws.Ec2.LaunchConfiguration("asConf", new Aws.Ec2.LaunchConfigurationArgs
    {
        ImageId = ubuntu.Apply(ubuntu => ubuntu.Id),
        InstanceType = "t2.micro",
        NamePrefix = "lc-example-",
    });
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
        LaunchConfiguration = asConf.Name,
        MaxSize = 2,
        MinSize = 1,
    });
}

}

With this setup this provider generates a unique name for your Launch Configuration and can then update the AutoScaling Group without conflict before destroying the previous Launch Configuration.

Using with Spot Instances

Launch configurations can set the spot instance pricing to be used for the Auto Scaling Group to reserve instances. Simply specifying the spot_price parameter will set the price on the Launch Configuration which will attempt to reserve your instances at this price. See the AWS Spot Instance documentation for more information or how to launch Spot Instances with this provider.

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 asConf = new Aws.Ec2.LaunchConfiguration("asConf", new Aws.Ec2.LaunchConfigurationArgs
    {
        ImageId = ubuntu.Apply(ubuntu => ubuntu.Id),
        InstanceType = "m4.large",
        SpotPrice = "0.001",
    });
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
        LaunchConfiguration = asConf.Name,
    });
}

}

Block devices

Each of the *_block_device attributes controls a portion of the AWS Launch Configuration's "Block Device Mapping". It's a good idea to familiarize yourself with AWS's Block Device Mapping docs to understand the implications of using these attributes.

The root_block_device mapping supports the following:

  • volume_type - (Optional) The type of volume. Can be "standard", "gp2", or "io1". (Default: "standard").
  • volume_size - (Optional) The size of the volume in gigabytes.
  • iops - (Optional) The amount of provisioned IOPS. This must be set with a volume_type of "io1".
  • delete_on_termination - (Optional) Whether the volume should be destroyed on instance termination (Default: true).
  • encrypted - (Optional) Whether the volume should be encrypted or not. (Default: false).

Modifying any of the root_block_device settings requires resource replacement.

Each ebs_block_device supports the following:

  • device_name - (Required) The name of the device to mount.
  • snapshot_id - (Optional) The Snapshot ID to mount.
  • volume_type - (Optional) The type of volume. Can be "standard", "gp2", or "io1". (Default: "standard").
  • volume_size - (Optional) The size of the volume in gigabytes.
  • iops - (Optional) The amount of provisioned IOPS. This must be set with a volume_type of "io1".
  • delete_on_termination - (Optional) Whether the volume should be destroyed on instance termination (Default: true).
  • encrypted - (Optional) Whether the volume should be encrypted or not. Do not use this option if you are using snapshot_id as the encrypted flag will be determined by the snapshot. (Default: false).

Modifying any ebs_block_device currently requires resource replacement.

Each ephemeral_block_device supports the following:

  • device_name - The name of the block device to mount on the instance.
  • virtual_name - The Instance Store Device Name (e.g. "ephemeral0")

Each AWS Instance type has a different set of Instance Store block devices available for attachment. AWS publishes a list of which ephemeral devices are available on each type. The devices are always identified by the virtual_name in the format "ephemeral{0..N}".

NOTE: Changes to *_block_device configuration of existing resources cannot currently be detected by this provider. After updating to block device configuration, resource recreation can be manually triggered by using the up command with the --replace argument.

Inheritance
System.Object
Resource
CustomResource
LaunchConfiguration
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 LaunchConfiguration : CustomResource

Constructors

View Source

LaunchConfiguration(String, LaunchConfigurationArgs, CustomResourceOptions)

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

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

The unique name of the resource

LaunchConfigurationArgs 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

Arn

The Amazon Resource Name of the launch configuration.

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.

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

EbsBlockDevices

Additional EBS block devices to attach to the instance. See Block Devices below for details.

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

EbsOptimized

If true, the launched EC2 instance will be EBS-optimized.

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

EnableMonitoring

Enables/disables detailed monitoring. This is enabled by default.

Declaration
public Output<bool?> EnableMonitoring { 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<LaunchConfigurationEphemeralBlockDevice>> EphemeralBlockDevices { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<LaunchConfigurationEphemeralBlockDevice>>
View Source

IamInstanceProfile

The name attribute of the IAM instance profile to associate with launched instances.

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

ImageId

The EC2 image ID to launch.

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

InstanceType

The size of instance to launch.

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

KeyName

The key name that should be used for the instance.

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

Name

The name of the launch configuration. If you leave this blank, this provider will auto-generate a unique name.

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

NamePrefix

Creates a unique name beginning with the specified prefix. Conflicts with name.

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

PlacementTenancy

The tenancy of the instance. Valid values are &quot;default&quot; or &quot;dedicated&quot;, see AWS's Create Launch Configuration for more details

Declaration
public Output<string> PlacementTenancy { 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<LaunchConfigurationRootBlockDevice> RootBlockDevice { get; }
Property Value
Type Description
Output<LaunchConfigurationRootBlockDevice>
View Source

SecurityGroups

A list of associated security group IDS.

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

SpotPrice

The maximum price to use for reserving spot instances.

Declaration
public Output<string> SpotPrice { 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

VpcClassicLinkId

The ID of a ClassicLink-enabled VPC. Only applies to EC2-Classic instances. (eg. vpc-2730681a)

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

VpcClassicLinkSecurityGroups

The IDs of one or more security groups for the specified ClassicLink-enabled VPC (eg. sg-46ae3d11).

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

Methods

View Source

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

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

Declaration
public static LaunchConfiguration Get(string name, Input<string> id, LaunchConfigurationState 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.

LaunchConfigurationState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

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