AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.9.1 published on Tuesday, Jun 21, 2022 by Pulumi

getAutoscalingGroups

Deprecated:

aws.getAutoscalingGroups has been deprecated in favor of aws.autoscaling.getAmiIds

The Autoscaling Groups data source allows access to the list of AWS ASGs within a specific region. This will allow you to pass a list of AutoScaling Groups to other resources.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var groups = Output.Create(Aws.AutoScaling.GetAmiIds.InvokeAsync(new Aws.AutoScaling.GetAmiIdsArgs
        {
            Filters = 
            {
                new Aws.AutoScaling.Inputs.GetAmiIdsFilterArgs
                {
                    Name = "tag:Team",
                    Values = 
                    {
                        "Pets",
                    },
                },
                new Aws.AutoScaling.Inputs.GetAmiIdsFilterArgs
                {
                    Name = "tag-key",
                    Values = 
                    {
                        "Environment",
                    },
                },
            },
        }));
        var slackNotifications = new Aws.AutoScaling.Notification("slackNotifications", new Aws.AutoScaling.NotificationArgs
        {
            GroupNames = groups.Apply(groups => groups.Names),
            Notifications = 
            {
                "autoscaling:EC2_INSTANCE_LAUNCH",
                "autoscaling:EC2_INSTANCE_TERMINATE",
                "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
                "autoscaling:EC2_INSTANCE_TERMINATE_ERROR",
            },
            TopicArn = "TOPIC ARN",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		groups, err := autoscaling.GetAmiIds(ctx, &autoscaling.GetAmiIdsArgs{
			Filters: []autoscaling.GetAmiIdsFilter{
				autoscaling.GetAmiIdsFilter{
					Name: "tag:Team",
					Values: []string{
						"Pets",
					},
				},
				autoscaling.GetAmiIdsFilter{
					Name: "tag-key",
					Values: []string{
						"Environment",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = autoscaling.NewNotification(ctx, "slackNotifications", &autoscaling.NotificationArgs{
			GroupNames: interface{}(groups.Names),
			Notifications: pulumi.StringArray{
				pulumi.String("autoscaling:EC2_INSTANCE_LAUNCH"),
				pulumi.String("autoscaling:EC2_INSTANCE_TERMINATE"),
				pulumi.String("autoscaling:EC2_INSTANCE_LAUNCH_ERROR"),
				pulumi.String("autoscaling:EC2_INSTANCE_TERMINATE_ERROR"),
			},
			TopicArn: pulumi.String("TOPIC ARN"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var groups = Output.of(AutoscalingFunctions.getAmiIds(GetAmiIdsArgs.builder()
            .filters(            
                GetAmiIdsFilterArgs.builder()
                    .name("tag:Team")
                    .values("Pets")
                    .build(),
                GetAmiIdsFilterArgs.builder()
                    .name("tag-key")
                    .values("Environment")
                    .build())
            .build()));

        var slackNotifications = new Notification("slackNotifications", NotificationArgs.builder()        
            .groupNames(groups.apply(getAmiIdsResult -> getAmiIdsResult.names()))
            .notifications(            
                "autoscaling:EC2_INSTANCE_LAUNCH",
                "autoscaling:EC2_INSTANCE_TERMINATE",
                "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
                "autoscaling:EC2_INSTANCE_TERMINATE_ERROR")
            .topicArn("TOPIC ARN")
            .build());

    }
}
import pulumi
import pulumi_aws as aws

groups = aws.autoscaling.get_ami_ids(filters=[
    aws.autoscaling.GetAmiIdsFilterArgs(
        name="tag:Team",
        values=["Pets"],
    ),
    aws.autoscaling.GetAmiIdsFilterArgs(
        name="tag-key",
        values=["Environment"],
    ),
])
slack_notifications = aws.autoscaling.Notification("slackNotifications",
    group_names=groups.names,
    notifications=[
        "autoscaling:EC2_INSTANCE_LAUNCH",
        "autoscaling:EC2_INSTANCE_TERMINATE",
        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR",
    ],
    topic_arn="TOPIC ARN")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const groups = aws.autoscaling.getAmiIds({
    filters: [
        {
            name: "tag:Team",
            values: ["Pets"],
        },
        {
            name: "tag-key",
            values: ["Environment"],
        },
    ],
});
const slackNotifications = new aws.autoscaling.Notification("slackNotifications", {
    groupNames: groups.then(groups => groups.names),
    notifications: [
        "autoscaling:EC2_INSTANCE_LAUNCH",
        "autoscaling:EC2_INSTANCE_TERMINATE",
        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR",
    ],
    topicArn: "TOPIC ARN",
});
resources:
  slackNotifications:
    type: aws:autoscaling:Notification
    properties:
      groupNames: ${groups.names}
      notifications:
        - autoscaling:EC2_INSTANCE_LAUNCH
        - autoscaling:EC2_INSTANCE_TERMINATE
        - autoscaling:EC2_INSTANCE_LAUNCH_ERROR
        - autoscaling:EC2_INSTANCE_TERMINATE_ERROR
      topicArn: TOPIC ARN
variables:
  groups:
    Fn::Invoke:
      Function: aws:autoscaling:getAmiIds
      Arguments:
        filters:
          - name: tag:Team
            values:
              - Pets
          - name: tag-key
            values:
              - Environment

Using getAutoscalingGroups

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getAutoscalingGroups(args: GetAutoscalingGroupsArgs, opts?: InvokeOptions): Promise<GetAutoscalingGroupsResult>
function getAutoscalingGroupsOutput(args: GetAutoscalingGroupsOutputArgs, opts?: InvokeOptions): Output<GetAutoscalingGroupsResult>
def get_autoscaling_groups(filters: Optional[Sequence[GetAutoscalingGroupsFilter]] = None,
                           names: Optional[Sequence[str]] = None,
                           opts: Optional[InvokeOptions] = None) -> GetAutoscalingGroupsResult
def get_autoscaling_groups_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetAutoscalingGroupsFilterArgs]]]] = None,
                           names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetAutoscalingGroupsResult]
func GetAutoscalingGroups(ctx *Context, args *GetAutoscalingGroupsArgs, opts ...InvokeOption) (*GetAutoscalingGroupsResult, error)
func GetAutoscalingGroupsOutput(ctx *Context, args *GetAutoscalingGroupsOutputArgs, opts ...InvokeOption) GetAutoscalingGroupsResultOutput

> Note: This function is named GetAutoscalingGroups in the Go SDK.

public static class GetAutoscalingGroups 
{
    public static Task<GetAutoscalingGroupsResult> InvokeAsync(GetAutoscalingGroupsArgs args, InvokeOptions? opts = null)
    public static Output<GetAutoscalingGroupsResult> Invoke(GetAutoscalingGroupsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetAutoscalingGroupsResult> getAutoscalingGroups(GetAutoscalingGroupsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:index/getAutoscalingGroups:getAutoscalingGroups
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Filters List<GetAutoscalingGroupsFilter>

A filter used to scope the list e.g., by tags. See related docs.

Names List<string>

A list of autoscaling group names

Filters []GetAutoscalingGroupsFilter

A filter used to scope the list e.g., by tags. See related docs.

Names []string

A list of autoscaling group names

filters List<GetAutoscalingGroupsFilter>

A filter used to scope the list e.g., by tags. See related docs.

names List<String>

A list of autoscaling group names

filters GetAutoscalingGroupsFilter[]

A filter used to scope the list e.g., by tags. See related docs.

names string[]

A list of autoscaling group names

filters Sequence[GetAutoscalingGroupsFilter]

A filter used to scope the list e.g., by tags. See related docs.

names Sequence[str]

A list of autoscaling group names

filters List<Property Map>

A filter used to scope the list e.g., by tags. See related docs.

names List<String>

A list of autoscaling group names

getAutoscalingGroups Result

The following output properties are available:

Arns List<string>

A list of the Autoscaling Groups Arns in the current region.

Id string

The provider-assigned unique ID for this managed resource.

Names List<string>

A list of the Autoscaling Groups in the current region.

Filters List<GetAutoscalingGroupsFilter>
Arns []string

A list of the Autoscaling Groups Arns in the current region.

Id string

The provider-assigned unique ID for this managed resource.

Names []string

A list of the Autoscaling Groups in the current region.

Filters []GetAutoscalingGroupsFilter
arns List<String>

A list of the Autoscaling Groups Arns in the current region.

id String

The provider-assigned unique ID for this managed resource.

names List<String>

A list of the Autoscaling Groups in the current region.

filters List<GetAutoscalingGroupsFilter>
arns string[]

A list of the Autoscaling Groups Arns in the current region.

id string

The provider-assigned unique ID for this managed resource.

names string[]

A list of the Autoscaling Groups in the current region.

filters GetAutoscalingGroupsFilter[]
arns Sequence[str]

A list of the Autoscaling Groups Arns in the current region.

id str

The provider-assigned unique ID for this managed resource.

names Sequence[str]

A list of the Autoscaling Groups in the current region.

filters Sequence[GetAutoscalingGroupsFilter]
arns List<String>

A list of the Autoscaling Groups Arns in the current region.

id String

The provider-assigned unique ID for this managed resource.

names List<String>

A list of the Autoscaling Groups in the current region.

filters List<Property Map>

Supporting Types

GetAutoscalingGroupsFilter

Name string

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

Values List<string>

The value of the filter.

Name string

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

Values []string

The value of the filter.

name String

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

values List<String>

The value of the filter.

name string

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

values string[]

The value of the filter.

name str

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

values Sequence[str]

The value of the filter.

name String

The name of the DescribeAutoScalingGroup filter. The recommended values are: tag-key, tag-value, and tag:<tag name>

values List<String>

The value of the filter.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.