@infoxchange/make-it-so 2.13.0 → 2.14.0-internal-testing-add-sst-3-support.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.ts +47 -0
- package/dist/components/ix/InternalNetwork.d.ts +24 -0
- package/dist/components/ix/InternalNetwork.d.ts.map +1 -0
- package/dist/components/ix/dns.d.ts +97 -0
- package/dist/components/ix/dns.d.ts.map +1 -0
- package/dist/components/ix/index.d.ts +3 -0
- package/dist/components/ix/index.d.ts.map +1 -0
- package/dist/components/ix/index.js +375 -0
- package/dist/components/ix/index.js.map +7 -0
- package/dist/deployConfig.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/sst/component-defaults.d.ts +14 -0
- package/dist/lib/sst/component-defaults.d.ts.map +1 -0
- package/eslint.config.js +1 -0
- package/package.json +16 -16
- package/src/components/ix/InternalNetwork.ts +126 -0
- package/src/components/ix/dns.ts +280 -0
- package/src/components/ix/index.ts +2 -0
- package/src/deployConfig.ts +12 -6
- package/src/index.ts +3 -0
- package/src/lib/sst/component-defaults.ts +80 -0
- package/src/sst-globals.d.ts +1 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +8 -4
- package/vitest.config.ts +19 -0
- package/dist/cdk-constructs/IxApi.d.ts +0 -12
- package/dist/cdk-constructs/IxApi.d.ts.map +0 -1
- package/dist/cdk-constructs/IxApi.js +0 -56
- package/dist/cdk-constructs/IxBucket.d.ts +0 -9
- package/dist/cdk-constructs/IxBucket.d.ts.map +0 -1
- package/dist/cdk-constructs/IxBucket.js +0 -22
- package/dist/cdk-constructs/IxCertificate.d.ts +0 -16
- package/dist/cdk-constructs/IxCertificate.d.ts.map +0 -1
- package/dist/cdk-constructs/IxCertificate.js +0 -26
- package/dist/cdk-constructs/IxDnsRecord.d.ts +0 -23
- package/dist/cdk-constructs/IxDnsRecord.d.ts.map +0 -1
- package/dist/cdk-constructs/IxDnsRecord.js +0 -43
- package/dist/cdk-constructs/IxElasticache.d.ts +0 -17
- package/dist/cdk-constructs/IxElasticache.d.ts.map +0 -1
- package/dist/cdk-constructs/IxElasticache.js +0 -70
- package/dist/cdk-constructs/IxNextjsSite.d.ts +0 -16
- package/dist/cdk-constructs/IxNextjsSite.d.ts.map +0 -1
- package/dist/cdk-constructs/IxNextjsSite.js +0 -38
- package/dist/cdk-constructs/IxQuicksightWorkspace.d.ts +0 -17
- package/dist/cdk-constructs/IxQuicksightWorkspace.d.ts.map +0 -1
- package/dist/cdk-constructs/IxQuicksightWorkspace.js +0 -29
- package/dist/cdk-constructs/IxSESIdentity.d.ts +0 -12
- package/dist/cdk-constructs/IxSESIdentity.d.ts.map +0 -1
- package/dist/cdk-constructs/IxSESIdentity.js +0 -45
- package/dist/cdk-constructs/IxStaticSite.d.ts +0 -17
- package/dist/cdk-constructs/IxStaticSite.d.ts.map +0 -1
- package/dist/cdk-constructs/IxStaticSite.js +0 -38
- package/dist/cdk-constructs/IxVpcDetails.d.ts +0 -12
- package/dist/cdk-constructs/IxVpcDetails.d.ts.map +0 -1
- package/dist/cdk-constructs/IxVpcDetails.js +0 -26
- package/dist/cdk-constructs/IxWebsiteRedirect.d.ts +0 -35
- package/dist/cdk-constructs/IxWebsiteRedirect.d.ts.map +0 -1
- package/dist/cdk-constructs/IxWebsiteRedirect.js +0 -72
- package/dist/cdk-constructs/SiteOidcAuth/auth-check-handler-body.d.ts +0 -2
- package/dist/cdk-constructs/SiteOidcAuth/auth-check-handler-body.d.ts.map +0 -1
- package/dist/cdk-constructs/SiteOidcAuth/auth-check-handler-body.js +0 -130
- package/dist/cdk-constructs/SiteOidcAuth/auth-route.d.ts +0 -2
- package/dist/cdk-constructs/SiteOidcAuth/auth-route.d.ts.map +0 -1
- package/dist/cdk-constructs/SiteOidcAuth/auth-route.js +0 -59
- package/dist/cdk-constructs/SiteOidcAuth/index.d.ts +0 -197
- package/dist/cdk-constructs/SiteOidcAuth/index.d.ts.map +0 -1
- package/dist/cdk-constructs/SiteOidcAuth/index.js +0 -188
- package/dist/cdk-constructs/index.d.ts +0 -11
- package/dist/cdk-constructs/index.d.ts.map +0 -1
- package/dist/cdk-constructs/index.js +0 -10
- package/dist/deployConfig.js +0 -78
- package/dist/lib/auth/index.d.ts +0 -2
- package/dist/lib/auth/index.d.ts.map +0 -1
- package/dist/lib/auth/index.js +0 -1
- package/dist/lib/auth/oidc.d.ts +0 -26
- package/dist/lib/auth/oidc.d.ts.map +0 -1
- package/dist/lib/auth/oidc.js +0 -48
- package/dist/lib/proxy/fetch.js +0 -31
- package/dist/lib/proxy/index.js +0 -1
- package/dist/lib/site/support.d.ts +0 -71
- package/dist/lib/site/support.d.ts.map +0 -1
- package/dist/lib/site/support.js +0 -262
- package/dist/lib/utils/hash.d.ts +0 -2
- package/dist/lib/utils/hash.d.ts.map +0 -1
- package/dist/lib/utils/hash.js +0 -13
- package/dist/lib/utils/objects.d.ts +0 -4
- package/dist/lib/utils/objects.d.ts.map +0 -1
- package/dist/lib/utils/objects.js +0 -7
- package/src/cdk-constructs/IxApi.ts +0 -81
- package/src/cdk-constructs/IxBucket.ts +0 -35
- package/src/cdk-constructs/IxCertificate.ts +0 -54
- package/src/cdk-constructs/IxDnsRecord.ts +0 -79
- package/src/cdk-constructs/IxElasticache.ts +0 -106
- package/src/cdk-constructs/IxNextjsSite.ts +0 -72
- package/src/cdk-constructs/IxQuicksightWorkspace.ts +0 -54
- package/src/cdk-constructs/IxSESIdentity.ts +0 -70
- package/src/cdk-constructs/IxStaticSite.ts +0 -69
- package/src/cdk-constructs/IxVpcDetails.ts +0 -38
- package/src/cdk-constructs/IxWebsiteRedirect.ts +0 -133
- package/src/cdk-constructs/SiteOidcAuth/auth-check-handler-body.ts +0 -168
- package/src/cdk-constructs/SiteOidcAuth/auth-route.ts +0 -71
- package/src/cdk-constructs/SiteOidcAuth/index.ts +0 -299
- package/src/cdk-constructs/index.ts +0 -10
- package/src/lib/auth/index.ts +0 -1
- package/src/lib/auth/oidc.ts +0 -73
- package/src/lib/site/support.ts +0 -439
- package/src/lib/utils/hash.ts +0 -14
- package/src/lib/utils/objects.ts +0 -19
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Based on https://github.com/anomalyco/sst/blob/3407c32b2cf97b85ea96a92361c6f4a0a8d55200/platform/src/components/aws/dns.ts
|
|
2
|
+
/**
|
|
3
|
+
* The AWS DNS Adapter is used to create DNS records to manage domains hosted on
|
|
4
|
+
* [Route 53](https://aws.amazon.com/route53/).
|
|
5
|
+
*
|
|
6
|
+
* This adapter is passed in as `domain.dns` when setting a custom domain.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* {
|
|
12
|
+
* domain: {
|
|
13
|
+
* name: "example.com",
|
|
14
|
+
* dns: sst.aws.dns()
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* You can also specify a hosted zone ID if you have multiple hosted zones with the same domain.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* {
|
|
23
|
+
* domain: {
|
|
24
|
+
* name: "example.com",
|
|
25
|
+
* dns: sst.aws.dns({
|
|
26
|
+
* zone: "Z2FDTNDATAQYW2"
|
|
27
|
+
* })
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @packageDocumentation
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
AliasRecord,
|
|
37
|
+
Dns,
|
|
38
|
+
Record as DnsRecord,
|
|
39
|
+
} from "sst3/platform/src/components/dns";
|
|
40
|
+
import { logicalName } from "sst3/platform/src/components/naming";
|
|
41
|
+
import { ComponentResourceOptions, output } from "@pulumi/pulumi";
|
|
42
|
+
import { Transform, transform } from "sst3/platform/src/components/component";
|
|
43
|
+
import { Input } from "sst3/platform/src/components/input";
|
|
44
|
+
import { useProvider } from "sst3/platform/src/components/aws/helpers/provider";
|
|
45
|
+
import { route53 } from "@pulumi/aws";
|
|
46
|
+
import { VisibleError } from "sst3/platform/src/components/error";
|
|
47
|
+
import * as aws from "@pulumi/aws";
|
|
48
|
+
|
|
49
|
+
export interface DnsArgs {
|
|
50
|
+
/**
|
|
51
|
+
* Set the hosted zone ID if you have multiple hosted zones that have the same
|
|
52
|
+
* domain in Route 53.
|
|
53
|
+
*
|
|
54
|
+
* The 14 letter ID of the [Route 53 hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html) that contains the `domainName`. You can find the hosted zone ID in the Route 53 part of the AWS Console.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```js
|
|
58
|
+
* {
|
|
59
|
+
* zone: "Z2FDTNDATAQYW2"
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
zone?: Input<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Set to `true` if you want to let the new DNS records replace the existing ones.
|
|
66
|
+
*
|
|
67
|
+
* :::tip
|
|
68
|
+
* Use this to migrate over your domain without any downtime.
|
|
69
|
+
* :::
|
|
70
|
+
*
|
|
71
|
+
* This is useful if your domain is currently used by another app and you want to switch it
|
|
72
|
+
* to your current app. Without setting this, you'll first have to remove the existing DNS
|
|
73
|
+
* records and then add the new one. This can cause downtime.
|
|
74
|
+
*
|
|
75
|
+
* You can avoid this by setting this to `true` and the existing DNS records will be replaced
|
|
76
|
+
* without any downtime. Just make sure that when you remove your old app, you don't remove
|
|
77
|
+
* the DNS records.
|
|
78
|
+
*
|
|
79
|
+
* @default `false`
|
|
80
|
+
* @example
|
|
81
|
+
* ```js
|
|
82
|
+
* {
|
|
83
|
+
* override: true
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
override?: Input<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* [Transform](/docs/components#transform) how this component creates its underlying
|
|
90
|
+
* resources.
|
|
91
|
+
*/
|
|
92
|
+
transform?: {
|
|
93
|
+
/**
|
|
94
|
+
* Transform the AWS Route 53 record resource.
|
|
95
|
+
*/
|
|
96
|
+
record?: Transform<
|
|
97
|
+
route53.RecordArgs & {
|
|
98
|
+
aliasIpType?: "IPv4" | "IPv6";
|
|
99
|
+
// Can be used to override the raw input to the IX DNS lambda
|
|
100
|
+
lambdaInput?: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
>;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function dns(args: DnsArgs = {}) {
|
|
107
|
+
return {
|
|
108
|
+
provider: "aws",
|
|
109
|
+
createAlias,
|
|
110
|
+
createCaa,
|
|
111
|
+
createRecord,
|
|
112
|
+
} satisfies Dns;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Creates alias records in the hosted zone.
|
|
116
|
+
*
|
|
117
|
+
* @param namePrefix The prefix to use for the resource names.
|
|
118
|
+
* @param record The alias record to create.
|
|
119
|
+
* @param opts The component resource options.
|
|
120
|
+
*/
|
|
121
|
+
function createAlias(
|
|
122
|
+
namePrefix: string,
|
|
123
|
+
record: AliasRecord,
|
|
124
|
+
opts: ComponentResourceOptions,
|
|
125
|
+
) {
|
|
126
|
+
return ["A", "AAAA"].map((type) =>
|
|
127
|
+
_createRecord(
|
|
128
|
+
namePrefix,
|
|
129
|
+
{
|
|
130
|
+
type,
|
|
131
|
+
name: record.name,
|
|
132
|
+
aliases: [
|
|
133
|
+
{
|
|
134
|
+
name: record.aliasName,
|
|
135
|
+
zoneId: record.aliasZone,
|
|
136
|
+
evaluateTargetHealth: true,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
opts,
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function createCaa(
|
|
146
|
+
/* eslint-disable @typescript-eslint/no-unused-vars -- Kept for typing even though it's not used for this
|
|
147
|
+
implementation of Dns */
|
|
148
|
+
namePrefix: string,
|
|
149
|
+
recordName: string,
|
|
150
|
+
opts: ComponentResourceOptions,
|
|
151
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
152
|
+
) {
|
|
153
|
+
// placeholder
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Creates a DNS record in the hosted zone.
|
|
159
|
+
*
|
|
160
|
+
* @param namePrefix The prefix to use for the resource names.
|
|
161
|
+
* @param record The DNS record to create.
|
|
162
|
+
* @param opts The component resource options.
|
|
163
|
+
*/
|
|
164
|
+
function createRecord(
|
|
165
|
+
namePrefix: string,
|
|
166
|
+
record: DnsRecord,
|
|
167
|
+
opts: ComponentResourceOptions,
|
|
168
|
+
) {
|
|
169
|
+
return _createRecord(
|
|
170
|
+
namePrefix,
|
|
171
|
+
{
|
|
172
|
+
type: record.type,
|
|
173
|
+
name: record.name,
|
|
174
|
+
ttl: 60,
|
|
175
|
+
records: [record.value],
|
|
176
|
+
},
|
|
177
|
+
opts,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function _createRecord(
|
|
182
|
+
namePrefix: string,
|
|
183
|
+
partial: Omit<route53.RecordArgs, "zoneId">,
|
|
184
|
+
opts: ComponentResourceOptions,
|
|
185
|
+
) {
|
|
186
|
+
return output(partial).apply((partial) => {
|
|
187
|
+
const nameSuffix = logicalName(partial.name);
|
|
188
|
+
const zoneId = ""; // The IX dns lambda will determine the zone ID based on the domain name
|
|
189
|
+
const dnsRecord = createRecord();
|
|
190
|
+
return dnsRecord;
|
|
191
|
+
|
|
192
|
+
function createRecord() {
|
|
193
|
+
const [name, mergedArgs, mergedOpts] = transform(
|
|
194
|
+
args.transform?.record,
|
|
195
|
+
`${namePrefix}${partial.type}Record${nameSuffix}`,
|
|
196
|
+
{
|
|
197
|
+
zoneId,
|
|
198
|
+
allowOverwrite: args.override,
|
|
199
|
+
...partial,
|
|
200
|
+
},
|
|
201
|
+
opts,
|
|
202
|
+
);
|
|
203
|
+
const lambdaInput = output(mergedArgs).apply((mergedArgs) => {
|
|
204
|
+
const { aliases } = mergedArgs;
|
|
205
|
+
let { aliasIpType } = mergedArgs;
|
|
206
|
+
if (aliases && aliases.length > 1) {
|
|
207
|
+
throw new VisibleError(
|
|
208
|
+
"Aliases with multiple targets are not supported",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const [alias] = aliases || [];
|
|
212
|
+
if (alias) {
|
|
213
|
+
if (mergedArgs.type === "A") {
|
|
214
|
+
aliasIpType = "IPv4";
|
|
215
|
+
} else if (mergedArgs.type === "AAAA") {
|
|
216
|
+
aliasIpType = "IPv6";
|
|
217
|
+
} else {
|
|
218
|
+
throw new VisibleError(
|
|
219
|
+
"Alias records can only be created for A or AAAA record types",
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
RecordType: mergedArgs.type,
|
|
225
|
+
// Even though a trailing dot is valid a bug in the IX dns lambda means that an error occurs
|
|
226
|
+
// when trying to find the hosted zone if there is a trailing dot.
|
|
227
|
+
RecordFQDN: mergedArgs.name.replace(/\.$/, ""),
|
|
228
|
+
// If giving the IX dns lambda multiple values we need to wrap in 'Value' objects
|
|
229
|
+
// unlike for single values where the lambda does it for us
|
|
230
|
+
// https://github.com/InfoxchangeTS/aws-gov/blob/213609c2e91b021375b93290efdaf38936ee98e1/components/xaccount-route53/dns-record-updater-lambda/src/index.py#L133
|
|
231
|
+
RecordValue: mergedArgs.records?.map((value) => ({ Value: value })),
|
|
232
|
+
...(mergedArgs.zoneId ? { HostedZoneId: mergedArgs.zoneId } : {}),
|
|
233
|
+
...(mergedArgs.ttl ? { RecordTTL: mergedArgs.ttl } : {}),
|
|
234
|
+
...(alias
|
|
235
|
+
? {
|
|
236
|
+
RecordType: "ALIAS",
|
|
237
|
+
// https://github.com/InfoxchangeTS/aws-gov/blob/213609c2e91b021375b93290efdaf38936ee98e1/components/xaccount-route53/dns-record-updater-lambda/src/index.py#L145
|
|
238
|
+
RecordValue: alias.name,
|
|
239
|
+
// https://github.com/InfoxchangeTS/aws-gov/blob/213609c2e91b021375b93290efdaf38936ee98e1/components/xaccount-route53/dns-record-updater-lambda/src/index.py#L144
|
|
240
|
+
AliasZoneId: alias.zoneId,
|
|
241
|
+
// alias.evaluateTargetHealth can't be set by the lambda
|
|
242
|
+
IpAddressType: aliasIpType?.toLowerCase(),
|
|
243
|
+
}
|
|
244
|
+
: {}),
|
|
245
|
+
...mergedArgs.lambdaInput,
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
// output([mergedArgs, lambdaInput]).apply(([mergedArgs, lambdaInput]) => console.log('________ BEFORE', mergedArgs, '___________ AFTER', lambdaInput));
|
|
249
|
+
return new aws.lambda.Invocation(
|
|
250
|
+
name,
|
|
251
|
+
{
|
|
252
|
+
input: output(lambdaInput).apply((lambdaInput) =>
|
|
253
|
+
JSON.stringify({
|
|
254
|
+
RequestType: "Create",
|
|
255
|
+
ResourceProperties: lambdaInput,
|
|
256
|
+
// We need some value so that the lambda doesn't throw an error but we don't want the lambda to actually
|
|
257
|
+
// send a response to this url (the response is for CloudFormation which we're not using). Setting an
|
|
258
|
+
// invalid domain will cause it to log an error but not throw so the lambda is considered successful.
|
|
259
|
+
ResponseURL: "invalid://make-it-so-dns",
|
|
260
|
+
StackId: "",
|
|
261
|
+
RequestId: "",
|
|
262
|
+
LogicalResourceId: "",
|
|
263
|
+
}),
|
|
264
|
+
),
|
|
265
|
+
functionName: aws.ssm
|
|
266
|
+
.getParameter({
|
|
267
|
+
name: "/shared-services/route53/lambdaArn",
|
|
268
|
+
})
|
|
269
|
+
.then((param) => param.value),
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
...mergedOpts,
|
|
273
|
+
// Function can only be invoked from within the same region it is deployed
|
|
274
|
+
provider: useProvider("ap-southeast-2"),
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
package/src/deployConfig.ts
CHANGED
|
@@ -27,12 +27,18 @@ const ixDeployConfigSchema = z
|
|
|
27
27
|
environment: z.enum(["dev", "test", "uat", "prod"]),
|
|
28
28
|
workloadGroup: z.enum(["ds", "srs"]),
|
|
29
29
|
primaryAwsRegion: z.literal("ap-southeast-2"),
|
|
30
|
-
siteDomains: z
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
siteDomains: z.string().transform((val) =>
|
|
31
|
+
val
|
|
32
|
+
.split(",")
|
|
33
|
+
.map((domain) => domain.trim())
|
|
34
|
+
.filter(Boolean),
|
|
35
|
+
),
|
|
36
|
+
siteDomainAliases: z.string().transform((val) =>
|
|
37
|
+
val
|
|
38
|
+
.split(",")
|
|
39
|
+
.map((domain) => domain.trim())
|
|
40
|
+
.filter(Boolean),
|
|
41
|
+
),
|
|
36
42
|
isInternalApp: z.coerce.boolean(),
|
|
37
43
|
deploymentType: z.enum(["docker", "serverless"]),
|
|
38
44
|
sourceCommitRef: z.string().min(1),
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { $transform as sst3$transform } from "sst3/platform/src/components/component";
|
|
2
|
+
import type * as aws from "sst3/platform/src/components/aws";
|
|
3
|
+
import type * as cloudflare from "sst3/platform/src/components/cloudflare";
|
|
4
|
+
import { dns } from "@/components/ix/dns";
|
|
5
|
+
import { output } from "@pulumi/pulumi";
|
|
6
|
+
import { getDeployConfig } from "@/deployConfig";
|
|
7
|
+
|
|
8
|
+
export default function setupComponentDefaults({
|
|
9
|
+
$transform,
|
|
10
|
+
sst: partiallyTypedSst,
|
|
11
|
+
}: {
|
|
12
|
+
$transform: typeof sst3$transform;
|
|
13
|
+
sst: {
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-explicit-any -- SST works by creating types dynamically in the
|
|
15
|
+
project where it's used. Therefore we can't import them in this library. For the sake of ensuring the
|
|
16
|
+
correctness of this code we cast to equivalent classes from the "sst3" module we download directly from
|
|
17
|
+
GitHub since we can't guarantee the whole type will exactly match.
|
|
18
|
+
*/
|
|
19
|
+
aws: {
|
|
20
|
+
StaticSite: any;
|
|
21
|
+
Nextjs: any;
|
|
22
|
+
};
|
|
23
|
+
cloudflare: {
|
|
24
|
+
StaticSite: any;
|
|
25
|
+
};
|
|
26
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
27
|
+
};
|
|
28
|
+
}) {
|
|
29
|
+
const sst: {
|
|
30
|
+
aws: {
|
|
31
|
+
StaticSite: typeof aws.StaticSite;
|
|
32
|
+
Nextjs: typeof aws.Nextjs;
|
|
33
|
+
};
|
|
34
|
+
cloudflare: {
|
|
35
|
+
StaticSite: typeof cloudflare.StaticSite;
|
|
36
|
+
};
|
|
37
|
+
} = partiallyTypedSst;
|
|
38
|
+
|
|
39
|
+
$transform(sst.aws.StaticSite, (args, opts, name) => {
|
|
40
|
+
addDefaultDomain(args, name);
|
|
41
|
+
});
|
|
42
|
+
$transform(sst.aws.Nextjs, (args, opts, name) => {
|
|
43
|
+
addDefaultDomain(args, name);
|
|
44
|
+
});
|
|
45
|
+
$transform(sst.cloudflare.StaticSite, (args, opts, name) => {
|
|
46
|
+
addDefaultDomain(args, name);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function addDefaultDomain(
|
|
51
|
+
args:
|
|
52
|
+
| aws.StaticSiteArgs
|
|
53
|
+
| aws.NextjsArgs
|
|
54
|
+
| cloudflare.StaticSiteArgs
|
|
55
|
+
| undefined,
|
|
56
|
+
name: string,
|
|
57
|
+
) {
|
|
58
|
+
if (!args) {
|
|
59
|
+
throw new Error(`No args provided to ${name}`);
|
|
60
|
+
}
|
|
61
|
+
const domainArgs = {
|
|
62
|
+
name: getDeployConfig().siteDomains[0],
|
|
63
|
+
dns: dns(),
|
|
64
|
+
};
|
|
65
|
+
if (!("domain" in args)) {
|
|
66
|
+
args.domain = domainArgs;
|
|
67
|
+
} else if (args.domain) {
|
|
68
|
+
args.domain = output(args.domain).apply((domain) => {
|
|
69
|
+
if (typeof domain === "string") {
|
|
70
|
+
return {
|
|
71
|
+
name: domain,
|
|
72
|
+
dns: domainArgs.dns,
|
|
73
|
+
};
|
|
74
|
+
} else if (!("dns" in domain)) {
|
|
75
|
+
domain.dns = domainArgs.dns;
|
|
76
|
+
}
|
|
77
|
+
return domain;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "sst3/platform/src/global.d.ts";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"declarationMap": true,
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"noEmit": false
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*.ts"]
|
|
13
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"moduleResolution": "bundler",
|
|
4
|
+
"module": "es2022",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["src/*"]
|
|
8
|
+
},
|
|
9
|
+
"noEmit": true
|
|
6
10
|
},
|
|
7
|
-
"include": ["src/**/*.ts"],
|
|
11
|
+
"include": ["src/**/*.ts", "tests/**/*.ts"],
|
|
8
12
|
"extends": "@tsconfig/node21/tsconfig.json"
|
|
9
13
|
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: "node",
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: "v8",
|
|
10
|
+
reporter: ["text", "json", "html"],
|
|
11
|
+
exclude: ["**/*.config.*", "**/dist/**", "**/tests/**", "**/build.*"],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
resolve: {
|
|
15
|
+
alias: {
|
|
16
|
+
"@": resolve(__dirname, "./src"),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Api } from "sst/constructs";
|
|
2
|
-
type ConstructScope = ConstructorParameters<typeof Api>[0];
|
|
3
|
-
type ConstructId = ConstructorParameters<typeof Api>[1];
|
|
4
|
-
type ConstructProps = Exclude<ConstructorParameters<typeof Api>[2], undefined>;
|
|
5
|
-
export declare class IxApi extends Api {
|
|
6
|
-
constructor(scope: ConstructScope, id: ConstructId, props?: ConstructProps);
|
|
7
|
-
private static setupCustomDomain;
|
|
8
|
-
private static setupCertificate;
|
|
9
|
-
private createDnsRecords;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=IxApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IxApi.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAMrC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,KAAK,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAE/E,qBAAa,KAAM,SAAQ,GAAG;gBAE1B,KAAK,EAAE,cAAc,EACrB,EAAE,EAAE,WAAW,EACf,KAAK,GAAE,cAAmB;IAc5B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgBhC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAuB/B,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Api } from "sst/constructs";
|
|
2
|
-
import { IxCertificate } from "./IxCertificate.js";
|
|
3
|
-
import { IxDnsRecord } from "./IxDnsRecord.js";
|
|
4
|
-
import ixDeployConfig from "../deployConfig.js";
|
|
5
|
-
import { convertToBase62Hash } from "../lib/utils/hash.js";
|
|
6
|
-
export class IxApi extends Api {
|
|
7
|
-
constructor(scope, id, props = {}) {
|
|
8
|
-
if (ixDeployConfig.isIxDeploy) {
|
|
9
|
-
IxApi.setupCustomDomain(scope, id, props);
|
|
10
|
-
}
|
|
11
|
-
super(scope, id, props);
|
|
12
|
-
if (ixDeployConfig.isIxDeploy) {
|
|
13
|
-
this.createDnsRecords(scope);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// This must be static because we need to call it in the constructor before super
|
|
17
|
-
static setupCustomDomain(scope, id, props) {
|
|
18
|
-
// Default to using domains names passed in by the pipeline as the custom domain
|
|
19
|
-
if (ixDeployConfig.isIxDeploy && !("customDomain" in props)) {
|
|
20
|
-
props.customDomain = {
|
|
21
|
-
domainName: ixDeployConfig.siteDomains[0],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
this.setupCertificate(scope, id, props);
|
|
25
|
-
}
|
|
26
|
-
// This must be static because we need to call it in the constructor before super
|
|
27
|
-
static setupCertificate(scope, id, props) {
|
|
28
|
-
if (!props?.customDomain)
|
|
29
|
-
return;
|
|
30
|
-
if (typeof props.customDomain === "string") {
|
|
31
|
-
props.customDomain = { domainName: props.customDomain };
|
|
32
|
-
}
|
|
33
|
-
const domainName = props.customDomain.domainName;
|
|
34
|
-
if (domainName) {
|
|
35
|
-
const domainCert = new IxCertificate(scope, id + "-IxCertificate", {
|
|
36
|
-
domainName,
|
|
37
|
-
region: "ap-southeast-2", // API Gateway wants southeast-2.
|
|
38
|
-
});
|
|
39
|
-
props.customDomain.isExternalDomain = true;
|
|
40
|
-
props.customDomain.cdk = props.customDomain.cdk ?? {};
|
|
41
|
-
props.customDomain.cdk.certificate = domainCert.acmCertificate;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
createDnsRecords(scope) {
|
|
45
|
-
if (this.cdk.domainName?.name && this.cdk.domainName?.regionalDomainName) {
|
|
46
|
-
const domainNameLogicalId = convertToBase62Hash(this.cdk.domainName.name);
|
|
47
|
-
// API Gateway has a separate domain for using with a CNAME (regionalDomainName)
|
|
48
|
-
new IxDnsRecord(scope, `DnsRecord-${domainNameLogicalId}`, {
|
|
49
|
-
type: "CNAME",
|
|
50
|
-
name: this.cdk.domainName.name,
|
|
51
|
-
value: this.cdk.domainName?.regionalDomainName,
|
|
52
|
-
ttl: 900,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Bucket } from "sst/constructs";
|
|
2
|
-
type ConstructScope = ConstructorParameters<typeof Bucket>[0];
|
|
3
|
-
type ConstructId = ConstructorParameters<typeof Bucket>[1];
|
|
4
|
-
type ConstructProps = Exclude<ConstructorParameters<typeof Bucket>[2], undefined>;
|
|
5
|
-
export declare class IxBucket extends Bucket {
|
|
6
|
-
constructor(scope: ConstructScope, id: ConstructId, props?: ConstructProps);
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=IxBucket.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IxBucket.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxBucket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,KAAK,cAAc,GAAG,OAAO,CAC3B,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EACvC,SAAS,CACV,CAAC;AAEF,qBAAa,QAAS,SAAQ,MAAM;gBAEhC,KAAK,EAAE,cAAc,EACrB,EAAE,EAAE,WAAW,EACf,KAAK,GAAE,cAAmB;CAmB7B"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Bucket } from "sst/constructs";
|
|
2
|
-
import { BucketEncryption } from "aws-cdk-lib/aws-s3";
|
|
3
|
-
import ixDeployConfig from "../deployConfig.js";
|
|
4
|
-
export class IxBucket extends Bucket {
|
|
5
|
-
constructor(scope, id, props = {}) {
|
|
6
|
-
const bucketProps = {
|
|
7
|
-
blockPublicACLs: true,
|
|
8
|
-
...props,
|
|
9
|
-
cdk: {
|
|
10
|
-
...props.cdk,
|
|
11
|
-
bucket: {
|
|
12
|
-
enforceSSL: true,
|
|
13
|
-
...(ixDeployConfig.isIxDeploy
|
|
14
|
-
? { encryption: BucketEncryption.S3_MANAGED }
|
|
15
|
-
: {}),
|
|
16
|
-
...props.cdk?.bucket,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
super(scope, id, bucketProps);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
3
|
-
type ConstructScope = ConstructorParameters<typeof Construct>[0];
|
|
4
|
-
type ConstructId = ConstructorParameters<typeof Construct>[1];
|
|
5
|
-
type Props = {
|
|
6
|
-
domainName: string;
|
|
7
|
-
subjectAlternativeNames?: string[];
|
|
8
|
-
region?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class IxCertificate extends Construct {
|
|
11
|
-
acmCertificate: ICertificate;
|
|
12
|
-
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
13
|
-
private createCertificate;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=IxCertificate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IxCertificate.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxCertificate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAe,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAG/E,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,aAAc,SAAQ,SAAS;IACnC,cAAc,EAAE,YAAY,CAAC;gBAExB,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAKhE,OAAO,CAAC,iBAAiB;CA+B1B"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
3
|
-
import { Certificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
4
|
-
import { CustomResource } from "aws-cdk-lib";
|
|
5
|
-
export class IxCertificate extends Construct {
|
|
6
|
-
acmCertificate;
|
|
7
|
-
constructor(scope, id, props) {
|
|
8
|
-
super(scope, id);
|
|
9
|
-
this.acmCertificate = this.createCertificate(scope, id, props);
|
|
10
|
-
}
|
|
11
|
-
createCertificate(scope, id, props) {
|
|
12
|
-
const certificateCreationLambdaArn = StringParameter.valueForStringParameter(scope, "/shared-services/acm/lambdaArn-v2");
|
|
13
|
-
const certificateCustomResource = new CustomResource(scope, "DomainCert-" + id, {
|
|
14
|
-
resourceType: "Custom::CertIssuingLambda",
|
|
15
|
-
serviceToken: certificateCreationLambdaArn,
|
|
16
|
-
properties: {
|
|
17
|
-
DomainName: props.domainName,
|
|
18
|
-
...(props.subjectAlternativeNames && {
|
|
19
|
-
SubjectAlternativeNames: props.subjectAlternativeNames,
|
|
20
|
-
}),
|
|
21
|
-
...(props.region && { CertificateIssuingRegion: props.region }),
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return Certificate.fromCertificateArn(scope, id + "-AwsCertificate", certificateCustomResource.ref);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
type ConstructScope = ConstructorParameters<typeof Construct>[0];
|
|
3
|
-
type ConstructId = ConstructorParameters<typeof Construct>[1];
|
|
4
|
-
type Props = {
|
|
5
|
-
name: string;
|
|
6
|
-
value: string;
|
|
7
|
-
ttl?: number;
|
|
8
|
-
hostedZoneId?: string;
|
|
9
|
-
} & ({
|
|
10
|
-
type: "A" | "CNAME" | "NS" | "SOA" | "TXT";
|
|
11
|
-
} | {
|
|
12
|
-
type: "ALIAS";
|
|
13
|
-
aliasZoneId: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: "MX";
|
|
16
|
-
priority: number;
|
|
17
|
-
});
|
|
18
|
-
export declare class IxDnsRecord extends Construct {
|
|
19
|
-
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
20
|
-
private createDnsRecord;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=IxDnsRecord.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IxDnsRecord.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxDnsRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,CACA;IACE,IAAI,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;CAC5C,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB,CACJ,CAAC;AAEF,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAKhE,OAAO,CAAC,eAAe;CA6CxB"}
|