dcl-ops-lib 5.21.2 → 5.22.0
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/exposePublicService.d.ts +9 -2
- package/exposePublicService.js +27 -8
- package/package.json +1 -1
package/exposePublicService.d.ts
CHANGED
|
@@ -3,8 +3,15 @@ import * as aws from "@pulumi/aws";
|
|
|
3
3
|
import * as awsx from "@pulumi/awsx";
|
|
4
4
|
import * as cf from "@pulumi/cloudflare";
|
|
5
5
|
import { ApplicationTargetGroupHealthCheck } from "@pulumi/awsx/lb";
|
|
6
|
-
export declare type
|
|
7
|
-
createCloudflareProxiedSubdomain
|
|
6
|
+
export declare type ProxiedCloudflareDomain = {
|
|
7
|
+
createCloudflareProxiedSubdomain: true;
|
|
8
|
+
};
|
|
9
|
+
export declare type UnproxiedCloudflareDomain = {
|
|
10
|
+
createCloudflareDNSWithoutProxy: true;
|
|
11
|
+
ttl: number;
|
|
12
|
+
};
|
|
13
|
+
export declare type CloudflareDomainOptions = ProxiedCloudflareDomain | UnproxiedCloudflareDomain | {};
|
|
14
|
+
export declare type ExtraExposedServiceOptions = CloudflareDomainOptions & {
|
|
8
15
|
skipInternalDomain?: boolean;
|
|
9
16
|
targetGroupConditions?: pulumi.Input<aws.types.input.alb.ListenerRuleCondition>[];
|
|
10
17
|
};
|
package/exposePublicService.js
CHANGED
|
@@ -24,6 +24,12 @@ const DEFAULT_HEALTHCHECK_VALUES = {
|
|
|
24
24
|
unhealthyThreshold: 5,
|
|
25
25
|
healthyThreshold: 5,
|
|
26
26
|
};
|
|
27
|
+
function isProxiedDomain(v) {
|
|
28
|
+
return typeof v == "object" && v && v.createCloudflareProxiedSubdomain;
|
|
29
|
+
}
|
|
30
|
+
function isUnProxiedDomain(v) {
|
|
31
|
+
return typeof v == "object" && v && v.createCloudflareDNSWithoutProxy;
|
|
32
|
+
}
|
|
27
33
|
/**
|
|
28
34
|
* Publicly expose a service on a given domain (with SSL). This will create a
|
|
29
35
|
* Target Group and a Listener for your microservice. Additionally, it will
|
|
@@ -37,7 +43,9 @@ function exposePublicService(name, domain, port, healthCheck = {}, vpc, extraOpt
|
|
|
37
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
44
|
const { alb, listener } = yield (0, alb_1.getAlb)();
|
|
39
45
|
const healthCheckValue = Object.assign({}, DEFAULT_HEALTHCHECK_VALUES, healthCheck);
|
|
40
|
-
const
|
|
46
|
+
const isProxied = isProxiedDomain(extraOptions);
|
|
47
|
+
const isUnproxied = isUnProxiedDomain(extraOptions);
|
|
48
|
+
const createCloudflareRecord = isProxied || isUnproxied || domain.endsWith(`.${domain_1.publicDomain}`);
|
|
41
49
|
const onlyCloudflare = (extraOptions && extraOptions.skipInternalDomain) || false;
|
|
42
50
|
const createInternalDomain = !onlyCloudflare;
|
|
43
51
|
const certificate = (0, certificate_1.getCertificateFor)(domain);
|
|
@@ -71,14 +79,25 @@ function exposePublicService(name, domain, port, healthCheck = {}, vpc, extraOpt
|
|
|
71
79
|
});
|
|
72
80
|
enabledHostnames.push(domain);
|
|
73
81
|
}
|
|
74
|
-
if (
|
|
82
|
+
if (createCloudflareRecord) {
|
|
75
83
|
enabledHostnames.push(domainParts.subdomain + "." + domain_1.publicDomain);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
if (isUnProxiedDomain(extraOptions)) {
|
|
85
|
+
cloudflareRecord = yield (0, cloudflare_1.setRecord)({
|
|
86
|
+
recordName: domainParts.subdomain,
|
|
87
|
+
type: "CNAME",
|
|
88
|
+
value: alb.loadBalancer.dnsName,
|
|
89
|
+
proxied: false,
|
|
90
|
+
ttl: extraOptions.ttl || 600,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
cloudflareRecord = yield (0, cloudflare_1.setRecord)({
|
|
95
|
+
recordName: domainParts.subdomain,
|
|
96
|
+
type: "CNAME",
|
|
97
|
+
value: alb.loadBalancer.dnsName,
|
|
98
|
+
proxied: true,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
82
101
|
}
|
|
83
102
|
if (enabledHostnames.length) {
|
|
84
103
|
new aws.alb.ListenerRule(`${domain_1.env}-ls-${slug}`, {
|