-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsst.config.ts
59 lines (58 loc) · 1.63 KB
/
sst.config.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// <reference path="./.sst/platform/config.d.ts" />
import * as aws from "@pulumi/aws";
export default $config({
app(input) {
return {
name: "lambda-ddclient-handler",
removal: input?.stage === "production" ? "retain" : "remove",
home: "aws",
};
},
async run() {
// create pulumi role
const policy = new aws.iam.Policy("DDClientManagedPolicy", {
description: "Managed policy that allows access to the hosted zone",
name: `${$app.name}-${$app.stage}-ddclient-policy`,
policy: {
Version: "2012-10-17",
Statement: [
{
Action: ["route53:ChangeResourceRecordSets"],
Effect: "Allow",
Resource: `arn:aws:route53:::hostedzone/${process.env.TARGET_HOSTED_ZONE_ID}`,
},
{
Action: [
"route53:ListHostedZonesByName",
"route53:ListResourceRecordSets",
],
Effect: "Allow",
Resource: "*",
},
],
},
});
new sst.aws.ApiGatewayV2("LambdaDDclientHandlerApi").route("$default", {
handler: "index.update",
transform: {
role: {
name: `${$app.name}-${$app.stage}-ddclient-role`,
managedPolicyArns: [policy.arn],
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Action: "sts:AssumeRole",
Effect: "Allow",
Sid: "main",
Principal: {
Service: "lambda.amazonaws.com",
},
},
],
},
},
},
});
},
});