AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Creates an Auto Scaling group with the specified name and attributes.

If you exceed your maximum limit of Auto Scaling groups, which by default is 20 per region, the call fails. For information about viewing and updating this limit, see DescribeAccountLimits.

For more information, see Auto Scaling Groups in the Auto Scaling User Guide.

Note:

For PCL this operation is only available in asynchronous form. Please refer to CreateAutoScalingGroupAsync.

Namespace: Amazon.AutoScaling
Assembly: AWSSDK.AutoScaling.dll
Version: 3.x.y.z

Syntax

C#
public abstract CreateAutoScalingGroupResponse CreateAutoScalingGroup(
         CreateAutoScalingGroupRequest request
)
Parameters
request
Type: Amazon.AutoScaling.Model.CreateAutoScalingGroupRequest

Container for the necessary parameters to execute the CreateAutoScalingGroup service method.

Return Value
The response from the CreateAutoScalingGroup service method, as returned by AutoScaling.

Exceptions

ExceptionCondition
AlreadyExistsException You already have an Auto Scaling group or launch configuration with this name.
LimitExceededException You have already reached a limit for your Auto Scaling resources (for example, groups, launch configurations, or lifecycle hooks). For more information, see DescribeAccountLimits.
ResourceContentionException You already have a pending update to an Auto Scaling resource (for example, a group, instance, or load balancer).

Examples

This example creates an Auto Scaling group.

To create an Auto Scaling group


var response = client.CreateAutoScalingGroup(new CreateAutoScalingGroupRequest 
{
    AutoScalingGroupName = "my-auto-scaling-group",
    LaunchConfigurationName = "my-launch-config",
    MaxSize = 3,
    MinSize = 1,
    VPCZoneIdentifier = "subnet-4176792c"
});


            

This example creates an Auto Scaling group and attaches the specified Classic Load Balancer.

To create an Auto Scaling group with an attached load balancer


var response = client.CreateAutoScalingGroup(new CreateAutoScalingGroupRequest 
{
    AutoScalingGroupName = "my-auto-scaling-group",
    AvailabilityZones = new List {
        "us-west-2c"
    },
    HealthCheckGracePeriod = 120,
    HealthCheckType = "ELB",
    LaunchConfigurationName = "my-launch-config",
    LoadBalancerNames = new List {
        "my-load-balancer"
    },
    MaxSize = 3,
    MinSize = 1
});


            

This example creates an Auto Scaling group and attaches the specified target group.

To create an Auto Scaling group with an attached target group


var response = client.CreateAutoScalingGroup(new CreateAutoScalingGroupRequest 
{
    AutoScalingGroupName = "my-auto-scaling-group",
    HealthCheckGracePeriod = 120,
    HealthCheckType = "ELB",
    LaunchConfigurationName = "my-launch-config",
    MaxSize = 3,
    MinSize = 1,
    TargetGroupARNs = new List {
        "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"
    },
    VPCZoneIdentifier = "subnet-4176792c, subnet-65ea5f08"
});


            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

See Also