-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdescribe-ec2.ts
34 lines (30 loc) · 1.01 KB
/
describe-ec2.ts
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
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
import { isSingletonPresentInStack } from "../../../utils/singleton";
import type { GuStack } from "../../core";
import { GuPolicy } from "./base-policy";
export class GuDescribeEC2Policy extends GuPolicy {
private static instance: GuPolicy | undefined;
private constructor(scope: GuStack) {
super(scope, "DescribeEC2Policy", {
policyName: "describe-ec2-policy",
statements: [
new PolicyStatement({
effect: Effect.ALLOW,
actions: [
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeAutoScalingGroups",
"ec2:DescribeTags",
"ec2:DescribeInstances",
],
resources: ["*"],
}),
],
});
}
public static getInstance(stack: GuStack): GuDescribeEC2Policy {
if (!this.instance || !isSingletonPresentInStack(stack, this.instance)) {
this.instance = new GuDescribeEC2Policy(stack);
}
return this.instance;
}
}