@studion/infra-code-blocks 0.8.0-next.2 → 2.0.0-alpha.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/dist/components/acm-certificate/index.d.ts +20 -0
- package/dist/components/acm-certificate/index.d.ts.map +1 -0
- package/dist/components/acm-certificate/index.js +40 -0
- package/dist/components/cloudfront/index.d.ts +92 -0
- package/dist/components/cloudfront/index.d.ts.map +1 -0
- package/dist/components/cloudfront/index.js +208 -0
- package/dist/components/cloudfront/lb-cache-strategy.d.ts +21 -0
- package/dist/components/cloudfront/lb-cache-strategy.d.ts.map +1 -0
- package/dist/components/cloudfront/lb-cache-strategy.js +93 -0
- package/dist/components/cloudfront/s3-cache-strategy.d.ts +21 -0
- package/dist/components/cloudfront/s3-cache-strategy.d.ts.map +1 -0
- package/dist/components/cloudfront/s3-cache-strategy.js +78 -0
- package/dist/components/cloudfront/types.d.ts +10 -0
- package/dist/components/cloudfront/types.d.ts.map +1 -0
- package/dist/components/database/builder.d.ts +32 -0
- package/dist/components/database/builder.d.ts.map +1 -0
- package/dist/components/database/builder.js +82 -0
- package/dist/components/database/database-replica.d.ts +35 -0
- package/dist/components/database/database-replica.d.ts.map +1 -0
- package/dist/components/database/database-replica.js +40 -0
- package/dist/components/database/ec2-ssm-connect.d.ts +26 -0
- package/dist/components/database/ec2-ssm-connect.d.ts.map +1 -0
- package/dist/components/{ec2-ssm-connect.js → database/ec2-ssm-connect.js} +42 -34
- package/dist/components/database/index.d.ts +67 -0
- package/dist/components/database/index.d.ts.map +1 -0
- package/dist/components/database/index.js +144 -0
- package/dist/{v2/components → components}/ecs-service/index.d.ts +6 -5
- package/dist/components/ecs-service/index.d.ts.map +1 -0
- package/dist/{v2/components → components}/ecs-service/index.js +19 -30
- package/dist/components/ecs-service/policies.d.ts +3 -0
- package/dist/components/ecs-service/policies.d.ts.map +1 -0
- package/dist/components/ecs-service/task-size.d.ts +37 -0
- package/dist/components/ecs-service/task-size.d.ts.map +1 -0
- package/dist/{constants.js → components/ecs-service/task-size.js} +17 -7
- package/dist/components/grafana/dashboards/index.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/panels.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/types.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/web-server-slo.d.ts.map +1 -0
- package/dist/components/grafana/index.d.ts.map +1 -0
- package/dist/components/password/index.d.ts +15 -0
- package/dist/components/password/index.d.ts.map +1 -0
- package/dist/components/{password.js → password/index.js} +6 -9
- package/dist/components/prometheus/index.d.ts.map +1 -0
- package/dist/components/prometheus/queries.d.ts.map +1 -0
- package/dist/components/prometheus/queries.test.d.ts.map +1 -0
- package/dist/components/redis/elasticache-redis.d.ts +38 -0
- package/dist/components/redis/elasticache-redis.d.ts.map +1 -0
- package/dist/components/redis/elasticache-redis.js +58 -0
- package/dist/components/redis/upstash-redis.d.ts +20 -0
- package/dist/components/redis/upstash-redis.d.ts.map +1 -0
- package/dist/components/redis/upstash-redis.js +29 -0
- package/dist/components/static-site/index.d.ts +23 -0
- package/dist/components/static-site/index.d.ts.map +1 -0
- package/dist/components/static-site/index.js +32 -0
- package/dist/components/static-site/s3-assets.d.ts +20 -0
- package/dist/components/static-site/s3-assets.d.ts.map +1 -0
- package/dist/components/static-site/s3-assets.js +63 -0
- package/dist/components/vpc/index.d.ts +20 -0
- package/dist/components/vpc/index.d.ts.map +1 -0
- package/dist/components/vpc/index.js +31 -0
- package/dist/{v2/components → components}/web-server/builder.d.ts +6 -2
- package/dist/components/web-server/builder.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/builder.js +11 -1
- package/dist/{v2/components → components}/web-server/index.d.ts +30 -8
- package/dist/components/web-server/index.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/index.js +49 -40
- package/dist/{v2/components → components}/web-server/load-balancer.d.ts +4 -3
- package/dist/components/web-server/load-balancer.d.ts.map +1 -0
- package/dist/{v2/components → components}/web-server/load-balancer.js +17 -14
- package/dist/index.d.ts +24 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -26
- package/dist/otel/batch-processor.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/builder.d.ts +15 -2
- package/dist/otel/builder.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/builder.js +47 -2
- package/dist/{v2/otel → otel}/config.d.ts +13 -1
- package/dist/otel/config.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/config.js +20 -3
- package/dist/{v2/otel → otel}/index.d.ts +8 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/memory-limiter-processor.d.ts.map +1 -0
- package/dist/otel/otlp-receiver.d.ts.map +1 -0
- package/dist/otel/prometheus-remote-write-exporter.d.ts.map +1 -0
- package/dist/shared/common-tags.d.ts +5 -0
- package/dist/shared/common-tags.d.ts.map +1 -0
- package/dist/shared/common-tags.js +8 -0
- package/dist/shared/merge-with-defaults.d.ts +2 -0
- package/dist/shared/merge-with-defaults.d.ts.map +1 -0
- package/dist/shared/merge-with-defaults.js +7 -0
- package/package.json +32 -14
- package/dist/components/acm-certificate.d.ts +0 -11
- package/dist/components/acm-certificate.d.ts.map +0 -1
- package/dist/components/acm-certificate.js +0 -30
- package/dist/components/database-replica.d.ts +0 -69
- package/dist/components/database-replica.d.ts.map +0 -1
- package/dist/components/database-replica.js +0 -40
- package/dist/components/database.d.ts +0 -99
- package/dist/components/database.d.ts.map +0 -1
- package/dist/components/database.js +0 -118
- package/dist/components/ec2-ssm-connect.d.ts +0 -22
- package/dist/components/ec2-ssm-connect.d.ts.map +0 -1
- package/dist/components/ecs-service.d.ts +0 -143
- package/dist/components/ecs-service.d.ts.map +0 -1
- package/dist/components/ecs-service.js +0 -357
- package/dist/components/mongo.d.ts +0 -39
- package/dist/components/mongo.d.ts.map +0 -1
- package/dist/components/mongo.js +0 -54
- package/dist/components/nuxt-ssr.d.ts +0 -44
- package/dist/components/nuxt-ssr.d.ts.map +0 -1
- package/dist/components/nuxt-ssr.js +0 -277
- package/dist/components/password.d.ts +0 -13
- package/dist/components/password.d.ts.map +0 -1
- package/dist/components/project.d.ts +0 -77
- package/dist/components/project.d.ts.map +0 -1
- package/dist/components/project.js +0 -171
- package/dist/components/redis.d.ts +0 -23
- package/dist/components/redis.d.ts.map +0 -1
- package/dist/components/redis.js +0 -35
- package/dist/components/static-site.d.ts +0 -36
- package/dist/components/static-site.d.ts.map +0 -1
- package/dist/components/static-site.js +0 -138
- package/dist/components/web-server.d.ts +0 -38
- package/dist/components/web-server.d.ts.map +0 -1
- package/dist/components/web-server.js +0 -185
- package/dist/constants.d.ts +0 -23
- package/dist/constants.d.ts.map +0 -1
- package/dist/types/pulumi.d.ts +0 -5
- package/dist/types/pulumi.d.ts.map +0 -1
- package/dist/types/size.d.ts +0 -8
- package/dist/types/size.d.ts.map +0 -1
- package/dist/types/size.js +0 -2
- package/dist/v2/components/ecs-service/index.d.ts.map +0 -1
- package/dist/v2/components/ecs-service/policies.d.ts +0 -3
- package/dist/v2/components/ecs-service/policies.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/index.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/panels.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/types.d.ts.map +0 -1
- package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts.map +0 -1
- package/dist/v2/components/grafana/index.d.ts.map +0 -1
- package/dist/v2/components/prometheus/index.d.ts.map +0 -1
- package/dist/v2/components/prometheus/queries.d.ts.map +0 -1
- package/dist/v2/components/prometheus/queries.test.d.ts.map +0 -1
- package/dist/v2/components/web-server/builder.d.ts.map +0 -1
- package/dist/v2/components/web-server/index.d.ts.map +0 -1
- package/dist/v2/components/web-server/load-balancer.d.ts.map +0 -1
- package/dist/v2/index.d.ts +0 -13
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -16
- package/dist/v2/otel/batch-processor.d.ts.map +0 -1
- package/dist/v2/otel/builder.d.ts.map +0 -1
- package/dist/v2/otel/config.d.ts.map +0 -1
- package/dist/v2/otel/index.d.ts.map +0 -1
- package/dist/v2/otel/memory-limiter-processor.d.ts.map +0 -1
- package/dist/v2/otel/otlp-receiver.d.ts.map +0 -1
- package/dist/v2/otel/prometheus-remote-write-exporter.d.ts.map +0 -1
- /package/dist/{v2/components/grafana/dashboards → components/cloudfront}/types.js +0 -0
- /package/dist/{v2/components → components}/ecs-service/policies.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/index.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/index.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/panels.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/panels.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/types.d.ts +0 -0
- /package/dist/{types/pulumi.js → components/grafana/dashboards/types.js} +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/web-server-slo.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/web-server-slo.js +0 -0
- /package/dist/{v2/components → components}/grafana/index.d.ts +0 -0
- /package/dist/{v2/components → components}/grafana/index.js +0 -0
- /package/dist/{v2/components → components}/prometheus/index.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/index.js +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.js +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.test.d.ts +0 -0
- /package/dist/{v2/components → components}/prometheus/queries.test.js +0 -0
- /package/dist/{v2/otel → otel}/batch-processor.d.ts +0 -0
- /package/dist/{v2/otel → otel}/batch-processor.js +0 -0
- /package/dist/{v2/otel → otel}/index.js +0 -0
- /package/dist/{v2/otel → otel}/memory-limiter-processor.d.ts +0 -0
- /package/dist/{v2/otel → otel}/memory-limiter-processor.js +0 -0
- /package/dist/{v2/otel → otel}/otlp-receiver.d.ts +0 -0
- /package/dist/{v2/otel → otel}/otlp-receiver.js +0 -0
- /package/dist/{v2/otel → otel}/prometheus-remote-write-exporter.d.ts +0 -0
- /package/dist/{v2/otel → otel}/prometheus-remote-write-exporter.js +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Project = exports.MissingEcsCluster = void 0;
|
|
15
|
-
const pulumi = require("@pulumi/pulumi");
|
|
16
|
-
const aws = require("@pulumi/aws");
|
|
17
|
-
const awsx = require("@pulumi/awsx");
|
|
18
|
-
const upstash = require("@upstash/pulumi");
|
|
19
|
-
const database_1 = require("./database");
|
|
20
|
-
const web_server_1 = require("./web-server");
|
|
21
|
-
const mongo_1 = require("./mongo");
|
|
22
|
-
const redis_1 = require("./redis");
|
|
23
|
-
const static_site_1 = require("./static-site");
|
|
24
|
-
const ec2_ssm_connect_1 = require("./ec2-ssm-connect");
|
|
25
|
-
const constants_1 = require("../constants");
|
|
26
|
-
const ecs_service_1 = require("./ecs-service");
|
|
27
|
-
const nuxt_ssr_1 = require("./nuxt-ssr");
|
|
28
|
-
class MissingEcsCluster extends Error {
|
|
29
|
-
constructor() {
|
|
30
|
-
super('Ecs Cluster does not exist');
|
|
31
|
-
this.name = this.constructor.name;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.MissingEcsCluster = MissingEcsCluster;
|
|
35
|
-
class Project extends pulumi.ComponentResource {
|
|
36
|
-
constructor(name, args, opts = {}) {
|
|
37
|
-
super('studion:Project', name, {}, opts);
|
|
38
|
-
this.services = {};
|
|
39
|
-
this.name = name;
|
|
40
|
-
this.vpc = this.createVpc(args.numberOfAvailabilityZones);
|
|
41
|
-
this.createServices(args.services);
|
|
42
|
-
if (args.enableSSMConnect) {
|
|
43
|
-
this.ec2SSMConnect = new ec2_ssm_connect_1.Ec2SSMConnect(`${name}-ssm-connect`, {
|
|
44
|
-
vpcId: this.vpc.vpcId,
|
|
45
|
-
privateSubnetId: this.vpc.privateSubnetIds.apply(ids => ids[0]),
|
|
46
|
-
vpcCidrBlock: this.vpc.vpc.cidrBlock,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
this.registerOutputs();
|
|
50
|
-
}
|
|
51
|
-
createVpc(numberOfAvailabilityZones = 2) {
|
|
52
|
-
const vpc = new awsx.ec2.Vpc(`${this.name}-vpc`, {
|
|
53
|
-
numberOfAvailabilityZones,
|
|
54
|
-
enableDnsHostnames: true,
|
|
55
|
-
enableDnsSupport: true,
|
|
56
|
-
subnetSpecs: [
|
|
57
|
-
{ type: awsx.ec2.SubnetType.Public, cidrMask: 24 },
|
|
58
|
-
{ type: awsx.ec2.SubnetType.Private, cidrMask: 24 },
|
|
59
|
-
{ type: awsx.ec2.SubnetType.Isolated, cidrMask: 24 },
|
|
60
|
-
],
|
|
61
|
-
tags: constants_1.commonTags,
|
|
62
|
-
}, { parent: this });
|
|
63
|
-
return vpc;
|
|
64
|
-
}
|
|
65
|
-
createServices(services) {
|
|
66
|
-
const hasRedisService = services.some(it => it.type === 'REDIS');
|
|
67
|
-
const shouldCreateEcsCluster = services.some(it => it.type === 'WEB_SERVER' ||
|
|
68
|
-
it.type === 'NUXT_SSR' ||
|
|
69
|
-
it.type === 'MONGO' ||
|
|
70
|
-
it.type === 'ECS_SERVICE') && !this.cluster;
|
|
71
|
-
if (hasRedisService)
|
|
72
|
-
this.createRedisPrerequisites();
|
|
73
|
-
if (shouldCreateEcsCluster)
|
|
74
|
-
this.createEcsCluster();
|
|
75
|
-
services.forEach(it => {
|
|
76
|
-
if (it.type === 'DATABASE')
|
|
77
|
-
this.createDatabaseService(it);
|
|
78
|
-
if (it.type === 'REDIS')
|
|
79
|
-
this.createRedisService(it);
|
|
80
|
-
if (it.type === 'STATIC_SITE')
|
|
81
|
-
this.createStaticSiteService(it);
|
|
82
|
-
if (it.type === 'WEB_SERVER')
|
|
83
|
-
this.createWebServerService(it);
|
|
84
|
-
if (it.type === 'NUXT_SSR')
|
|
85
|
-
this.createNuxtSSRService(it);
|
|
86
|
-
if (it.type === 'MONGO')
|
|
87
|
-
this.createMongoService(it);
|
|
88
|
-
if (it.type === 'ECS_SERVICE')
|
|
89
|
-
this.createEcsService(it);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
createRedisPrerequisites() {
|
|
93
|
-
const upstashConfig = new pulumi.Config('upstash');
|
|
94
|
-
this.upstashProvider = new upstash.Provider('upstash', {
|
|
95
|
-
email: upstashConfig.requireSecret('email'),
|
|
96
|
-
apiKey: upstashConfig.requireSecret('apiKey'),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
createEcsCluster() {
|
|
100
|
-
const stack = pulumi.getStack();
|
|
101
|
-
this.cluster = new aws.ecs.Cluster(`${this.name}-cluster`, {
|
|
102
|
-
name: `${this.name}-${stack}`,
|
|
103
|
-
tags: constants_1.commonTags,
|
|
104
|
-
}, { parent: this });
|
|
105
|
-
}
|
|
106
|
-
createDatabaseService(options) {
|
|
107
|
-
const { serviceName, type } = options, databaseOptions = __rest(options, ["serviceName", "type"]);
|
|
108
|
-
const service = new database_1.Database(serviceName, Object.assign(Object.assign({}, databaseOptions), { vpcId: this.vpc.vpcId, isolatedSubnetIds: this.vpc.isolatedSubnetIds, vpcCidrBlock: this.vpc.vpc.cidrBlock }), { parent: this });
|
|
109
|
-
this.services[serviceName] = service;
|
|
110
|
-
}
|
|
111
|
-
createRedisService(options) {
|
|
112
|
-
if (!this.upstashProvider)
|
|
113
|
-
return;
|
|
114
|
-
const { serviceName } = options, redisOptions = __rest(options, ["serviceName"]);
|
|
115
|
-
const service = new redis_1.Redis(serviceName, redisOptions, {
|
|
116
|
-
parent: this,
|
|
117
|
-
provider: this.upstashProvider,
|
|
118
|
-
});
|
|
119
|
-
this.services[options.serviceName] = service;
|
|
120
|
-
}
|
|
121
|
-
createStaticSiteService(options) {
|
|
122
|
-
const { serviceName } = options, staticSiteOptions = __rest(options, ["serviceName"]);
|
|
123
|
-
const service = new static_site_1.StaticSite(serviceName, staticSiteOptions, {
|
|
124
|
-
parent: this,
|
|
125
|
-
});
|
|
126
|
-
this.services[serviceName] = service;
|
|
127
|
-
}
|
|
128
|
-
createWebServerService(options) {
|
|
129
|
-
if (!this.cluster)
|
|
130
|
-
throw new MissingEcsCluster();
|
|
131
|
-
const { serviceName, environment, secrets } = options, ecsOptions = __rest(options, ["serviceName", "environment", "secrets"]);
|
|
132
|
-
const parsedEnv = typeof environment === 'function'
|
|
133
|
-
? environment(this.services)
|
|
134
|
-
: environment;
|
|
135
|
-
const parsedSecrets = typeof secrets === 'function' ? secrets(this.services) : secrets;
|
|
136
|
-
const service = new web_server_1.WebServer(serviceName, Object.assign(Object.assign({}, ecsOptions), { clusterId: this.cluster.id, clusterName: this.cluster.name, vpcId: this.vpc.vpcId, vpcCidrBlock: this.vpc.vpc.cidrBlock, publicSubnetIds: this.vpc.publicSubnetIds, environment: parsedEnv, secrets: parsedSecrets }), { parent: this });
|
|
137
|
-
this.services[options.serviceName] = service;
|
|
138
|
-
}
|
|
139
|
-
createNuxtSSRService(options) {
|
|
140
|
-
if (!this.cluster)
|
|
141
|
-
throw new MissingEcsCluster();
|
|
142
|
-
const { serviceName, environment, secrets } = options, ecsOptions = __rest(options, ["serviceName", "environment", "secrets"]);
|
|
143
|
-
const parsedEnv = typeof environment === 'function'
|
|
144
|
-
? environment(this.services)
|
|
145
|
-
: environment;
|
|
146
|
-
const parsedSecrets = typeof secrets === 'function' ? secrets(this.services) : secrets;
|
|
147
|
-
const service = new nuxt_ssr_1.NuxtSSR(serviceName, Object.assign(Object.assign({}, ecsOptions), { clusterId: this.cluster.id, clusterName: this.cluster.name, vpcId: this.vpc.vpcId, vpcCidrBlock: this.vpc.vpc.cidrBlock, publicSubnetIds: this.vpc.publicSubnetIds, environment: parsedEnv, secrets: parsedSecrets }), { parent: this });
|
|
148
|
-
this.services[options.serviceName] = service;
|
|
149
|
-
}
|
|
150
|
-
createMongoService(options) {
|
|
151
|
-
if (!this.cluster)
|
|
152
|
-
throw new MissingEcsCluster();
|
|
153
|
-
const { serviceName } = options, mongoOptions = __rest(options, ["serviceName"]);
|
|
154
|
-
const service = new mongo_1.Mongo(serviceName, Object.assign(Object.assign({}, mongoOptions), { clusterId: this.cluster.id, clusterName: this.cluster.name, vpcId: this.vpc.vpcId, vpcCidrBlock: this.vpc.vpc.cidrBlock, privateSubnetIds: this.vpc.privateSubnetIds }), { parent: this });
|
|
155
|
-
this.services[options.serviceName] = service;
|
|
156
|
-
}
|
|
157
|
-
createEcsService(options) {
|
|
158
|
-
if (!this.cluster)
|
|
159
|
-
throw new MissingEcsCluster();
|
|
160
|
-
const { serviceName, environment, secrets } = options, ecsOptions = __rest(options, ["serviceName", "environment", "secrets"]);
|
|
161
|
-
const parsedEnv = typeof environment === 'function'
|
|
162
|
-
? environment(this.services)
|
|
163
|
-
: environment;
|
|
164
|
-
const parsedSecrets = typeof secrets === 'function' ? secrets(this.services) : secrets;
|
|
165
|
-
const service = new ecs_service_1.EcsService(serviceName, Object.assign(Object.assign({}, ecsOptions), { clusterId: this.cluster.id, clusterName: this.cluster.name, vpcId: this.vpc.vpcId, vpcCidrBlock: this.vpc.vpc.cidrBlock, subnetIds: ecsOptions.assignPublicIp
|
|
166
|
-
? this.vpc.publicSubnetIds
|
|
167
|
-
: this.vpc.privateSubnetIds, environment: parsedEnv, secrets: parsedSecrets }), { parent: this });
|
|
168
|
-
this.services[options.serviceName] = service;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.Project = Project;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as upstash from '@upstash/pulumi';
|
|
3
|
-
import * as aws from '@pulumi/aws';
|
|
4
|
-
export type RedisArgs = {
|
|
5
|
-
/**
|
|
6
|
-
* Redis database name.
|
|
7
|
-
*/
|
|
8
|
-
dbName: pulumi.Input<string>;
|
|
9
|
-
/**
|
|
10
|
-
* Region of the database. Possible values are: "global", "eu-west-1", "us-east-1", "us-west-1", "ap-northeast-1" , "eu-central1".
|
|
11
|
-
*/
|
|
12
|
-
region?: pulumi.Input<string>;
|
|
13
|
-
};
|
|
14
|
-
export interface RedisOptions extends pulumi.ComponentResourceOptions {
|
|
15
|
-
provider: upstash.Provider;
|
|
16
|
-
}
|
|
17
|
-
export declare class Redis extends pulumi.ComponentResource {
|
|
18
|
-
instance: upstash.RedisDatabase;
|
|
19
|
-
passwordSecret: aws.secretsmanager.Secret;
|
|
20
|
-
username: string;
|
|
21
|
-
constructor(name: string, args: RedisArgs, opts: RedisOptions);
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/components/redis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAGnC,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAMF,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,wBAAwB;IACnE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;CAC5B;AAED,qBAAa,KAAM,SAAQ,MAAM,CAAC,iBAAiB;IACjD,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC;IAChC,cAAc,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC;IAC1C,QAAQ,SAAa;gBAET,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY;CAuC9D"}
|
package/dist/components/redis.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Redis = void 0;
|
|
4
|
-
const pulumi = require("@pulumi/pulumi");
|
|
5
|
-
const upstash = require("@upstash/pulumi");
|
|
6
|
-
const aws = require("@pulumi/aws");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const defaults = {
|
|
9
|
-
region: 'us-east-1',
|
|
10
|
-
};
|
|
11
|
-
class Redis extends pulumi.ComponentResource {
|
|
12
|
-
constructor(name, args, opts) {
|
|
13
|
-
super('studion:Redis', name, {}, opts);
|
|
14
|
-
this.username = 'default';
|
|
15
|
-
const project = pulumi.getProject();
|
|
16
|
-
const stack = pulumi.getStack();
|
|
17
|
-
const argsWithDefaults = Object.assign({}, defaults, args);
|
|
18
|
-
this.instance = new upstash.RedisDatabase(name, {
|
|
19
|
-
databaseName: `${argsWithDefaults.dbName}-${stack}`,
|
|
20
|
-
region: argsWithDefaults.region,
|
|
21
|
-
eviction: true,
|
|
22
|
-
tls: true,
|
|
23
|
-
}, { provider: opts.provider, parent: this });
|
|
24
|
-
this.passwordSecret = new aws.secretsmanager.Secret(`${name}-password-secret`, {
|
|
25
|
-
namePrefix: `${stack}/${project}/RedisPassword-`,
|
|
26
|
-
tags: constants_1.commonTags,
|
|
27
|
-
}, { parent: this, dependsOn: [this.instance] });
|
|
28
|
-
const passwordSecretValue = new aws.secretsmanager.SecretVersion(`${name}-password-secret-value`, {
|
|
29
|
-
secretId: this.passwordSecret.id,
|
|
30
|
-
secretString: this.instance.password,
|
|
31
|
-
}, { parent: this, dependsOn: [this.passwordSecret] });
|
|
32
|
-
this.registerOutputs();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Redis = Redis;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as aws from '@pulumi/aws';
|
|
2
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
3
|
-
import { AcmCertificate } from './acm-certificate';
|
|
4
|
-
export type StaticSiteArgs = {
|
|
5
|
-
/**
|
|
6
|
-
* The domain which will be used to access the static site.
|
|
7
|
-
* The domain or subdomain must belong to the provided hostedZone.
|
|
8
|
-
*/
|
|
9
|
-
domain?: pulumi.Input<string>;
|
|
10
|
-
/**
|
|
11
|
-
* The ID of the hosted zone.
|
|
12
|
-
*/
|
|
13
|
-
hostedZoneId?: pulumi.Input<string>;
|
|
14
|
-
/**
|
|
15
|
-
* ARN of the CloudFront viewer-request function.
|
|
16
|
-
*/
|
|
17
|
-
viewerRequestFunctionArn?: pulumi.Input<string>;
|
|
18
|
-
/**
|
|
19
|
-
* A map of tags to assign to the resource.
|
|
20
|
-
*/
|
|
21
|
-
tags?: pulumi.Input<{
|
|
22
|
-
[key: string]: pulumi.Input<string>;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
export declare class StaticSite extends pulumi.ComponentResource {
|
|
26
|
-
name: string;
|
|
27
|
-
certificate?: AcmCertificate;
|
|
28
|
-
bucket: aws.s3.Bucket;
|
|
29
|
-
cloudfront: aws.cloudfront.Distribution;
|
|
30
|
-
constructor(name: string, args: StaticSiteArgs, opts?: pulumi.ComponentResourceOptions);
|
|
31
|
-
private createTlsCertificate;
|
|
32
|
-
private createPublicBucket;
|
|
33
|
-
private createCloudfrontDistribution;
|
|
34
|
-
private createDnsRecord;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=static-site.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-site.d.ts","sourceRoot":"","sources":["../../src/components/static-site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KACrC,CAAC,CAAC;CACJ,CAAC;AAEF,qBAAa,UAAW,SAAQ,MAAM,CAAC,iBAAiB;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC;IACtB,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;gBAGtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,IAAI,GAAE,MAAM,CAAC,wBAA6B;IA4B5C,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,kBAAkB;IAoD1B,OAAO,CAAC,4BAA4B;IA0EpC,OAAO,CAAC,eAAe;CAsBxB"}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StaticSite = void 0;
|
|
4
|
-
const aws = require("@pulumi/aws");
|
|
5
|
-
const pulumi = require("@pulumi/pulumi");
|
|
6
|
-
const acm_certificate_1 = require("./acm-certificate");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
class StaticSite extends pulumi.ComponentResource {
|
|
9
|
-
constructor(name, args, opts = {}) {
|
|
10
|
-
super('studion:StaticSite', name, {}, opts);
|
|
11
|
-
this.name = name;
|
|
12
|
-
const { domain, hostedZoneId, viewerRequestFunctionArn, tags } = args;
|
|
13
|
-
const hasCustomDomain = domain && hostedZoneId;
|
|
14
|
-
if (domain && !hostedZoneId) {
|
|
15
|
-
throw new Error('StaticSite:hostedZoneId must be provided when the domain is specified');
|
|
16
|
-
}
|
|
17
|
-
if (hasCustomDomain) {
|
|
18
|
-
this.certificate = this.createTlsCertificate({ domain, hostedZoneId });
|
|
19
|
-
}
|
|
20
|
-
this.bucket = this.createPublicBucket({ tags });
|
|
21
|
-
this.cloudfront = this.createCloudfrontDistribution({
|
|
22
|
-
domain,
|
|
23
|
-
viewerRequestFunctionArn,
|
|
24
|
-
tags,
|
|
25
|
-
});
|
|
26
|
-
if (hasCustomDomain) {
|
|
27
|
-
this.createDnsRecord({ domain, hostedZoneId });
|
|
28
|
-
}
|
|
29
|
-
this.registerOutputs();
|
|
30
|
-
}
|
|
31
|
-
createTlsCertificate({ domain, hostedZoneId, }) {
|
|
32
|
-
const certificate = new acm_certificate_1.AcmCertificate(`${domain}-acm-certificate`, {
|
|
33
|
-
domain,
|
|
34
|
-
hostedZoneId,
|
|
35
|
-
}, { parent: this });
|
|
36
|
-
return certificate;
|
|
37
|
-
}
|
|
38
|
-
createPublicBucket({ tags }) {
|
|
39
|
-
const bucket = new aws.s3.Bucket(`${this.name}-bucket`, {
|
|
40
|
-
bucketPrefix: `${this.name}-`,
|
|
41
|
-
website: {
|
|
42
|
-
indexDocument: 'index.html',
|
|
43
|
-
errorDocument: 'index.html',
|
|
44
|
-
},
|
|
45
|
-
tags: Object.assign(Object.assign({}, constants_1.commonTags), tags),
|
|
46
|
-
}, { parent: this });
|
|
47
|
-
const bucketPublicAccessBlock = new aws.s3.BucketPublicAccessBlock(`${this.name}-bucket-access-block`, {
|
|
48
|
-
bucket: bucket.id,
|
|
49
|
-
blockPublicAcls: false,
|
|
50
|
-
blockPublicPolicy: false,
|
|
51
|
-
ignorePublicAcls: false,
|
|
52
|
-
restrictPublicBuckets: false,
|
|
53
|
-
}, { parent: this });
|
|
54
|
-
const siteBucketPolicy = new aws.s3.BucketPolicy(`${this.name}-bucket-policy`, {
|
|
55
|
-
bucket: bucket.bucket,
|
|
56
|
-
policy: bucket.bucket.apply(publicReadPolicy),
|
|
57
|
-
}, { parent: this, dependsOn: [bucketPublicAccessBlock] });
|
|
58
|
-
function publicReadPolicy(bucketName) {
|
|
59
|
-
return {
|
|
60
|
-
Version: '2012-10-17',
|
|
61
|
-
Statement: [
|
|
62
|
-
{
|
|
63
|
-
Effect: 'Allow',
|
|
64
|
-
Principal: '*',
|
|
65
|
-
Action: ['s3:GetObject'],
|
|
66
|
-
Resource: [`arn:aws:s3:::${bucketName}/*`],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return bucket;
|
|
72
|
-
}
|
|
73
|
-
createCloudfrontDistribution({ domain, viewerRequestFunctionArn, tags, }) {
|
|
74
|
-
const functionAssociations = viewerRequestFunctionArn
|
|
75
|
-
? [
|
|
76
|
-
{
|
|
77
|
-
eventType: 'viewer-request',
|
|
78
|
-
functionArn: viewerRequestFunctionArn,
|
|
79
|
-
},
|
|
80
|
-
]
|
|
81
|
-
: [];
|
|
82
|
-
const cloudfront = new aws.cloudfront.Distribution(`${this.name}-cloudfront`, Object.assign(Object.assign({ enabled: true, defaultRootObject: 'index.html' }, (domain && { aliases: [domain] })), { isIpv6Enabled: true, waitForDeployment: true, httpVersion: 'http2and3', viewerCertificate: Object.assign({}, (this.certificate
|
|
83
|
-
? {
|
|
84
|
-
acmCertificateArn: this.certificate.certificate.arn,
|
|
85
|
-
sslSupportMethod: 'sni-only',
|
|
86
|
-
minimumProtocolVersion: 'TLSv1.2_2021',
|
|
87
|
-
}
|
|
88
|
-
: {
|
|
89
|
-
cloudfrontDefaultCertificate: true,
|
|
90
|
-
})), origins: [
|
|
91
|
-
{
|
|
92
|
-
originId: this.bucket.arn,
|
|
93
|
-
domainName: this.bucket.websiteEndpoint,
|
|
94
|
-
connectionAttempts: 3,
|
|
95
|
-
connectionTimeout: 10,
|
|
96
|
-
customOriginConfig: {
|
|
97
|
-
originProtocolPolicy: 'http-only',
|
|
98
|
-
httpPort: 80,
|
|
99
|
-
httpsPort: 443,
|
|
100
|
-
originSslProtocols: ['TLSv1.2'],
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
], defaultCacheBehavior: {
|
|
104
|
-
targetOriginId: this.bucket.arn,
|
|
105
|
-
viewerProtocolPolicy: 'redirect-to-https',
|
|
106
|
-
allowedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
107
|
-
cachedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
108
|
-
compress: true,
|
|
109
|
-
defaultTtl: 86400,
|
|
110
|
-
minTtl: 1,
|
|
111
|
-
maxTtl: 31536000,
|
|
112
|
-
forwardedValues: {
|
|
113
|
-
cookies: { forward: 'none' },
|
|
114
|
-
queryString: false,
|
|
115
|
-
},
|
|
116
|
-
functionAssociations,
|
|
117
|
-
}, priceClass: 'PriceClass_100', restrictions: {
|
|
118
|
-
geoRestriction: { restrictionType: 'none' },
|
|
119
|
-
}, tags: Object.assign(Object.assign({}, constants_1.commonTags), tags) }), { parent: this });
|
|
120
|
-
return cloudfront;
|
|
121
|
-
}
|
|
122
|
-
createDnsRecord({ domain, hostedZoneId, }) {
|
|
123
|
-
const cdnAliasRecord = new aws.route53.Record(`${this.name}-cdn-route53-record`, {
|
|
124
|
-
type: 'A',
|
|
125
|
-
name: domain,
|
|
126
|
-
zoneId: hostedZoneId,
|
|
127
|
-
aliases: [
|
|
128
|
-
{
|
|
129
|
-
name: this.cloudfront.domainName,
|
|
130
|
-
zoneId: this.cloudfront.hostedZoneId,
|
|
131
|
-
evaluateTargetHealth: true,
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
}, { parent: this });
|
|
135
|
-
return cdnAliasRecord;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.StaticSite = StaticSite;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as aws from '@pulumi/aws';
|
|
3
|
-
import { AcmCertificate } from './acm-certificate';
|
|
4
|
-
import { EcsService, EcsServiceArgs } from './ecs-service';
|
|
5
|
-
export type WebServerArgs = Pick<EcsServiceArgs, 'image' | 'port' | 'clusterId' | 'clusterName' | 'vpcId' | 'vpcCidrBlock' | 'desiredCount' | 'autoscaling' | 'size' | 'environment' | 'secrets' | 'persistentStorageConfig' | 'taskExecutionRoleInlinePolicies' | 'taskRoleInlinePolicies' | 'tags'> & {
|
|
6
|
-
publicSubnetIds: pulumi.Input<pulumi.Input<string>[]>;
|
|
7
|
-
/**
|
|
8
|
-
* The domain which will be used to access the service.
|
|
9
|
-
* The domain or subdomain must belong to the provided hostedZone.
|
|
10
|
-
*/
|
|
11
|
-
domain?: pulumi.Input<string>;
|
|
12
|
-
/**
|
|
13
|
-
* The ID of the hosted zone.
|
|
14
|
-
*/
|
|
15
|
-
hostedZoneId?: pulumi.Input<string>;
|
|
16
|
-
/**
|
|
17
|
-
* Path for the health check request. Defaults to "/healthcheck".
|
|
18
|
-
*/
|
|
19
|
-
healthCheckPath?: pulumi.Input<string>;
|
|
20
|
-
};
|
|
21
|
-
export declare class WebServer extends pulumi.ComponentResource {
|
|
22
|
-
name: string;
|
|
23
|
-
service: EcsService;
|
|
24
|
-
lbSecurityGroup: aws.ec2.SecurityGroup;
|
|
25
|
-
serviceSecurityGroup: aws.ec2.SecurityGroup;
|
|
26
|
-
lb: aws.lb.LoadBalancer;
|
|
27
|
-
lbTargetGroup: aws.lb.TargetGroup;
|
|
28
|
-
lbHttpListener: aws.lb.Listener;
|
|
29
|
-
certificate?: AcmCertificate;
|
|
30
|
-
lbTlsListener?: aws.lb.Listener;
|
|
31
|
-
constructor(name: string, args: WebServerArgs, opts?: pulumi.ComponentResourceOptions);
|
|
32
|
-
private createTlsCertificate;
|
|
33
|
-
private createLoadBalancer;
|
|
34
|
-
private createSecurityGroup;
|
|
35
|
-
private createEcsService;
|
|
36
|
-
private createDnsRecord;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=web-server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-server.d.ts","sourceRoot":"","sources":["../../src/components/web-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,cAAc,EACZ,OAAO,GACP,MAAM,GACN,WAAW,GACX,aAAa,GACb,OAAO,GACP,cAAc,GACd,cAAc,GACd,aAAa,GACb,MAAM,GACN,aAAa,GACb,SAAS,GACT,yBAAyB,GACzB,iCAAiC,GACjC,wBAAwB,GACxB,MAAM,CACT,GAAG;IACF,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAMF,qBAAa,SAAU,SAAQ,MAAM,CAAC,iBAAiB;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,UAAU,CAAC;IACpB,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC;IACvC,oBAAoB,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC;IAC5C,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC;IACxB,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC;IAChC,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC;gBAG9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,EACnB,IAAI,GAAE,MAAM,CAAC,wBAA6B;IA2C5C,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,kBAAkB;IAkI1B,OAAO,CAAC,mBAAmB;IA4B3B,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,eAAe;CAqBxB"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebServer = void 0;
|
|
4
|
-
const pulumi = require("@pulumi/pulumi");
|
|
5
|
-
const aws = require("@pulumi/aws");
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const acm_certificate_1 = require("./acm-certificate");
|
|
8
|
-
const ecs_service_1 = require("./ecs-service");
|
|
9
|
-
const defaults = {
|
|
10
|
-
healthCheckPath: '/healthcheck',
|
|
11
|
-
};
|
|
12
|
-
class WebServer extends pulumi.ComponentResource {
|
|
13
|
-
constructor(name, args, opts = {}) {
|
|
14
|
-
const aliases = opts.aliases || [];
|
|
15
|
-
super('studion:LegacyWebServer', name, args, Object.assign(Object.assign({}, opts), { aliases: [...aliases, { type: 'studion:WebServer' }] }));
|
|
16
|
-
const { vpcId, domain, hostedZoneId } = args;
|
|
17
|
-
const hasCustomDomain = !!domain && !!hostedZoneId;
|
|
18
|
-
if (domain && !hostedZoneId) {
|
|
19
|
-
throw new Error('WebServer:hostedZoneId must be provided when the domain is specified');
|
|
20
|
-
}
|
|
21
|
-
this.name = name;
|
|
22
|
-
if (hasCustomDomain) {
|
|
23
|
-
this.certificate = this.createTlsCertificate({ domain, hostedZoneId });
|
|
24
|
-
}
|
|
25
|
-
const { lb, lbTargetGroup, lbHttpListener, lbTlsListener, lbSecurityGroup, } = this.createLoadBalancer(args);
|
|
26
|
-
this.lb = lb;
|
|
27
|
-
this.lbTargetGroup = lbTargetGroup;
|
|
28
|
-
this.lbHttpListener = lbHttpListener;
|
|
29
|
-
this.lbTlsListener = lbTlsListener;
|
|
30
|
-
this.lbSecurityGroup = lbSecurityGroup;
|
|
31
|
-
this.serviceSecurityGroup = this.createSecurityGroup(vpcId);
|
|
32
|
-
this.service = this.createEcsService(args);
|
|
33
|
-
if (hasCustomDomain) {
|
|
34
|
-
this.createDnsRecord({ domain, hostedZoneId });
|
|
35
|
-
}
|
|
36
|
-
this.registerOutputs();
|
|
37
|
-
}
|
|
38
|
-
createTlsCertificate({ domain, hostedZoneId, }) {
|
|
39
|
-
const certificate = new acm_certificate_1.AcmCertificate(`${domain}-acm-certificate`, {
|
|
40
|
-
domain,
|
|
41
|
-
hostedZoneId,
|
|
42
|
-
}, { parent: this });
|
|
43
|
-
return certificate;
|
|
44
|
-
}
|
|
45
|
-
createLoadBalancer({ vpcId, publicSubnetIds, port, healthCheckPath, }) {
|
|
46
|
-
const lbSecurityGroup = new aws.ec2.SecurityGroup(`${this.name}-lb-security-group`, {
|
|
47
|
-
vpcId,
|
|
48
|
-
ingress: [
|
|
49
|
-
{
|
|
50
|
-
protocol: 'tcp',
|
|
51
|
-
fromPort: 80,
|
|
52
|
-
toPort: 80,
|
|
53
|
-
cidrBlocks: ['0.0.0.0/0'],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
protocol: 'tcp',
|
|
57
|
-
fromPort: 443,
|
|
58
|
-
toPort: 443,
|
|
59
|
-
cidrBlocks: ['0.0.0.0/0'],
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
egress: [
|
|
63
|
-
{
|
|
64
|
-
fromPort: 0,
|
|
65
|
-
toPort: 0,
|
|
66
|
-
protocol: '-1',
|
|
67
|
-
cidrBlocks: ['0.0.0.0/0'],
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
tags: constants_1.commonTags,
|
|
71
|
-
}, { parent: this });
|
|
72
|
-
const lb = new aws.lb.LoadBalancer(`${this.name}-lb`, {
|
|
73
|
-
namePrefix: 'lb-',
|
|
74
|
-
loadBalancerType: 'application',
|
|
75
|
-
subnets: publicSubnetIds,
|
|
76
|
-
securityGroups: [lbSecurityGroup.id],
|
|
77
|
-
internal: false,
|
|
78
|
-
ipAddressType: 'ipv4',
|
|
79
|
-
tags: Object.assign(Object.assign({}, constants_1.commonTags), { Name: `${this.name}-lb` }),
|
|
80
|
-
}, { parent: this });
|
|
81
|
-
const lbTargetGroup = new aws.lb.TargetGroup(`${this.name}-lb-tg`, {
|
|
82
|
-
namePrefix: 'lb-tg-',
|
|
83
|
-
port,
|
|
84
|
-
protocol: 'HTTP',
|
|
85
|
-
targetType: 'ip',
|
|
86
|
-
vpcId,
|
|
87
|
-
healthCheck: {
|
|
88
|
-
healthyThreshold: 3,
|
|
89
|
-
unhealthyThreshold: 2,
|
|
90
|
-
interval: 60,
|
|
91
|
-
timeout: 5,
|
|
92
|
-
path: healthCheckPath || defaults.healthCheckPath,
|
|
93
|
-
},
|
|
94
|
-
tags: Object.assign(Object.assign({}, constants_1.commonTags), { Name: `${this.name}-lb-target-group` }),
|
|
95
|
-
}, { parent: this, dependsOn: [this.lb] });
|
|
96
|
-
const defaultAction = this.certificate
|
|
97
|
-
? {
|
|
98
|
-
type: 'redirect',
|
|
99
|
-
redirect: {
|
|
100
|
-
port: '443',
|
|
101
|
-
protocol: 'HTTPS',
|
|
102
|
-
statusCode: 'HTTP_301',
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
: {
|
|
106
|
-
type: 'forward',
|
|
107
|
-
targetGroupArn: lbTargetGroup.arn,
|
|
108
|
-
};
|
|
109
|
-
const lbHttpListener = new aws.lb.Listener(`${this.name}-lb-listener-80`, {
|
|
110
|
-
loadBalancerArn: lb.arn,
|
|
111
|
-
port: 80,
|
|
112
|
-
defaultActions: [defaultAction],
|
|
113
|
-
tags: constants_1.commonTags,
|
|
114
|
-
}, { parent: this });
|
|
115
|
-
let lbTlsListener = undefined;
|
|
116
|
-
if (this.certificate) {
|
|
117
|
-
lbTlsListener = new aws.lb.Listener(`${this.name}-lb-listener-443`, {
|
|
118
|
-
loadBalancerArn: lb.arn,
|
|
119
|
-
port: 443,
|
|
120
|
-
protocol: 'HTTPS',
|
|
121
|
-
sslPolicy: 'ELBSecurityPolicy-2016-08',
|
|
122
|
-
certificateArn: this.certificate.certificate.arn,
|
|
123
|
-
defaultActions: [
|
|
124
|
-
{
|
|
125
|
-
type: 'forward',
|
|
126
|
-
targetGroupArn: lbTargetGroup.arn,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
tags: constants_1.commonTags,
|
|
130
|
-
}, { parent: this, dependsOn: [this.certificate] });
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
lb,
|
|
134
|
-
lbTargetGroup,
|
|
135
|
-
lbHttpListener,
|
|
136
|
-
lbTlsListener,
|
|
137
|
-
lbSecurityGroup,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
createSecurityGroup(vpcId) {
|
|
141
|
-
const securityGroup = new aws.ec2.SecurityGroup(`${this.name}-security-group`, {
|
|
142
|
-
vpcId,
|
|
143
|
-
ingress: [
|
|
144
|
-
{
|
|
145
|
-
fromPort: 0,
|
|
146
|
-
toPort: 0,
|
|
147
|
-
protocol: '-1',
|
|
148
|
-
securityGroups: [this.lbSecurityGroup.id],
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
egress: [
|
|
152
|
-
{
|
|
153
|
-
fromPort: 0,
|
|
154
|
-
toPort: 0,
|
|
155
|
-
protocol: '-1',
|
|
156
|
-
cidrBlocks: ['0.0.0.0/0'],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
tags: constants_1.commonTags,
|
|
160
|
-
}, { parent: this });
|
|
161
|
-
return securityGroup;
|
|
162
|
-
}
|
|
163
|
-
createEcsService(args) {
|
|
164
|
-
const service = new ecs_service_1.EcsService(this.name, Object.assign(Object.assign({}, args), { enableServiceAutoDiscovery: false, lbTargetGroupArn: this.lbTargetGroup.arn, assignPublicIp: true, subnetIds: args.publicSubnetIds, securityGroup: this.serviceSecurityGroup }), {
|
|
165
|
-
parent: this,
|
|
166
|
-
dependsOn: [this.lb, this.lbTargetGroup],
|
|
167
|
-
});
|
|
168
|
-
return service;
|
|
169
|
-
}
|
|
170
|
-
createDnsRecord({ domain, hostedZoneId, }) {
|
|
171
|
-
const albAliasRecord = new aws.route53.Record(`${this.name}-route53-record`, {
|
|
172
|
-
type: 'A',
|
|
173
|
-
name: domain,
|
|
174
|
-
zoneId: hostedZoneId,
|
|
175
|
-
aliases: [
|
|
176
|
-
{
|
|
177
|
-
name: this.lb.dnsName,
|
|
178
|
-
zoneId: this.lb.zoneId,
|
|
179
|
-
evaluateTargetHealth: true,
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
}, { parent: this });
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exports.WebServer = WebServer;
|
package/dist/constants.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export declare const PredefinedSize: {
|
|
2
|
-
readonly small: {
|
|
3
|
-
readonly cpu: number;
|
|
4
|
-
readonly memory: number;
|
|
5
|
-
};
|
|
6
|
-
readonly medium: {
|
|
7
|
-
readonly cpu: number;
|
|
8
|
-
readonly memory: 1024;
|
|
9
|
-
};
|
|
10
|
-
readonly large: {
|
|
11
|
-
readonly cpu: 1024;
|
|
12
|
-
readonly memory: number;
|
|
13
|
-
};
|
|
14
|
-
readonly xlarge: {
|
|
15
|
-
readonly cpu: number;
|
|
16
|
-
readonly memory: number;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare const commonTags: {
|
|
20
|
-
Env: string;
|
|
21
|
-
Project: string;
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;CAiBjB,CAAC;AAEX,eAAO,MAAM,UAAU;;;CAGtB,CAAC"}
|