dcl-ops-lib 8.3.2 → 9.0.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/README.md +1 -0
- package/acceptBastion.js +3 -12
- package/acceptDb.js +6 -15
- package/accessTheInternet.js +23 -34
- package/alb.js +7 -16
- package/buildStatic.js +1 -2
- package/cloudflare.js +47 -57
- package/createFargateTask.js +240 -251
- package/createImageFromContext.js +6 -2
- package/exposePublicService.js +74 -85
- package/getAmi.js +14 -25
- package/getImageRegistryAndCredentials.js +3 -12
- package/lambda.js +124 -132
- package/package.json +13 -9
- package/prometheus.js +6 -15
- package/utils.js +1 -1
- package/values.js +12 -23
- package/vpc.js +7 -18
package/README.md
CHANGED
package/acceptBastion.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.makeSecurityGroupAccessibleFromBastion = void 0;
|
|
13
4
|
const aws = require("@pulumi/aws");
|
|
14
5
|
const values_1 = require("./values");
|
|
15
6
|
const withCache_1 = require("./withCache");
|
|
16
7
|
const utils_1 = require("./utils");
|
|
17
|
-
const bastionSecurityGroupId = (0, withCache_1.default)(() =>
|
|
18
|
-
const config =
|
|
8
|
+
const bastionSecurityGroupId = (0, withCache_1.default)(async () => {
|
|
9
|
+
const config = await (0, values_1.getEnvConfiguration)();
|
|
19
10
|
return config.bastionSecurityGroupId;
|
|
20
|
-
})
|
|
11
|
+
});
|
|
21
12
|
function makeSecurityGroupAccessibleFromBastion(securityGroup, ruleName = "") {
|
|
22
13
|
new aws.ec2.SecurityGroupRule((0, utils_1.withRuleName)("accesible-from-bastion-v2", ruleName), {
|
|
23
14
|
securityGroupId: securityGroup.id,
|
package/acceptDb.js
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.acceptDbSecurityGroupId = exports.acceptDbSecurityGroup = void 0;
|
|
13
4
|
const aws = require("@pulumi/aws");
|
|
14
5
|
const values_1 = require("./values");
|
|
15
6
|
const withCache_1 = require("./withCache");
|
|
16
|
-
exports.acceptDbSecurityGroup = (0, withCache_1.default)(() =>
|
|
17
|
-
const config =
|
|
7
|
+
exports.acceptDbSecurityGroup = (0, withCache_1.default)(async () => {
|
|
8
|
+
const config = await (0, values_1.getEnvConfiguration)();
|
|
18
9
|
return aws.ec2.getSecurityGroup({ id: config.dbSecurity });
|
|
19
|
-
})
|
|
20
|
-
exports.acceptDbSecurityGroupId = (0, withCache_1.default)(() =>
|
|
21
|
-
const config =
|
|
10
|
+
});
|
|
11
|
+
exports.acceptDbSecurityGroupId = (0, withCache_1.default)(async () => {
|
|
12
|
+
const config = await (0, values_1.getEnvConfiguration)();
|
|
22
13
|
return config.dbSecurity;
|
|
23
|
-
})
|
|
14
|
+
});
|
|
24
15
|
exports.default = exports.acceptDbSecurityGroup;
|
|
25
16
|
//# sourceMappingURL=acceptDb.js.map
|
package/accessTheInternet.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.makeSecurityGroupAccessibleByCloudflare = exports.makeSecurityGroupAccessTheInternetV2 = void 0;
|
|
13
4
|
const aws = require("@pulumi/aws");
|
|
@@ -27,31 +18,29 @@ function makeSecurityGroupAccessTheInternetV2(securityGroup, ruleName = "") {
|
|
|
27
18
|
}
|
|
28
19
|
exports.makeSecurityGroupAccessTheInternetV2 = makeSecurityGroupAccessTheInternetV2;
|
|
29
20
|
/** Enables ingress traffic from cloudflare CIDRs */
|
|
30
|
-
function makeSecurityGroupAccessibleByCloudflare(securityGroup) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
});
|
|
21
|
+
async function makeSecurityGroupAccessibleByCloudflare(securityGroup) {
|
|
22
|
+
const ips = await cloudflare.getIpRanges({});
|
|
23
|
+
for (let block of ips.ipv4CidrBlocks) {
|
|
24
|
+
const hash = (0, utils_1.sha256hash)(block).substring(0, 6);
|
|
25
|
+
new aws.ec2.SecurityGroupRule(`accept-cf-80-${hash}`, {
|
|
26
|
+
protocol: "tcp",
|
|
27
|
+
fromPort: 80,
|
|
28
|
+
toPort: 80,
|
|
29
|
+
cidrBlocks: [block],
|
|
30
|
+
type: "ingress",
|
|
31
|
+
securityGroupId: securityGroup.id,
|
|
32
|
+
description: `pulumi-supra-${hash}`,
|
|
33
|
+
}, { deleteBeforeReplace: true });
|
|
34
|
+
new aws.ec2.SecurityGroupRule(`accept-cf-443-${hash}`, {
|
|
35
|
+
protocol: "tcp",
|
|
36
|
+
fromPort: 443,
|
|
37
|
+
toPort: 443,
|
|
38
|
+
cidrBlocks: [block],
|
|
39
|
+
type: "ingress",
|
|
40
|
+
securityGroupId: securityGroup.id,
|
|
41
|
+
description: `pulumi-supra-${hash}`,
|
|
42
|
+
}, { deleteBeforeReplace: true });
|
|
43
|
+
}
|
|
55
44
|
}
|
|
56
45
|
exports.makeSecurityGroupAccessibleByCloudflare = makeSecurityGroupAccessibleByCloudflare;
|
|
57
46
|
//# sourceMappingURL=accessTheInternet.js.map
|
package/alb.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getAlb = void 0;
|
|
13
4
|
const aws = require("@pulumi/aws");
|
|
@@ -21,12 +12,12 @@ const cache = {
|
|
|
21
12
|
dns: undefined,
|
|
22
13
|
listener: null
|
|
23
14
|
};
|
|
24
|
-
exports.getAlb = (0, withCache_1.default)(() =>
|
|
25
|
-
const dns =
|
|
26
|
-
const loadBalancer =
|
|
27
|
-
const elbValues =
|
|
28
|
-
const alb =
|
|
29
|
-
const listener =
|
|
15
|
+
exports.getAlb = (0, withCache_1.default)(async () => {
|
|
16
|
+
const dns = await supra_1.supra.getOutputValue("dns");
|
|
17
|
+
const loadBalancer = await supra_1.supra.requireOutputValue("albInstance");
|
|
18
|
+
const elbValues = await supra_1.supra.requireOutputValue("elbValues");
|
|
19
|
+
const alb = await aws.lb.getLoadBalancer({ arn: loadBalancer.arn });
|
|
20
|
+
const listener = await aws.lb.getListener({ arn: elbValues.listenerArn });
|
|
30
21
|
return { dns, alb, listener };
|
|
31
|
-
})
|
|
22
|
+
});
|
|
32
23
|
//# sourceMappingURL=alb.js.map
|
package/buildStatic.js
CHANGED
|
@@ -8,7 +8,6 @@ const cloudflare_1 = require("./cloudflare");
|
|
|
8
8
|
const domain_1 = require("./domain");
|
|
9
9
|
const getDomainAndSubdomain_1 = require("./getDomainAndSubdomain");
|
|
10
10
|
function buildStatic(staticSite) {
|
|
11
|
-
var _a;
|
|
12
11
|
const protect = !staticSite.unprotect;
|
|
13
12
|
// Load the Pulumi program configuration. These act as the "parameters" to the Pulumi program,
|
|
14
13
|
// so that different Pulumi Stacks can be brought up using the same code.
|
|
@@ -28,7 +27,7 @@ function buildStatic(staticSite) {
|
|
|
28
27
|
// requests for "foo/" to "foo/index.html".
|
|
29
28
|
website: {
|
|
30
29
|
indexDocument: "index.html",
|
|
31
|
-
errorDocument:
|
|
30
|
+
errorDocument: staticSite.defaultPath ?? "404.html",
|
|
32
31
|
},
|
|
33
32
|
forceDestroy: staticSite.destroy === true
|
|
34
33
|
};
|
package/cloudflare.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.setRecord = exports.deployWorker = exports.getAccountId = exports.getZoneId = void 0;
|
|
13
4
|
const pulumi = require("@pulumi/pulumi");
|
|
14
5
|
const cloudflare = require("@pulumi/cloudflare");
|
|
15
6
|
const domain_1 = require("./domain");
|
|
16
7
|
const fs_1 = require("fs");
|
|
17
|
-
function getZoneId() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return res.zones[0].id;
|
|
23
|
-
});
|
|
8
|
+
async function getZoneId() {
|
|
9
|
+
const res = await cloudflare.getZones({ filter: { name: domain_1.publicDomain } });
|
|
10
|
+
if (res.zones.length == 0)
|
|
11
|
+
throw new Error(`Zone ${domain_1.publicDomain} not found`);
|
|
12
|
+
return res.zones[0].id;
|
|
24
13
|
}
|
|
25
14
|
exports.getZoneId = getZoneId;
|
|
26
15
|
function getAccountId() {
|
|
@@ -32,50 +21,51 @@ function getAccountId() {
|
|
|
32
21
|
}
|
|
33
22
|
}
|
|
34
23
|
exports.getAccountId = getAccountId;
|
|
35
|
-
function deployWorker(workerName, config) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
plainTextBindings.push({ name, text });
|
|
43
|
-
});
|
|
44
|
-
// create the worker
|
|
45
|
-
const worker = new cloudflare.WorkerScript(`${workerName}-${domain_1.publicTLD}`, Object.assign({ name: `${workerName}-${domain_1.publicTLD}`, content,
|
|
46
|
-
plainTextBindings, accountId: getAccountId() }, (config.overrides || {})));
|
|
47
|
-
const ret = { [workerName + "-" + domain_1.publicTLD]: worker.id, worker };
|
|
48
|
-
// create the routes
|
|
49
|
-
let count = 0;
|
|
50
|
-
for (let pattern of config.routes) {
|
|
51
|
-
const contentRoute = new cloudflare.WorkerRoute(`${workerName}-route-${count}`, {
|
|
52
|
-
pattern,
|
|
53
|
-
scriptName: worker.name,
|
|
54
|
-
zoneId: getZoneId(),
|
|
55
|
-
}, { aliases: [pulumi.interpolate `${workerName}-route-${pattern}`] });
|
|
56
|
-
count++;
|
|
57
|
-
ret[workerName + "-" + domain_1.publicTLD + "-route"] = contentRoute.id;
|
|
58
|
-
}
|
|
59
|
-
return ret;
|
|
24
|
+
async function deployWorker(workerName, config) {
|
|
25
|
+
// get file contents
|
|
26
|
+
const content = (0, fs_1.readFileSync)(config.jsWorkerFileName).toString();
|
|
27
|
+
// build array of global variables for the workers
|
|
28
|
+
const plainTextBindings = [];
|
|
29
|
+
Object.entries(config.env || {}).forEach(([name, text]) => {
|
|
30
|
+
plainTextBindings.push({ name, text });
|
|
60
31
|
});
|
|
32
|
+
// create the worker
|
|
33
|
+
const worker = new cloudflare.WorkerScript(`${workerName}-${domain_1.publicTLD}`, {
|
|
34
|
+
name: `${workerName}-${domain_1.publicTLD}`,
|
|
35
|
+
content,
|
|
36
|
+
plainTextBindings,
|
|
37
|
+
accountId: getAccountId(),
|
|
38
|
+
...(config.overrides || {}),
|
|
39
|
+
});
|
|
40
|
+
const ret = { [workerName + "-" + domain_1.publicTLD]: worker.id, worker };
|
|
41
|
+
// create the routes
|
|
42
|
+
let count = 0;
|
|
43
|
+
for (let pattern of config.routes) {
|
|
44
|
+
const contentRoute = new cloudflare.WorkerRoute(`${workerName}-route-${count}`, {
|
|
45
|
+
pattern,
|
|
46
|
+
scriptName: worker.name,
|
|
47
|
+
zoneId: getZoneId(),
|
|
48
|
+
}, { aliases: [pulumi.interpolate `${workerName}-route-${pattern}`] });
|
|
49
|
+
count++;
|
|
50
|
+
ret[workerName + "-" + domain_1.publicTLD + "-route"] = contentRoute.id;
|
|
51
|
+
}
|
|
52
|
+
return ret;
|
|
61
53
|
}
|
|
62
54
|
exports.deployWorker = deployWorker;
|
|
63
|
-
function setRecord(config) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return record;
|
|
78
|
-
});
|
|
55
|
+
async function setRecord(config) {
|
|
56
|
+
if (!config.proxied && config.ttl < 120) {
|
|
57
|
+
throw new Error("Min TTL is 120");
|
|
58
|
+
}
|
|
59
|
+
// create the record
|
|
60
|
+
const record = new cloudflare.Record(`${config.recordName}-${config.type}-${domain_1.publicTLD}`, {
|
|
61
|
+
type: config.type,
|
|
62
|
+
name: config.recordName,
|
|
63
|
+
value: config.value,
|
|
64
|
+
ttl: config.proxied ? 1 : config.ttl,
|
|
65
|
+
zoneId: getZoneId(),
|
|
66
|
+
proxied: config.proxied,
|
|
67
|
+
}, { deleteBeforeReplace: true });
|
|
68
|
+
return record;
|
|
79
69
|
}
|
|
80
70
|
exports.setRecord = setRecord;
|
|
81
71
|
//# sourceMappingURL=cloudflare.js.map
|