GetAutoscalingGroups
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.GetAutoscalingGroups.InvokeAsync(new Aws.GetAutoscalingGroupsArgs
{
Filters =
{
new Aws.Inputs.GetAutoscalingGroupsFilterArgs
{
Name = "key",
Values =
{
"Team",
},
},
new Aws.Inputs.GetAutoscalingGroupsFilterArgs
{
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/v2/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/autoscaling"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
groups, err := aws.GetAutoscalingGroups(ctx, &aws.GetAutoscalingGroupsArgs{
Filters: []aws.GetAutoscalingGroupsFilter{
aws.GetAutoscalingGroupsFilter{
Name: "key",
Values: []string{
"Team",
},
},
aws.GetAutoscalingGroupsFilter{
Name: "value",
Values: []string{
"Pets",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = autoscaling.NewNotification(ctx, "slackNotifications", &autoscaling.NotificationArgs{
GroupNames: toPulumiStringArray(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
})
}
func toPulumiStringArray(arr []string) pulumi.StringArray {
var pulumiArr pulumi.StringArray
for _, v := range arr {
pulumiArr = append(pulumiArr, pulumi.String(v))
}
return pulumiArr
}import pulumi
import pulumi_aws as aws
groups = aws.get_autoscaling_groups(filters=[
{
"name": "key",
"values": ["Team"],
},
{
"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 = pulumi.output(aws.getAutoscalingGroups({
filters: [
{
name: "key",
values: ["Team"],
},
{
name: "value",
values: ["Pets"],
},
],
}, { async: true }));
const slackNotifications = new aws.autoscaling.Notification("slack_notifications", {
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",
});Using GetAutoscalingGroups
function getAutoscalingGroups(args: GetAutoscalingGroupsArgs, opts?: InvokeOptions): Promise<GetAutoscalingGroupsResult>function get_autoscaling_groups(filters=None, opts=None)func GetAutoscalingGroups(ctx *Context, args *GetAutoscalingGroupsArgs, opts ...InvokeOption) (*GetAutoscalingGroupsResult, error)public static class GetAutoscalingGroups {
public static Task<GetAutoscalingGroupsResult> InvokeAsync(GetAutoscalingGroupsArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Filters
List<Get
Autoscaling Groups Filter Args> A filter used to scope the list e.g. by tags. See related docs.
- Filters
[]Get
Autoscaling Groups Filter A filter used to scope the list e.g. by tags. See related docs.
- filters
Get
Autoscaling Groups Filter[] A filter used to scope the list e.g. by tags. See related docs.
- filters
List[Get
Autoscaling Groups Filter] A filter used to scope the list e.g. by tags. See related docs.
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<Get
Autoscaling Groups Filter>
Supporting Types
GetAutoscalingGroupsFilter
- Name string
The name of the filter. The valid values are:
auto-scaling-group,key,value, andpropagate-at-launch.- 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
awsTerraform Provider.