Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

AWS Classic

v4.25.0 published on Friday, Oct 15, 2021 by Pulumi

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 = "key",
                    Values = 
                    {
                        "Team",
                    },
                },
                new Aws.AutoScaling.Inputs.GetAmiIdsFilterArgs
                {
                    Name = "value",
                    Values = 
                    {
                        "Pets",
                    },
                },
            },
        }));
        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/v4/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: "key",
					Values: []string{
						"Team",
					},
				},
				autoscaling.GetAmiIdsFilter{
					Name: "value",
					Values: []string{
						"Pets",
					},
				},
			},
		}, 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
	})
}
import pulumi
import pulumi_aws as aws

groups = aws.autoscaling.get_ami_ids(filters=[
    aws.autoscaling.GetAmiIdsFilterArgs(
        name="key",
        values=["Team"],
    ),
    aws.autoscaling.GetAmiIdsFilterArgs(
        name="value",
        values=["Pets"],
    ),
])
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: "key",
            values: ["Team"],
        },
        {
            name: "value",
            values: ["Pets"],
        },
    ],
});
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",
});

Using getAmiIds

function getAmiIds(args: GetAmiIdsArgs, opts?: InvokeOptions): Promise<GetAmiIdsResult>
def get_ami_ids(filters: Optional[Sequence[GetAmiIdsFilter]] = None,
                opts: Optional[InvokeOptions] = None) -> GetAmiIdsResult
func GetAmiIds(ctx *Context, args *GetAmiIdsArgs, opts ...InvokeOption) (*GetAmiIdsResult, error)

Note: This function is named GetAmiIds in the Go SDK.

public static class GetAmiIds {
    public static Task<GetAmiIdsResult> InvokeAsync(GetAmiIdsArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetAmiIdsFilter>
A filter used to scope the list e.g. by tags. See related docs.
Filters []GetAmiIdsFilter
A filter used to scope the list e.g. by tags. See related docs.
filters GetAmiIdsFilter[]
A filter used to scope the list e.g. by tags. See related docs.
filters Sequence[GetAmiIdsFilter]
A filter used to scope the list e.g. by tags. See related docs.

getAmiIds 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<GetAmiIdsFilter>
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 []GetAmiIdsFilter
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 GetAmiIdsFilter[]
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[GetAmiIdsFilter]

Supporting Types

GetAmiIdsFilter

Name string
The name of the filter. The valid values are: auto-scaling-group, key, value, and propagate-at-launch.
Values List<string>
The value of the filter.
Name string
The name of the filter. The valid values are: auto-scaling-group, key, value, and propagate-at-launch.
Values []string
The value of the filter.
name string
The name of the filter. The valid values are: auto-scaling-group, key, value, and propagate-at-launch.
values string[]
The value of the filter.
name str
The name of the filter. The valid values are: auto-scaling-group, key, value, and propagate-at-launch.
values Sequence[str]
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.