Menu
Auto Scaling
User Guide

Launching Auto Scaling Instances in a VPC

Amazon Virtual Private Cloud (Amazon VPC) enables you to define a virtual networking environment in a private, isolated section of the AWS cloud. You have complete control over your virtual networking environment. For more information, see the Amazon VPC User Guide.

Within a virtual private cloud (VPC), you can launch AWS resources such as an Auto Scaling group. An Auto Scaling group in a VPC works essentially the same way as it does on Amazon EC2 and supports the same set of features.

A subnet in Amazon VPC is a subdivision within an Availability Zone defined by a segment of the IP address range of the VPC. Using subnets, you can group your instances based on your security and operational needs. A subnet resides entirely within the Availability Zone it was created in. You launch Auto Scaling instances within the subnets.

To enable communication between the Internet and the instances in your subnets, you must create an Internet gateway and attach it to your VPC. An Internet gateway enables your resources within the subnets to connect to the Internet through the Amazon EC2 network edge. If a subnet's traffic is routed to an Internet gateway, the subnet is known as a public subnet. If a subnet's traffic is not routed to an Internet gateway, the subnet is known as a private subnet. Use a public subnet for resources that must be connected to the Internet, and a private subnet for resources that need not be connected to the Internet.

Prerequisites

Before you can launch your Auto Scaling instances in a VPC, you must first create your VPC environment. After you create your VPC and subnets, you launch Auto Scaling instances within the subnets. The easiest way to create a VPC with one public subnet is to use the VPC wizard. For more information, see the Amazon VPC Getting Started Guide.

Default VPC

If you have created your AWS account after 2013-12-04 or you are creating your Auto Scaling group in a new region, we create a default VPC for you. Your default VPC comes with a default subnet in each Availability Zone. If you have a default VPC, your Auto Scaling group is created in the default VPC by default.

For information about default VPCs and checking whether your account comes with a default VPC, see Your Default VPC and Subnets in the Amazon VPC Developer Guide.

IP Addressing in a VPC

When you launch your Auto Scaling instances in a VPC, your instances are automatically assigned with a private IP address in the address range of the subnet. This enables your instances to communicate with other instances in the VPC. You have an option to assign a public IP address to your instance. Assigning a public IP address to your instance allows it to communicate with the Internet or other services in AWS. You can choose the option of assigning public IP address to your instances when you create your launch configuration.

Instance Placement Tenancy

Dedicated Instances are physically isolated at the host hardware level from instances that aren't dedicated and from instances that belong to other AWS accounts. When you create a VPC, by default its tenancy attribute is set to default. In such a VPC, you can launch instances with a tenancy value of dedicated so that they run as single-tenancy instances. Otherwise, they run as shared-tenancy instances by default. If you set the tenancy attribute of a VPC to dedicated, all instances launched in the VPC run as single-tenancy instances. For more information, see Dedicated Instances in the Amazon VPC User Guide. For pricing information, see the Amazon EC2 Dedicated Instances product page.

When you create a launch configuration, the default value for the instance placement tenancy is null and the instance tenancy is controlled by the tenancy attribute of the VPC. The following table summarizes the instance placement tenancy of the Auto Scaling instances launched in a VPC.

Launch Configuration TenancyVPC Tenancy = defaultVPC Tenancy = dedicated

not specified

shared-tenancy instance

Dedicated Instance

default

shared-tenancy instance

Dedicated Instance

dedicated

Dedicated Instance

Dedicated Instance

You can specify the instance placement tenancy for your launch configuration as default or dedicated using the create-launch-configuration command with the --placement-tenancy option. For example, the following command sets the launch configuration tenancy to dedicated:

aws autoscaling create-launch-configuration --launch-configuration-name my-launch-config --placement-tenancy dedicated --image-id ...

You can use the following describe-launch-configurations command to verify the instance placement tenancy of the launch configuration:

aws autoscaling describe-launch-configurations --launch-configuration-names my-launch-config

The following is example output for a launch configuration that creates Dedicated Instances. Note that PlacementTenancy is not part of the output for this command unless you have explicitly set the instance placement tenancy.

{
    "LaunchConfigurations": [
        {
            "UserData": null,
            "EbsOptimized": false,
            "PlacementTenancy": "dedicated",
            "LaunchConfigurationARN": "arn",
            "InstanceMonitoring": {
                "Enabled": true
            },
            "ImageId": "ami-b5a7ea85",
            "CreatedTime": "2015-03-08T23:39:49.011Z",
            "BlockDeviceMappings": [],
            "KeyName": null,
            "SecurityGroups": [],
            "LaunchConfigurationName": "my-launch-config",
            "KernelId": null,
            "RamdiskId": null,
            "InstanceType": "m3.medium"
        }
    ]

If you are launching the instances in your Auto Scaling group in EC2-Classic, you can link them to a VPC using ClassicLink. ClassicLink enables you to associate one or more security groups for the VPC with the EC2-Classic instances in your Auto Scaling group, enabling communication between these linked EC2-Classic instances and instances in the VPC using private IP addresses. For more information, see ClassicLink in the Amazon EC2 User Guide for Linux Instances.

If you have running EC2-Classic instances in your Auto Scaling group, you can link them to a VPC with ClassicLink enabled. For more information, see Linking an Instance to a VPC in the Amazon EC2 User Guide for Linux Instances. Alternatively, you can update the Auto Scaling group to use a launch configuration that automatically links the EC2-Classic instances to a VPC at launch, then terminate the running instances and let Auto Scaling launch new instances that are linked to the VPC.

Use the following procedure to create a launch configuration that links EC2-Classic instances to the specified VPC and update an existing Auto Scaling group to use the launch configuration.

To link EC2-Classic instances in an Auto Scaling group to a VPC using the console

  1. Verify that the VPC has ClassicLink enabled. For more information, see Viewing Your ClassicLink-Enabled VPCs in the Amazon EC2 User Guide for Linux Instances.

  2. Create a security group for the VPC that you are going to link EC2-Classic instances to, with rules to control communication between the linked EC2-Classic instances and instances in the VPC.

  3. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  4. On the navigation pane, choose Launch Configurations. If you are new to Auto Scaling, you see a welcome page. Choose Create Auto Scaling group.

  5. Choose Create launch configuration.

  6. On the Choose AMI page, select an AMI.

  7. On the Choose an Instance Type page, select an instance type, and then choose Next: Configure details.

  8. On the Configure details page, do the following:

    1. Type a name for your launch configuration.

    2. Expand Advanced Details, select the IP Address Type that you need, and then select Link to VPC.

    3. For VPC, select the VPC with ClassicLink enabled from step 1.

    4. For Security Groups, select the security group from step 2.

    5. Choose Skip to review.

  9. On the Review page, make any changes that you need, and then choose Create launch configuration. For Select an existing key pair or create a new key pair, select an option, select the acknowledgment check box (if present), and then choose Create launch configuration.

  10. When prompted, follow the directions to create an Auto Scaling group that uses the new launch configuration. Be sure to select Launch into EC2-Classic for Network. Otherwise, choose Cancel and then add your launch configuration to an existing Auto Scaling group as follows:

    1. On the navigation pane, choose Auto Scaling Groups.

    2. Select your Auto Scaling group, choose Actions, Edit.

    3. For Launch Configuration, select your new launch configuration and then choose Save.

Use the following procedure to create a launch configuration that links EC2-Classic instances to the specified VPC and update an existing Auto Scaling group to use the launch configuration.

To link EC2-Classic instances in an Auto Scaling group to a VPC using the AWS CLI

  1. Verify that the VPC has ClassicLink enabled. For more information, see Viewing Your ClassicLink-Enabled VPCs in the Amazon EC2 User Guide for Linux Instances.

  2. Create a security group for the VPC that you are going to link EC2-Classic instances to, with rules to control communication between the linked EC2-Classic instances and instances in the VPC.

  3. Create a launch configuration using the create-launch-configuration command as follows, where vpd_id is the ID of the VPC with ClassicLink enabled from step 1 and group_id is the security group from step 2:

    aws autoscaling create-launch-configuration --launch-configuration-name classiclink-config 
    --image-id ami_id --instance-type instance_type
    --classic-link-vpc-id vpc_id --classic-link-vpc-security-groups group_id
  4. Update your existing Auto Scaling group, for example my-asg, with the launch configuration that you created in the previous step. Any new EC2-Classic instances launched in this Auto Scaling group are linked EC2-Classic instances. Use the update-auto-scaling-group command as follows:

    aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg 
    --launch-configuration-name classiclink-config

    Alternatively, you can use this launch configuration with a new Auto Scaling group that you create using create-auto-scaling-group.