Skip to content

Group

Source: src/AWS/ResourceGroups/Group.ts

An AWS Resource Groups group — a collection of AWS resources defined by a tag-based query, a CloudFormation stack query, or an attached service configuration.

Deleting a group never deletes its member resources; it only deletes the group structure.

Tag-based Group

import * as ResourceGroups from "alchemy/AWS/ResourceGroups";
const group = yield* ResourceGroups.Group("EnvGroup", {
description: "All resources tagged env=prod",
resourceQuery: {
type: "TAG_FILTERS_1_0",
query: JSON.stringify({
ResourceTypeFilters: ["AWS::AllSupported"],
TagFilters: [{ Key: "env", Values: ["prod"] }],
}),
},
});

CloudFormation Stack Group

const group = yield* ResourceGroups.Group("StackGroup", {
resourceQuery: {
type: "CLOUDFORMATION_STACK_1_0",
query: JSON.stringify({
ResourceTypeFilters: ["AWS::AllSupported"],
StackIdentifier: stackArn,
}),
},
});
const pool = yield* ResourceGroups.Group("ReservationPool", {
configuration: [
{
type: "AWS::ResourceGroups::Generic",
parameters: [
{
name: "allowed-resource-types",
values: ["AWS::EC2::CapacityReservation"],
},
],
},
{ type: "AWS::EC2::CapacityReservationPool" },
],
});
const group = yield* ResourceGroups.Group("TaggedGroup", {
resourceQuery: {
type: "TAG_FILTERS_1_0",
query: JSON.stringify({
ResourceTypeFilters: ["AWS::AllSupported"],
TagFilters: [{ Key: "team", Values: ["platform"] }],
}),
},
tags: { team: "platform" },
});