@infoxchange/make-it-so 2.12.0-internal-testing-add-ix-ses-idenity.5 → 2.12.0-internal-testing-add-setup-proxy-globally.1
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/README.md +0 -23
- package/dist/cdk-constructs/IxDnsRecord.d.ts +1 -4
- package/dist/cdk-constructs/IxDnsRecord.d.ts.map +1 -1
- package/dist/cdk-constructs/IxDnsRecord.js +2 -19
- package/dist/cdk-constructs/index.d.ts +0 -1
- package/dist/cdk-constructs/index.d.ts.map +1 -1
- package/dist/cdk-constructs/index.js +0 -1
- package/dist/lib/proxy/fetch.d.ts +4 -0
- package/dist/lib/proxy/fetch.d.ts.map +1 -0
- package/dist/lib/proxy/fetch.js +29 -0
- package/dist/lib/proxy/index.d.ts +2 -0
- package/dist/lib/proxy/index.d.ts.map +1 -0
- package/dist/lib/proxy/index.js +1 -0
- package/dist/lib/utils/objects.d.ts +1 -1
- package/dist/lib/utils/objects.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/cdk-constructs/IxDnsRecord.ts +4 -28
- package/src/cdk-constructs/index.ts +0 -1
- package/src/lib/proxy/fetch.ts +39 -0
- package/src/lib/proxy/index.ts +1 -0
- package/src/lib/utils/objects.ts +1 -5
- 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/src/cdk-constructs/IxSESIdentity.ts +0 -70
package/README.md
CHANGED
|
@@ -261,29 +261,6 @@ new IxDnsRecord(scope, "IxDnsRecord", {
|
|
|
261
261
|
|
|
262
262
|
</details>
|
|
263
263
|
|
|
264
|
-
<details>
|
|
265
|
-
<summary><strong>IxSESIdentity</strong> - Creates an SES domain identity for a domain managed by IX.</summary>
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
import { IxSESIdentity } from "@infoxchange/make-it-so/cdk-constructs";
|
|
269
|
-
|
|
270
|
-
new IxSESIdentity(scope, "IxSESIdentity", {
|
|
271
|
-
// Email identity domain will be: example.dev.ixapps.org
|
|
272
|
-
// Custom mail from domain will be: info.example.dev.ixapps.org
|
|
273
|
-
domain: "example.dev.ixapps.org",
|
|
274
|
-
mailFromSubdomain: "info", // optional, "mail" will be used otherwise
|
|
275
|
-
});
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
#### Options:
|
|
279
|
-
|
|
280
|
-
| Prop | Type | Description |
|
|
281
|
-
| ----------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
282
|
-
| domain | string | The domain of the identity. An email address can also be provided in which case the domain will be extracted from the email. |
|
|
283
|
-
| mailFromSubdomain | string | (optional) by default the custom mail from domain will be `mail.${domain}`. This lets you change that. It should be given as just the subdomain part, not the fully qualified domain. |
|
|
284
|
-
|
|
285
|
-
</details>
|
|
286
|
-
|
|
287
264
|
<details>
|
|
288
265
|
<summary><strong>IxWebsiteRedirect</strong> - Creates a redirect from one domain to another.</summary>
|
|
289
266
|
|
|
@@ -7,13 +7,10 @@ type Props = {
|
|
|
7
7
|
ttl?: number;
|
|
8
8
|
hostedZoneId?: string;
|
|
9
9
|
} & ({
|
|
10
|
-
type: "A" | "CNAME" | "NS" | "SOA"
|
|
10
|
+
type: "A" | "CNAME" | "NS" | "SOA";
|
|
11
11
|
} | {
|
|
12
12
|
type: "ALIAS";
|
|
13
13
|
aliasZoneId: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: "MX";
|
|
16
|
-
priority: number;
|
|
17
14
|
});
|
|
18
15
|
export declare class IxDnsRecord extends Construct {
|
|
19
16
|
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAC;CACpC,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CACJ,CAAC;AAEF,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAKhE,OAAO,CAAC,eAAe;CAyBxB"}
|
|
@@ -9,31 +9,14 @@ export class IxDnsRecord extends Construct {
|
|
|
9
9
|
}
|
|
10
10
|
createDnsRecord(scope, id, constructProps) {
|
|
11
11
|
const dnsRecordUpdaterLambdaArn = StringParameter.valueForStringParameter(scope, "/shared-services/route53/lambdaArn");
|
|
12
|
-
const
|
|
12
|
+
const lambdaProps = remapKeys(constructProps, {
|
|
13
13
|
name: "RecordFQDN",
|
|
14
14
|
value: "RecordValue",
|
|
15
15
|
ttl: "RecordTTL",
|
|
16
16
|
hostedZoneId: "HostedZoneId",
|
|
17
17
|
type: "RecordType",
|
|
18
18
|
aliasZoneId: "AliasZoneId",
|
|
19
|
-
};
|
|
20
|
-
let lambdaProps;
|
|
21
|
-
if (constructProps.type === "TXT") {
|
|
22
|
-
lambdaProps = remapKeys({
|
|
23
|
-
...constructProps,
|
|
24
|
-
value: `"${constructProps.value}"`,
|
|
25
|
-
}, keysMap);
|
|
26
|
-
}
|
|
27
|
-
else if (constructProps.type === "MX") {
|
|
28
|
-
const { priority, ...rest } = constructProps;
|
|
29
|
-
lambdaProps = remapKeys({
|
|
30
|
-
...rest,
|
|
31
|
-
value: `${priority} ${rest.value}`,
|
|
32
|
-
}, keysMap);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
lambdaProps = remapKeys(constructProps, keysMap);
|
|
36
|
-
}
|
|
19
|
+
});
|
|
37
20
|
new CustomResource(scope, id + "-CertificateCustomResource", {
|
|
38
21
|
resourceType: "Custom::DNSRecordUpdaterLambda",
|
|
39
22
|
serviceToken: dnsRecordUpdaterLambdaArn,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/proxy/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,WAAW,EACrB,MAAM,QAAQ,CAAC;AAGhB,wBAAgB,kBAAkB,SAiBjC;AAED,wBAAgB,eAAe,uBAW9B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { setGlobalDispatcher, getGlobalDispatcher, EnvHttpProxyAgent, fetch as undiciFetch, } from "undici";
|
|
2
|
+
import { bootstrap } from "global-agent";
|
|
3
|
+
export function setupProxyGlobally() {
|
|
4
|
+
// Make operation idempotent
|
|
5
|
+
if (getGlobalDispatcher() instanceof EnvHttpProxyAgent)
|
|
6
|
+
return;
|
|
7
|
+
// To cover libraries that use fetch
|
|
8
|
+
// See https://nodejs.org/api/globals.html#custom-dispatcher
|
|
9
|
+
// This might stop being needed at some point: https://github.com/actions/create-github-app-token/pull/143#discussion_r1747641337
|
|
10
|
+
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
11
|
+
setGlobalDispatcher(envHttpProxyAgent);
|
|
12
|
+
// To cover libraries that use the http/https object
|
|
13
|
+
if (!process.env.GLOBAL_AGENT_HTTP_PROXY) {
|
|
14
|
+
process.env.GLOBAL_AGENT_HTTP_PROXY = process.env.HTTP_PROXY;
|
|
15
|
+
process.env.GLOBAL_AGENT_HTTPS_PROXY =
|
|
16
|
+
process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY;
|
|
17
|
+
}
|
|
18
|
+
bootstrap();
|
|
19
|
+
}
|
|
20
|
+
export function getProxiedFetch() {
|
|
21
|
+
const fetch = (input, init = {}) => {
|
|
22
|
+
if (init.dispatcher) {
|
|
23
|
+
console.warn("A custom dispatcher was provided to fetch but this is ignored as a proxy agent is being used.");
|
|
24
|
+
}
|
|
25
|
+
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
26
|
+
return undiciFetch(input, { ...init, dispatcher: envHttpProxyAgent });
|
|
27
|
+
};
|
|
28
|
+
return fetch;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/proxy/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fetch.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function remapKeys<SourceObject extends object, MapObject extends Record<keyof SourceObject, string>>(object: SourceObject, keyMap: Readonly<MapObject>): {
|
|
2
|
-
[k in keyof SourceObject
|
|
2
|
+
[k in keyof SourceObject]: MapObject[k];
|
|
3
3
|
};
|
|
4
4
|
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,YAAY,SAAS,MAAM,EAC3B,SAAS,SAAS,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,EAEpD,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC1B;
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,YAAY,SAAS,MAAM,EAC3B,SAAS,SAAS,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,EAEpD,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC1B;KAAG,CAAC,IAAI,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC;CAAE,CAQ7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infoxchange/make-it-so",
|
|
3
|
-
"version": "2.12.0-internal-testing-add-
|
|
3
|
+
"version": "2.12.0-internal-testing-add-setup-proxy-globally.1",
|
|
4
4
|
"description": "Makes deploying services to IX infra easy",
|
|
5
5
|
"repository": "github:infoxchange/make-it-so",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
"./cdk-constructs": "./dist/cdk-constructs/index.js",
|
|
19
19
|
"./deployConfig": "./dist/deployConfig.js",
|
|
20
|
-
"./auth": "./dist/lib/auth/index.js"
|
|
20
|
+
"./auth": "./dist/lib/auth/index.js",
|
|
21
|
+
"./proxy": "./dist/lib/proxy/index.js"
|
|
21
22
|
},
|
|
22
23
|
"lint-staged": {
|
|
23
24
|
"**/*": [
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@eslint/js": "^9.3.0",
|
|
33
34
|
"@tsconfig/node21": "^21.0.3",
|
|
34
35
|
"@types/aws-cloudfront-function": "^1.0.6",
|
|
36
|
+
"@types/global-agent": "^3.0.0",
|
|
35
37
|
"@types/jsonwebtoken": "^9.0.10",
|
|
36
38
|
"aws-cdk-lib": "2.142.1",
|
|
37
39
|
"constructs": "^10.3.0",
|
|
@@ -53,7 +55,9 @@
|
|
|
53
55
|
"sst": "^2.0.0"
|
|
54
56
|
},
|
|
55
57
|
"dependencies": {
|
|
58
|
+
"global-agent": "^3.0.0",
|
|
56
59
|
"jsonwebtoken": "^9.0.2",
|
|
60
|
+
"undici": "^7.16.0",
|
|
57
61
|
"zod": "^3.24.2"
|
|
58
62
|
}
|
|
59
63
|
}
|
|
@@ -13,16 +13,12 @@ type Props = {
|
|
|
13
13
|
hostedZoneId?: string;
|
|
14
14
|
} & (
|
|
15
15
|
| {
|
|
16
|
-
type: "A" | "CNAME" | "NS" | "SOA"
|
|
16
|
+
type: "A" | "CNAME" | "NS" | "SOA";
|
|
17
17
|
}
|
|
18
18
|
| {
|
|
19
19
|
type: "ALIAS";
|
|
20
20
|
aliasZoneId: string;
|
|
21
21
|
}
|
|
22
|
-
| {
|
|
23
|
-
type: "MX";
|
|
24
|
-
priority: number;
|
|
25
|
-
}
|
|
26
22
|
);
|
|
27
23
|
|
|
28
24
|
export class IxDnsRecord extends Construct {
|
|
@@ -40,35 +36,15 @@ export class IxDnsRecord extends Construct {
|
|
|
40
36
|
scope,
|
|
41
37
|
"/shared-services/route53/lambdaArn",
|
|
42
38
|
);
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
const lambdaProps = remapKeys(constructProps, {
|
|
44
41
|
name: "RecordFQDN",
|
|
45
42
|
value: "RecordValue",
|
|
46
43
|
ttl: "RecordTTL",
|
|
47
44
|
hostedZoneId: "HostedZoneId",
|
|
48
45
|
type: "RecordType",
|
|
49
46
|
aliasZoneId: "AliasZoneId",
|
|
50
|
-
};
|
|
51
|
-
let lambdaProps;
|
|
52
|
-
if (constructProps.type === "TXT") {
|
|
53
|
-
lambdaProps = remapKeys(
|
|
54
|
-
{
|
|
55
|
-
...constructProps,
|
|
56
|
-
value: `"${constructProps.value}"`,
|
|
57
|
-
},
|
|
58
|
-
keysMap,
|
|
59
|
-
);
|
|
60
|
-
} else if (constructProps.type === "MX") {
|
|
61
|
-
const { priority, ...rest } = constructProps;
|
|
62
|
-
lambdaProps = remapKeys(
|
|
63
|
-
{
|
|
64
|
-
...rest,
|
|
65
|
-
value: `${priority} ${rest.value}`,
|
|
66
|
-
},
|
|
67
|
-
keysMap,
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
lambdaProps = remapKeys(constructProps, keysMap);
|
|
71
|
-
}
|
|
47
|
+
});
|
|
72
48
|
|
|
73
49
|
new CustomResource(scope, id + "-CertificateCustomResource", {
|
|
74
50
|
resourceType: "Custom::DNSRecordUpdaterLambda",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setGlobalDispatcher,
|
|
3
|
+
getGlobalDispatcher,
|
|
4
|
+
EnvHttpProxyAgent,
|
|
5
|
+
fetch as undiciFetch,
|
|
6
|
+
} from "undici";
|
|
7
|
+
import { bootstrap } from "global-agent";
|
|
8
|
+
|
|
9
|
+
export function setupProxyGlobally() {
|
|
10
|
+
// Make operation idempotent
|
|
11
|
+
if (getGlobalDispatcher() instanceof EnvHttpProxyAgent) return;
|
|
12
|
+
|
|
13
|
+
// To cover libraries that use fetch
|
|
14
|
+
// See https://nodejs.org/api/globals.html#custom-dispatcher
|
|
15
|
+
// This might stop being needed at some point: https://github.com/actions/create-github-app-token/pull/143#discussion_r1747641337
|
|
16
|
+
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
17
|
+
setGlobalDispatcher(envHttpProxyAgent);
|
|
18
|
+
|
|
19
|
+
// To cover libraries that use the http/https object
|
|
20
|
+
if (!process.env.GLOBAL_AGENT_HTTP_PROXY) {
|
|
21
|
+
process.env.GLOBAL_AGENT_HTTP_PROXY = process.env.HTTP_PROXY;
|
|
22
|
+
process.env.GLOBAL_AGENT_HTTPS_PROXY =
|
|
23
|
+
process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY;
|
|
24
|
+
}
|
|
25
|
+
bootstrap();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getProxiedFetch() {
|
|
29
|
+
const fetch: typeof undiciFetch = (input, init = {}) => {
|
|
30
|
+
if (init.dispatcher) {
|
|
31
|
+
console.warn(
|
|
32
|
+
"A custom dispatcher was provided to fetch but this is ignored as a proxy agent is being used.",
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
36
|
+
return undiciFetch(input, { ...init, dispatcher: envHttpProxyAgent });
|
|
37
|
+
};
|
|
38
|
+
return fetch;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fetch.js";
|
package/src/lib/utils/objects.ts
CHANGED
|
@@ -4,11 +4,7 @@ export function remapKeys<
|
|
|
4
4
|
>(
|
|
5
5
|
object: SourceObject,
|
|
6
6
|
keyMap: Readonly<MapObject>,
|
|
7
|
-
): {
|
|
8
|
-
[k in keyof SourceObject as k extends keyof MapObject
|
|
9
|
-
? MapObject[k]
|
|
10
|
-
: k]: SourceObject[k];
|
|
11
|
-
} {
|
|
7
|
+
): { [k in keyof SourceObject]: MapObject[k] } {
|
|
12
8
|
return Object.fromEntries(
|
|
13
9
|
Object.entries(object).map(([key, value]) => {
|
|
14
10
|
// @ts-expect-error the typing for map() reduces keys to general string
|
|
@@ -1,12 +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
|
-
domain: string;
|
|
6
|
-
mailFromSubdomain?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare class IxSESIdentity extends Construct {
|
|
9
|
-
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=IxSESIdentity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IxSESIdentity.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxSESIdentity.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,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;CAuDjE"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { IxDnsRecord } from "./IxDnsRecord.js";
|
|
3
|
-
import * as ses from "aws-cdk-lib/aws-ses";
|
|
4
|
-
import * as cdk from "aws-cdk-lib";
|
|
5
|
-
export class IxSESIdentity extends Construct {
|
|
6
|
-
constructor(scope, id, props) {
|
|
7
|
-
const domain = props.domain.includes("@")
|
|
8
|
-
? props.domain.split("@")[1]
|
|
9
|
-
: props.domain;
|
|
10
|
-
const mailFromDomain = `${props.mailFromSubdomain ?? "mail"}.${domain}`;
|
|
11
|
-
super(scope, id);
|
|
12
|
-
const identity = new ses.EmailIdentity(scope, `${id}EmailIdentity`, {
|
|
13
|
-
identity: ses.Identity.domain(domain),
|
|
14
|
-
mailFromDomain,
|
|
15
|
-
});
|
|
16
|
-
// Based on https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L247
|
|
17
|
-
for (const i of [1, 2, 3]) {
|
|
18
|
-
new IxDnsRecord(scope, `${id}DkimDnsToken${i}`, {
|
|
19
|
-
type: "CNAME",
|
|
20
|
-
name: identity[`dkimDnsTokenName${i}`],
|
|
21
|
-
value: identity[`dkimDnsTokenValue${i}`],
|
|
22
|
-
ttl: 1800,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
// Based on
|
|
26
|
-
// https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L512
|
|
27
|
-
new IxDnsRecord(scope, `${id}MailFromMxRecord`, {
|
|
28
|
-
type: "MX",
|
|
29
|
-
name: mailFromDomain,
|
|
30
|
-
value: `feedback-smtp.${cdk.Stack.of(scope).region}.amazonses.com`,
|
|
31
|
-
priority: 10,
|
|
32
|
-
});
|
|
33
|
-
new IxDnsRecord(scope, `${id}MailFromTxtRecord`, {
|
|
34
|
-
type: "TXT",
|
|
35
|
-
name: mailFromDomain,
|
|
36
|
-
value: "v=spf1 include:amazonses.com ~all",
|
|
37
|
-
});
|
|
38
|
-
// Set up DMARC record
|
|
39
|
-
new IxDnsRecord(scope, `${id}DMARC`, {
|
|
40
|
-
type: "TXT",
|
|
41
|
-
name: `_dmarc.${domain}`,
|
|
42
|
-
value: "v=DMARC1; p=none;",
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { IxDnsRecord } from "./IxDnsRecord.js";
|
|
3
|
-
import * as ses from "aws-cdk-lib/aws-ses";
|
|
4
|
-
import * as cdk from "aws-cdk-lib";
|
|
5
|
-
|
|
6
|
-
type ConstructScope = ConstructorParameters<typeof Construct>[0];
|
|
7
|
-
type ConstructId = ConstructorParameters<typeof Construct>[1];
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
domain: string;
|
|
11
|
-
mailFromSubdomain?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export class IxSESIdentity extends Construct {
|
|
15
|
-
constructor(scope: ConstructScope, id: ConstructId, props: Props) {
|
|
16
|
-
const domain = props.domain.includes("@")
|
|
17
|
-
? props.domain.split("@")[1]
|
|
18
|
-
: props.domain;
|
|
19
|
-
const mailFromDomain = `${props.mailFromSubdomain ?? "mail"}.${domain}`;
|
|
20
|
-
|
|
21
|
-
super(scope, id);
|
|
22
|
-
|
|
23
|
-
const identity = new ses.EmailIdentity(scope, `${id}EmailIdentity`, {
|
|
24
|
-
identity: ses.Identity.domain(domain),
|
|
25
|
-
mailFromDomain,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Based on https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L247
|
|
29
|
-
for (const i of [1, 2, 3]) {
|
|
30
|
-
new IxDnsRecord(scope, `${id}DkimDnsToken${i}`, {
|
|
31
|
-
type: "CNAME",
|
|
32
|
-
name: identity[
|
|
33
|
-
`dkimDnsTokenName${i}` as
|
|
34
|
-
| "dkimDnsTokenName1"
|
|
35
|
-
| "dkimDnsTokenName2"
|
|
36
|
-
| "dkimDnsTokenName3"
|
|
37
|
-
],
|
|
38
|
-
value:
|
|
39
|
-
identity[
|
|
40
|
-
`dkimDnsTokenValue${i}` as
|
|
41
|
-
| "dkimDnsTokenValue1"
|
|
42
|
-
| "dkimDnsTokenValue2"
|
|
43
|
-
| "dkimDnsTokenValue3"
|
|
44
|
-
],
|
|
45
|
-
ttl: 1800,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Based on
|
|
50
|
-
// https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L512
|
|
51
|
-
new IxDnsRecord(scope, `${id}MailFromMxRecord`, {
|
|
52
|
-
type: "MX",
|
|
53
|
-
name: mailFromDomain,
|
|
54
|
-
value: `feedback-smtp.${cdk.Stack.of(scope).region}.amazonses.com`,
|
|
55
|
-
priority: 10,
|
|
56
|
-
});
|
|
57
|
-
new IxDnsRecord(scope, `${id}MailFromTxtRecord`, {
|
|
58
|
-
type: "TXT",
|
|
59
|
-
name: mailFromDomain,
|
|
60
|
-
value: "v=spf1 include:amazonses.com ~all",
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Set up DMARC record
|
|
64
|
-
new IxDnsRecord(scope, `${id}DMARC`, {
|
|
65
|
-
type: "TXT",
|
|
66
|
-
name: `_dmarc.${domain}`,
|
|
67
|
-
value: "v=DMARC1; p=none;",
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|