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

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("slack_notifications", {
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",
});
import pulumi
import pulumi_aws as aws
groups = aws.autoscaling.get_ami_ids(filters=[
{
"name": "tag:Team",
"values": ["Pets"],
},
{
"name": "tag-key",
"values": ["Environment"],
},
])
slack_notifications = aws.autoscaling.Notification("slack_notifications",
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")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var groups = Aws.AutoScaling.GetAmiIds.Invoke(new()
{
Filters = new[]
{
new Aws.AutoScaling.Inputs.GetAmiIdsFilterInputArgs
{
Name = "tag:Team",
Values = new[]
{
"Pets",
},
},
new Aws.AutoScaling.Inputs.GetAmiIdsFilterInputArgs
{
Name = "tag-key",
Values = new[]
{
"Environment",
},
},
},
});
var slackNotifications = new Aws.AutoScaling.Notification("slack_notifications", new()
{
GroupNames = groups.Apply(getAmiIdsResult => getAmiIdsResult.Names),
Notifications = new[]
{
"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/v6/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{
{
Name: "tag:Team",
Values: []string{
"Pets",
},
},
{
Name: "tag-key",
Values: []string{
"Environment",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = autoscaling.NewNotification(ctx, "slack_notifications", &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 com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.autoscaling.AutoscalingFunctions;
import com.pulumi.aws.autoscaling.inputs.GetAmiIdsArgs;
import com.pulumi.aws.autoscaling.Notification;
import com.pulumi.aws.autoscaling.NotificationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var groups = 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.names())
.notifications(
"autoscaling:EC2_INSTANCE_LAUNCH",
"autoscaling:EC2_INSTANCE_TERMINATE",
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
"autoscaling:EC2_INSTANCE_TERMINATE_ERROR")
.topicArn("TOPIC ARN")
.build());
}
}
resources:
slackNotifications:
type: aws:autoscaling:Notification
name: slack_notifications
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

Return

A collection of values returned by getAmiIds.

Parameters

argument

A collection of arguments for invoking getAmiIds.


suspend fun getAmiIds(filters: List<GetAmiIdsFilter>? = null, names: List<String>? = null): GetAmiIdsResult

Return

A collection of values returned by getAmiIds.

Parameters

filters

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

names

List of autoscaling group names

See also


suspend fun getAmiIds(argument: suspend GetAmiIdsPlainArgsBuilder.() -> Unit): GetAmiIdsResult

Return

A collection of values returned by getAmiIds.

Parameters

argument

Builder for com.pulumi.aws.autoscaling.kotlin.inputs.GetAmiIdsPlainArgs.

See also