-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathanghammarad.ts
32 lines (27 loc) · 1.13 KB
/
anghammarad.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
import { isSingletonPresentInStack } from "../../../utils/singleton";
import type { GuStack } from "../../core";
import { GuAnghammaradTopicParameter } from "../../core";
import { GuAllowPolicy } from "./base-policy";
/**
* Creates an `AWS::IAM::Policy` to grant `sns:Publish` permission to the Anghammarad topic.
* An `AnghammaradSnsArn` parameter will be automatically added to the stack when needed.
*
* @see GuAnghammaradTopicParameter
* @see https://github.com/guardian/anghammarad
*/
export class GuAnghammaradSenderPolicy extends GuAllowPolicy {
private static instance: GuAnghammaradSenderPolicy | undefined;
private constructor(scope: GuStack) {
const anghammaradTopicParameter = GuAnghammaradTopicParameter.getInstance(scope);
super(scope, "GuAnghammaradSenderPolicy", {
actions: ["sns:Publish"],
resources: [anghammaradTopicParameter.valueAsString],
});
}
public static getInstance(stack: GuStack): GuAnghammaradSenderPolicy {
if (!this.instance || !isSingletonPresentInStack(stack, this.instance)) {
this.instance = new GuAnghammaradSenderPolicy(stack);
}
return this.instance;
}
}