-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathgroup.ts
More file actions
50 lines (47 loc) · 1.22 KB
/
group.ts
File metadata and controls
50 lines (47 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { ComponentResourceOptions, all } from "@pulumi/pulumi";
import { Component } from "../component";
/**
* The `Group` component lets you define a named set of components that can be
* targeted together using `sst deploy --target` or excluded with `--exclude`.
*
* @example
*
* ```ts
* const bucket = new sst.aws.Bucket("MyBucket");
* const fn = new sst.aws.Function("MyFn", { handler: "src/handler.ts" });
*
* const api = new sst.x.Group("Api");
* api.add(bucket, fn);
* ```
*
* Now you can deploy just the `Api` group:
* ```bash
* sst deploy --target Api
* ```
*/
export class Group extends Component {
private members: Component[] = [];
constructor(name: string, opts?: ComponentResourceOptions) {
super("sst:sst:Group", name, {}, opts);
}
/**
* Add components to this group.
*
* @example
* ```ts
* const bucket = new sst.aws.Bucket("MyBucket");
* const fn = new sst.aws.Function("MyFn", { handler: "src/handler.ts" });
*
* const api = new sst.x.Group("Api");
* api.add(bucket, fn);
* ```
*/
add(...members: Component[]) {
this.members.push(...members);
this.registerOutputs({
_group: {
members: all(this.members.map((m) => m.urn)),
},
});
}
}