@studion/infra-code-blocks 0.8.0-next.1 → 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/README.md +7 -5
- 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 +11 -5
- package/dist/components/ecs-service/index.d.ts.map +1 -0
- package/dist/{v2/components → components}/ecs-service/index.js +22 -32
- 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 +3 -0
- package/dist/components/grafana/dashboards/index.d.ts.map +1 -0
- package/dist/components/grafana/dashboards/panels.d.ts.map +1 -0
- package/dist/{v2/components → components}/grafana/dashboards/panels.js +38 -28
- 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/{v2/components → components}/grafana/dashboards/web-server-slo.js +13 -16
- 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 +12 -1
- package/dist/{v2/components → components}/web-server/index.d.ts +31 -9
- package/dist/components/web-server/index.d.ts.map +1 -0
- package/dist/components/web-server/index.js +190 -0
- 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 +39 -26
- 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}/batch-processor.js +1 -1
- 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 +59 -12
- 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 +33 -17
- 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/{v2/otel → otel}/memory-limiter-processor.js +1 -1
- package/dist/otel/otlp-receiver.d.ts.map +1 -0
- package/dist/{v2/otel → otel}/otlp-receiver.js +3 -3
- 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 +37 -24
- 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 -358
- package/dist/components/mongo.d.ts +0 -39
- package/dist/components/mongo.d.ts.map +0 -1
- package/dist/components/mongo.js +0 -52
- 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 +0 -3
- 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/index.js +0 -169
- 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.js +0 -0
- /package/dist/{v2/components → components}/grafana/dashboards/panels.d.ts +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/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}/index.js +0 -0
- /package/dist/{v2/otel → otel}/memory-limiter-processor.d.ts +0 -0
- /package/dist/{v2/otel → otel}/otlp-receiver.d.ts +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
|
@@ -0,0 +1,190 @@
|
|
|
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-v7");
|
|
6
|
+
const common_tags_1 = require("../../shared/common-tags");
|
|
7
|
+
const acm_certificate_1 = require("../acm-certificate");
|
|
8
|
+
const ecs_service_1 = require("../ecs-service");
|
|
9
|
+
const load_balancer_1 = require("./load-balancer");
|
|
10
|
+
class WebServer extends pulumi.ComponentResource {
|
|
11
|
+
constructor(name, args, opts = {}) {
|
|
12
|
+
var _a;
|
|
13
|
+
super('studion:web-server:WebServer', name, args, Object.assign(Object.assign({}, opts), { aliases: [...(opts.aliases || []), { type: 'studion:WebServer' }] }));
|
|
14
|
+
const { vpc, domain, hostedZoneId, certificate } = args;
|
|
15
|
+
const hasCustomDomain = !!domain || !!certificate;
|
|
16
|
+
if (hasCustomDomain && !hostedZoneId) {
|
|
17
|
+
throw new Error('Provide `hostedZoneId` alongside `domain` and/or `certificate`.');
|
|
18
|
+
}
|
|
19
|
+
if (domain && hostedZoneId && !certificate) {
|
|
20
|
+
this.acmCertificate = this.createTlsCertificate({ domain, hostedZoneId });
|
|
21
|
+
}
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.lb = new load_balancer_1.WebServerLoadBalancer(`${this.name}-lb`, {
|
|
24
|
+
vpc,
|
|
25
|
+
port: args.port,
|
|
26
|
+
certificate: certificate !== null && certificate !== void 0 ? certificate : (_a = this.acmCertificate) === null || _a === void 0 ? void 0 : _a.certificate,
|
|
27
|
+
healthCheckPath: args.healthCheckPath,
|
|
28
|
+
loadBalancingAlgorithmType: args.loadBalancingAlgorithmType,
|
|
29
|
+
}, Object.assign({ parent: this }, (this.acmCertificate
|
|
30
|
+
? { dependsOn: [this.acmCertificate.certificateValidation] }
|
|
31
|
+
: undefined)));
|
|
32
|
+
this.serviceSecurityGroup = this.createSecurityGroup(vpc);
|
|
33
|
+
this.initContainers = this.getInitContainers(args);
|
|
34
|
+
this.sidecarContainers = this.getSidecarContainers(args);
|
|
35
|
+
this.container = this.createWebServerContainer(args);
|
|
36
|
+
this.ecsConfig = this.createEcsConfig(args);
|
|
37
|
+
this.volumes = this.getVolumes(args);
|
|
38
|
+
this.service = this.createEcsService(this.container, this.lb, this.ecsConfig, this.volumes, this.initContainers, this.sidecarContainers);
|
|
39
|
+
if (hasCustomDomain && hostedZoneId) {
|
|
40
|
+
this.dnsRecords = this.createDnsRecords(certificate !== null && certificate !== void 0 ? certificate : this.acmCertificate.certificate, hostedZoneId, domain);
|
|
41
|
+
}
|
|
42
|
+
this.registerOutputs();
|
|
43
|
+
}
|
|
44
|
+
getVolumes(args) {
|
|
45
|
+
return pulumi
|
|
46
|
+
.all([pulumi.output(args.volumes), args.otelCollector])
|
|
47
|
+
.apply(([passedVolumes, otelCollector]) => {
|
|
48
|
+
const volumes = [];
|
|
49
|
+
if (passedVolumes)
|
|
50
|
+
volumes.push(...passedVolumes);
|
|
51
|
+
if (otelCollector)
|
|
52
|
+
volumes.push({ name: otelCollector.configVolume });
|
|
53
|
+
return volumes;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getInitContainers(args) {
|
|
57
|
+
return pulumi
|
|
58
|
+
.all([pulumi.output(args.initContainers), args.otelCollector])
|
|
59
|
+
.apply(([passedInits, otelCollector]) => {
|
|
60
|
+
const containers = [];
|
|
61
|
+
if (passedInits)
|
|
62
|
+
containers.push(...passedInits);
|
|
63
|
+
if (otelCollector)
|
|
64
|
+
containers.push(otelCollector.configContainer);
|
|
65
|
+
return containers.map(container => (Object.assign(Object.assign({}, container), { essential: false })));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getSidecarContainers(args) {
|
|
69
|
+
return pulumi
|
|
70
|
+
.all([pulumi.output(args.sidecarContainers), args.otelCollector])
|
|
71
|
+
.apply(([passedSidecars, otelCollector]) => {
|
|
72
|
+
const containers = [];
|
|
73
|
+
if (passedSidecars)
|
|
74
|
+
containers.push(...passedSidecars);
|
|
75
|
+
if (otelCollector)
|
|
76
|
+
containers.push(otelCollector.container);
|
|
77
|
+
return containers.map(container => (Object.assign(Object.assign({}, container), { essential: true })));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
getTaskRoleInlinePolicies(args) {
|
|
81
|
+
return pulumi
|
|
82
|
+
.all([
|
|
83
|
+
pulumi.output(args.taskExecutionRoleInlinePolicies),
|
|
84
|
+
args.otelCollector,
|
|
85
|
+
])
|
|
86
|
+
.apply(([passedTaskRoleInlinePolicies, otelCollector]) => {
|
|
87
|
+
const inlinePolicies = [];
|
|
88
|
+
if (passedTaskRoleInlinePolicies)
|
|
89
|
+
inlinePolicies.push(...passedTaskRoleInlinePolicies);
|
|
90
|
+
if (otelCollector && otelCollector.taskRoleInlinePolicies) {
|
|
91
|
+
inlinePolicies.push(...otelCollector.taskRoleInlinePolicies);
|
|
92
|
+
}
|
|
93
|
+
return inlinePolicies;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
createEcsConfig(args) {
|
|
97
|
+
return {
|
|
98
|
+
vpc: args.vpc,
|
|
99
|
+
cluster: args.cluster,
|
|
100
|
+
deploymentController: args.deploymentController,
|
|
101
|
+
desiredCount: args.desiredCount,
|
|
102
|
+
autoscaling: args.autoscaling,
|
|
103
|
+
size: args.size,
|
|
104
|
+
taskExecutionRoleInlinePolicies: args.taskExecutionRoleInlinePolicies,
|
|
105
|
+
taskRoleInlinePolicies: this.getTaskRoleInlinePolicies(args),
|
|
106
|
+
tags: args.tags,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
createWebServerContainer(args) {
|
|
110
|
+
return {
|
|
111
|
+
image: args.image,
|
|
112
|
+
mountPoints: args.mountPoints,
|
|
113
|
+
environment: args.environment,
|
|
114
|
+
secrets: args.secrets,
|
|
115
|
+
port: args.port,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
createTlsCertificate({ domain, hostedZoneId, }) {
|
|
119
|
+
return new acm_certificate_1.AcmCertificate(`${domain}-acm-certificate`, {
|
|
120
|
+
domain,
|
|
121
|
+
hostedZoneId,
|
|
122
|
+
}, { parent: this });
|
|
123
|
+
}
|
|
124
|
+
createSecurityGroup(vpc) {
|
|
125
|
+
const vpcId = pulumi.output(vpc).vpcId;
|
|
126
|
+
return new aws.ec2.SecurityGroup(`${this.name}-security-group`, {
|
|
127
|
+
vpcId,
|
|
128
|
+
ingress: [
|
|
129
|
+
{
|
|
130
|
+
fromPort: 0,
|
|
131
|
+
toPort: 0,
|
|
132
|
+
protocol: '-1',
|
|
133
|
+
securityGroups: [this.lb.securityGroup.id],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
egress: [
|
|
137
|
+
{
|
|
138
|
+
fromPort: 0,
|
|
139
|
+
toPort: 0,
|
|
140
|
+
protocol: '-1',
|
|
141
|
+
cidrBlocks: ['0.0.0.0/0'],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
tags: common_tags_1.commonTags,
|
|
145
|
+
}, { parent: this });
|
|
146
|
+
}
|
|
147
|
+
createEcsService(webServerContainer, lb, ecsConfig, volumes, initContainers, sidecarContainers) {
|
|
148
|
+
return pulumi
|
|
149
|
+
.all([
|
|
150
|
+
initContainers || pulumi.output([]),
|
|
151
|
+
sidecarContainers || pulumi.output([]),
|
|
152
|
+
])
|
|
153
|
+
.apply(([inits, sidecars]) => {
|
|
154
|
+
return new ecs_service_1.EcsService(`${this.name}-ecs`, Object.assign(Object.assign({}, ecsConfig), { volumes, containers: [
|
|
155
|
+
Object.assign(Object.assign({}, webServerContainer), { name: this.name, portMappings: [
|
|
156
|
+
ecs_service_1.EcsService.createTcpPortMapping(webServerContainer.port),
|
|
157
|
+
], essential: true }),
|
|
158
|
+
...inits,
|
|
159
|
+
...sidecars,
|
|
160
|
+
], enableServiceAutoDiscovery: false, loadBalancers: [
|
|
161
|
+
{
|
|
162
|
+
containerName: this.name,
|
|
163
|
+
containerPort: webServerContainer.port,
|
|
164
|
+
targetGroupArn: lb.targetGroup.arn,
|
|
165
|
+
},
|
|
166
|
+
], assignPublicIp: true, securityGroup: this.serviceSecurityGroup }), {
|
|
167
|
+
parent: this,
|
|
168
|
+
dependsOn: [lb, lb.targetGroup],
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
createDnsRecords(certificate, hostedZoneId, domain) {
|
|
173
|
+
const certOutput = pulumi.output(certificate);
|
|
174
|
+
return pulumi
|
|
175
|
+
.all([domain, certOutput.domainName, certOutput.subjectAlternativeNames])
|
|
176
|
+
.apply(([domain, certDomain, certSans = []]) => (domain ? [domain] : [...new Set([certDomain, ...certSans])]).map((alias, index) => new aws.route53.Record(`${this.name}-route53-record${index === 0 ? '' : `-${index}`}`, {
|
|
177
|
+
type: 'A',
|
|
178
|
+
name: alias,
|
|
179
|
+
zoneId: hostedZoneId,
|
|
180
|
+
aliases: [
|
|
181
|
+
{
|
|
182
|
+
name: this.lb.lb.dnsName,
|
|
183
|
+
zoneId: this.lb.lb.zoneId,
|
|
184
|
+
evaluateTargetHealth: true,
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
}, { parent: this })));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.WebServer = WebServer;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as aws from '@pulumi/aws';
|
|
3
|
-
import * as awsx from '@pulumi/awsx';
|
|
2
|
+
import * as aws from '@pulumi/aws-v7';
|
|
3
|
+
import * as awsx from '@pulumi/awsx-v3';
|
|
4
4
|
export declare namespace WebServerLoadBalancer {
|
|
5
5
|
type Args = {
|
|
6
6
|
vpc: pulumi.Input<awsx.ec2.Vpc>;
|
|
7
7
|
port: pulumi.Input<number>;
|
|
8
|
-
certificate?: aws.acm.Certificate
|
|
8
|
+
certificate?: pulumi.Input<aws.acm.Certificate>;
|
|
9
9
|
healthCheckPath?: pulumi.Input<string>;
|
|
10
|
+
loadBalancingAlgorithmType?: pulumi.Input<string>;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
export declare class WebServerLoadBalancer extends pulumi.ComponentResource {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-balancer.d.ts","sourceRoot":"","sources":["../../../src/components/web-server/load-balancer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,yBAAiB,qBAAqB,CAAC;IACrC,KAAY,IAAI,GAAG;QACjB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,WAAW,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD,eAAe,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvC,0BAA0B,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KACnD,CAAC;CACH;AA+BD,qBAAa,qBAAsB,SAAQ,MAAM,CAAC,iBAAiB;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC;IAChC,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC9B,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IACzC,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC;gBAGnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,CAAC,IAAI,EAChC,IAAI,GAAE,MAAM,CAAC,wBAA6B;IAgD5C,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,oBAAoB;IAgC5B,OAAO,CAAC,mBAAmB;IA4B3B,OAAO,CAAC,qBAAqB;CAa9B"}
|
|
@@ -2,36 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebServerLoadBalancer = void 0;
|
|
4
4
|
const pulumi = require("@pulumi/pulumi");
|
|
5
|
-
const aws = require("@pulumi/aws");
|
|
6
|
-
const
|
|
5
|
+
const aws = require("@pulumi/aws-v7");
|
|
6
|
+
const common_tags_1 = require("../../shared/common-tags");
|
|
7
|
+
const merge_with_defaults_1 = require("../../shared/merge-with-defaults");
|
|
7
8
|
const webServerLoadBalancerNetworkConfig = {
|
|
8
|
-
ingress: [
|
|
9
|
+
ingress: [
|
|
10
|
+
{
|
|
9
11
|
protocol: 'tcp',
|
|
10
12
|
fromPort: 80,
|
|
11
13
|
toPort: 80,
|
|
12
14
|
cidrBlocks: ['0.0.0.0/0'],
|
|
13
|
-
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
14
17
|
protocol: 'tcp',
|
|
15
18
|
fromPort: 443,
|
|
16
19
|
toPort: 443,
|
|
17
20
|
cidrBlocks: ['0.0.0.0/0'],
|
|
18
|
-
}
|
|
19
|
-
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
egress: [
|
|
24
|
+
{
|
|
20
25
|
fromPort: 0,
|
|
21
26
|
toPort: 0,
|
|
22
27
|
protocol: '-1',
|
|
23
28
|
cidrBlocks: ['0.0.0.0/0'],
|
|
24
|
-
}
|
|
29
|
+
},
|
|
30
|
+
],
|
|
25
31
|
};
|
|
26
32
|
const defaults = {
|
|
27
33
|
healthCheckPath: '/healthcheck',
|
|
28
34
|
};
|
|
29
35
|
class WebServerLoadBalancer extends pulumi.ComponentResource {
|
|
30
36
|
constructor(name, args, opts = {}) {
|
|
31
|
-
super('studion:WebServerLoadBalancer', name, args, opts);
|
|
37
|
+
super('studion:web-server:WebServerLoadBalancer', name, args, opts);
|
|
32
38
|
this.name = name;
|
|
33
39
|
const vpc = pulumi.output(args.vpc);
|
|
34
|
-
const
|
|
40
|
+
const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
|
|
41
|
+
const { port, certificate, healthCheckPath, loadBalancingAlgorithmType } = argsWithDefaults;
|
|
35
42
|
this.securityGroup = this.createLbSecurityGroup(vpc.vpcId);
|
|
36
43
|
this.lb = new aws.lb.LoadBalancer(this.name, {
|
|
37
44
|
namePrefix: 'lb-',
|
|
@@ -40,12 +47,13 @@ class WebServerLoadBalancer extends pulumi.ComponentResource {
|
|
|
40
47
|
securityGroups: [this.securityGroup.id],
|
|
41
48
|
internal: false,
|
|
42
49
|
ipAddressType: 'ipv4',
|
|
43
|
-
tags: Object.assign(Object.assign({},
|
|
50
|
+
tags: Object.assign(Object.assign({}, common_tags_1.commonTags), { Name: name }),
|
|
44
51
|
}, { parent: this });
|
|
45
|
-
this.targetGroup = this.createLbTargetGroup(port, vpc.vpcId, healthCheckPath);
|
|
52
|
+
this.targetGroup = this.createLbTargetGroup(port, vpc.vpcId, healthCheckPath, loadBalancingAlgorithmType);
|
|
46
53
|
this.httpListener = this.createLbHttpListener(this.lb, this.targetGroup, !!certificate);
|
|
47
|
-
this.tlsListener =
|
|
48
|
-
|
|
54
|
+
this.tlsListener =
|
|
55
|
+
certificate &&
|
|
56
|
+
this.createLbTlsListener(this.lb, this.targetGroup, pulumi.output(certificate));
|
|
49
57
|
this.registerOutputs();
|
|
50
58
|
}
|
|
51
59
|
createLbTlsListener(lb, lbTargetGroup, certificate) {
|
|
@@ -53,13 +61,15 @@ class WebServerLoadBalancer extends pulumi.ComponentResource {
|
|
|
53
61
|
loadBalancerArn: lb.arn,
|
|
54
62
|
port: 443,
|
|
55
63
|
protocol: 'HTTPS',
|
|
56
|
-
sslPolicy: 'ELBSecurityPolicy-
|
|
64
|
+
sslPolicy: 'ELBSecurityPolicy-TLS13-1-2-2021-06',
|
|
57
65
|
certificateArn: certificate.arn,
|
|
58
|
-
defaultActions: [
|
|
66
|
+
defaultActions: [
|
|
67
|
+
{
|
|
59
68
|
type: 'forward',
|
|
60
69
|
targetGroupArn: lbTargetGroup.arn,
|
|
61
|
-
}
|
|
62
|
-
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
tags: common_tags_1.commonTags,
|
|
63
73
|
}, { parent: this, dependsOn: [certificate] });
|
|
64
74
|
}
|
|
65
75
|
createLbHttpListener(lb, lbTargetGroup, redirectToHttps) {
|
|
@@ -71,36 +81,39 @@ class WebServerLoadBalancer extends pulumi.ComponentResource {
|
|
|
71
81
|
statusCode: 'HTTP_301',
|
|
72
82
|
},
|
|
73
83
|
};
|
|
74
|
-
const defaultAction = redirectToHttps
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
const defaultAction = redirectToHttps
|
|
85
|
+
? httpsRedirectAction
|
|
86
|
+
: {
|
|
87
|
+
type: 'forward',
|
|
88
|
+
targetGroupArn: lbTargetGroup.arn,
|
|
89
|
+
};
|
|
78
90
|
return new aws.lb.Listener(`${this.name}-listener-80`, {
|
|
79
91
|
loadBalancerArn: lb.arn,
|
|
80
92
|
port: 80,
|
|
81
93
|
defaultActions: [defaultAction],
|
|
82
|
-
tags:
|
|
94
|
+
tags: common_tags_1.commonTags,
|
|
83
95
|
}, { parent: this });
|
|
84
96
|
}
|
|
85
|
-
createLbTargetGroup(port, vpcId, healthCheckPath) {
|
|
97
|
+
createLbTargetGroup(port, vpcId, healthCheckPath, loadBalancingAlgorithmType) {
|
|
86
98
|
return new aws.lb.TargetGroup(`${this.name}-tg`, {
|
|
87
99
|
namePrefix: 'lb-tg-',
|
|
88
100
|
port,
|
|
89
101
|
protocol: 'HTTP',
|
|
90
102
|
targetType: 'ip',
|
|
91
103
|
vpcId,
|
|
104
|
+
loadBalancingAlgorithmType,
|
|
92
105
|
healthCheck: {
|
|
93
106
|
healthyThreshold: 3,
|
|
94
107
|
unhealthyThreshold: 2,
|
|
95
108
|
interval: 60,
|
|
96
109
|
timeout: 5,
|
|
97
|
-
path: healthCheckPath
|
|
110
|
+
path: healthCheckPath,
|
|
98
111
|
},
|
|
99
|
-
tags: Object.assign(Object.assign({},
|
|
112
|
+
tags: Object.assign(Object.assign({}, common_tags_1.commonTags), { Name: `${this.name}-target-group` }),
|
|
100
113
|
}, { parent: this, dependsOn: [this.lb] });
|
|
101
114
|
}
|
|
102
115
|
createLbSecurityGroup(vpcId) {
|
|
103
|
-
return new aws.ec2.SecurityGroup(`${this.name}-security-group`, Object.assign(Object.assign({}, webServerLoadBalancerNetworkConfig), { vpcId, tags:
|
|
116
|
+
return new aws.ec2.SecurityGroup(`${this.name}-security-group`, Object.assign(Object.assign({}, webServerLoadBalancerNetworkConfig), { vpcId, tags: common_tags_1.commonTags }), { parent: this });
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
exports.WebServerLoadBalancer = WebServerLoadBalancer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
1
|
+
export { EcsService } from './components/ecs-service';
|
|
2
|
+
export { WebServer } from './components/web-server';
|
|
3
|
+
export { WebServerBuilder } from './components/web-server/builder';
|
|
4
|
+
export { WebServerLoadBalancer } from './components/web-server/load-balancer';
|
|
5
|
+
export { ElastiCacheRedis } from './components/redis/elasticache-redis';
|
|
6
|
+
export { UpstashRedis } from './components/redis/upstash-redis';
|
|
7
|
+
export { Vpc } from './components/vpc';
|
|
8
|
+
export { Database } from './components/database';
|
|
9
|
+
export { DatabaseBuilder } from './components/database/builder';
|
|
10
|
+
export { DatabaseReplica } from './components/database/database-replica';
|
|
11
|
+
export { Ec2SSMConnect } from './components/database/ec2-ssm-connect';
|
|
12
|
+
export { AcmCertificate } from './components/acm-certificate';
|
|
13
|
+
export { Password } from './components/password';
|
|
14
|
+
export { CloudFront } from './components/cloudfront';
|
|
15
|
+
export { StaticSite } from './components/static-site';
|
|
16
|
+
export { S3Assets } from './components/static-site/s3-assets';
|
|
17
|
+
import { OtelCollectorBuilder } from './otel/builder';
|
|
18
|
+
import { OtelCollector } from './otel';
|
|
19
|
+
export declare const openTelemetry: {
|
|
20
|
+
OtelCollector: typeof OtelCollector;
|
|
21
|
+
OtelCollectorBuilder: typeof OtelCollectorBuilder;
|
|
22
|
+
};
|
|
23
|
+
export * as grafana from './components/grafana';
|
|
24
|
+
export * as prometheus from './components/prometheus';
|
|
12
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,eAAO,MAAM,aAAa;;;CAA0C,CAAC;AAErE,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
exports.prometheus = exports.grafana = exports.openTelemetry = exports.S3Assets = exports.StaticSite = exports.CloudFront = exports.Password = exports.AcmCertificate = exports.Ec2SSMConnect = exports.DatabaseReplica = exports.DatabaseBuilder = exports.Database = exports.Vpc = exports.UpstashRedis = exports.ElastiCacheRedis = exports.WebServerLoadBalancer = exports.WebServerBuilder = exports.WebServer = exports.EcsService = void 0;
|
|
4
|
+
var ecs_service_1 = require("./components/ecs-service");
|
|
5
|
+
Object.defineProperty(exports, "EcsService", { enumerable: true, get: function () { return ecs_service_1.EcsService; } });
|
|
6
|
+
var web_server_1 = require("./components/web-server");
|
|
7
|
+
Object.defineProperty(exports, "WebServer", { enumerable: true, get: function () { return web_server_1.WebServer; } });
|
|
8
|
+
var builder_1 = require("./components/web-server/builder");
|
|
9
|
+
Object.defineProperty(exports, "WebServerBuilder", { enumerable: true, get: function () { return builder_1.WebServerBuilder; } });
|
|
10
|
+
var load_balancer_1 = require("./components/web-server/load-balancer");
|
|
11
|
+
Object.defineProperty(exports, "WebServerLoadBalancer", { enumerable: true, get: function () { return load_balancer_1.WebServerLoadBalancer; } });
|
|
12
|
+
var elasticache_redis_1 = require("./components/redis/elasticache-redis");
|
|
13
|
+
Object.defineProperty(exports, "ElastiCacheRedis", { enumerable: true, get: function () { return elasticache_redis_1.ElastiCacheRedis; } });
|
|
14
|
+
var upstash_redis_1 = require("./components/redis/upstash-redis");
|
|
15
|
+
Object.defineProperty(exports, "UpstashRedis", { enumerable: true, get: function () { return upstash_redis_1.UpstashRedis; } });
|
|
16
|
+
var vpc_1 = require("./components/vpc");
|
|
17
|
+
Object.defineProperty(exports, "Vpc", { enumerable: true, get: function () { return vpc_1.Vpc; } });
|
|
18
|
+
var database_1 = require("./components/database");
|
|
19
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_1.Database; } });
|
|
20
|
+
var builder_2 = require("./components/database/builder");
|
|
21
|
+
Object.defineProperty(exports, "DatabaseBuilder", { enumerable: true, get: function () { return builder_2.DatabaseBuilder; } });
|
|
22
|
+
var database_replica_1 = require("./components/database/database-replica");
|
|
23
|
+
Object.defineProperty(exports, "DatabaseReplica", { enumerable: true, get: function () { return database_replica_1.DatabaseReplica; } });
|
|
24
|
+
var ec2_ssm_connect_1 = require("./components/database/ec2-ssm-connect");
|
|
25
|
+
Object.defineProperty(exports, "Ec2SSMConnect", { enumerable: true, get: function () { return ec2_ssm_connect_1.Ec2SSMConnect; } });
|
|
26
|
+
var acm_certificate_1 = require("./components/acm-certificate");
|
|
27
|
+
Object.defineProperty(exports, "AcmCertificate", { enumerable: true, get: function () { return acm_certificate_1.AcmCertificate; } });
|
|
28
|
+
var password_1 = require("./components/password");
|
|
29
|
+
Object.defineProperty(exports, "Password", { enumerable: true, get: function () { return password_1.Password; } });
|
|
30
|
+
var cloudfront_1 = require("./components/cloudfront");
|
|
31
|
+
Object.defineProperty(exports, "CloudFront", { enumerable: true, get: function () { return cloudfront_1.CloudFront; } });
|
|
32
|
+
var static_site_1 = require("./components/static-site");
|
|
33
|
+
Object.defineProperty(exports, "StaticSite", { enumerable: true, get: function () { return static_site_1.StaticSite; } });
|
|
34
|
+
var s3_assets_1 = require("./components/static-site/s3-assets");
|
|
35
|
+
Object.defineProperty(exports, "S3Assets", { enumerable: true, get: function () { return s3_assets_1.S3Assets; } });
|
|
36
|
+
const builder_3 = require("./otel/builder");
|
|
37
|
+
const otel_1 = require("./otel");
|
|
38
|
+
exports.openTelemetry = { OtelCollector: otel_1.OtelCollector, OtelCollectorBuilder: builder_3.OtelCollectorBuilder };
|
|
39
|
+
exports.grafana = require("./components/grafana");
|
|
40
|
+
exports.prometheus = require("./components/prometheus");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-processor.d.ts","sourceRoot":"","sources":["../../src/otel/batch-processor.ts"],"names":[],"mappings":"AAAA,yBAAiB,cAAc,CAAC;IAC9B,KAAY,MAAM,GAAG;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import * as pulumi from '@pulumi/pulumi';
|
|
2
|
-
import * as aws from '@pulumi/aws';
|
|
2
|
+
import * as aws from '@pulumi/aws-v7';
|
|
3
3
|
import { OtelCollector } from '.';
|
|
4
4
|
import { OTLPReceiver } from './otlp-receiver';
|
|
5
|
+
import { PrometheusRemoteWriteExporter } from './prometheus-remote-write-exporter';
|
|
6
|
+
export declare namespace OtelCollectorBuilder {
|
|
7
|
+
type WithDefaultArgs = {
|
|
8
|
+
prometheusNamespace: PrometheusRemoteWriteExporter.Config['namespace'];
|
|
9
|
+
prometheusWorkspace: aws.amp.Workspace;
|
|
10
|
+
region: string;
|
|
11
|
+
logGroupName: OtelCollector.AwsCloudWatchLogsExporterConfig['log_group_name'];
|
|
12
|
+
logStreamName: OtelCollector.AwsCloudWatchLogsExporterConfig['log_stream_name'];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
5
15
|
export declare class OtelCollectorBuilder {
|
|
6
16
|
private readonly _serviceName;
|
|
7
17
|
private readonly _env;
|
|
@@ -12,6 +22,7 @@ export declare class OtelCollectorBuilder {
|
|
|
12
22
|
withBatchProcessor(name?: string, size?: number, maxSize?: number, timeout?: string): this;
|
|
13
23
|
withMemoryLimiterProcessor(checkInterval?: string, limitPercentage?: number, spikeLimitPercentage?: number): this;
|
|
14
24
|
withAWSXRayExporter(region: string): this;
|
|
25
|
+
withCloudWatchLogsExporter(region: OtelCollector.AwsCloudWatchLogsExporterConfig['region'], logGroupName: OtelCollector.AwsCloudWatchLogsExporterConfig['log_group_name'], logStreamName: OtelCollector.AwsCloudWatchLogsExporterConfig['log_stream_name'], logRetention?: OtelCollector.AwsCloudWatchLogsExporterConfig['log_retention']): this;
|
|
15
26
|
withHealthCheckExtension(endpoint?: string): this;
|
|
16
27
|
withPprofExtension(endpoint?: string): this;
|
|
17
28
|
withAPS(namespace: pulumi.Input<string>, workspace: aws.amp.Workspace, region: string): this;
|
|
@@ -19,9 +30,11 @@ export declare class OtelCollectorBuilder {
|
|
|
19
30
|
withTelemetry(logLevel?: 'debug' | 'warn' | 'error', metricsVerbosity?: 'basic' | 'normal' | 'detailed'): this;
|
|
20
31
|
withMetricsPipeline(receivers: OtelCollector.ReceiverType[], processors: OtelCollector.ProcessorType[], exporters: OtelCollector.ExporterType[]): this;
|
|
21
32
|
withTracesPipeline(receivers: OtelCollector.ReceiverType[], processors: OtelCollector.ProcessorType[], exporters: OtelCollector.ExporterType[]): this;
|
|
22
|
-
|
|
33
|
+
withLogsPipeline(receivers: OtelCollector.ReceiverType[], processors: OtelCollector.ProcessorType[], exporters: OtelCollector.ExporterType[]): this;
|
|
34
|
+
withDefault({ prometheusNamespace, prometheusWorkspace, region, logGroupName, logStreamName, }: OtelCollectorBuilder.WithDefaultArgs): this;
|
|
23
35
|
build(): OtelCollector;
|
|
24
36
|
private createAPSInlinePolicy;
|
|
25
37
|
private createAWSXRayPolicy;
|
|
38
|
+
private createCloudWatchLogsPolicy;
|
|
26
39
|
}
|
|
27
40
|
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/otel/builder.ts"],"names":[],"mappings":"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"}
|
|
@@ -30,6 +30,11 @@ class OtelCollectorBuilder {
|
|
|
30
30
|
this.createAWSXRayPolicy();
|
|
31
31
|
return this;
|
|
32
32
|
}
|
|
33
|
+
withCloudWatchLogsExporter(region, logGroupName, logStreamName, logRetention) {
|
|
34
|
+
this._configBuilder.withCloudWatchLogsExporter(region, logGroupName, logStreamName, logRetention);
|
|
35
|
+
this.createCloudWatchLogsPolicy(logGroupName);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
33
38
|
withHealthCheckExtension(endpoint = '0.0.0.0:13133') {
|
|
34
39
|
this._configBuilder.withHealthCheckExtension(endpoint);
|
|
35
40
|
return this;
|
|
@@ -59,39 +64,51 @@ class OtelCollectorBuilder {
|
|
|
59
64
|
this._configBuilder.withTracesPipeline(receivers, processors, exporters);
|
|
60
65
|
return this;
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
this._configBuilder.
|
|
67
|
+
withLogsPipeline(receivers, processors, exporters) {
|
|
68
|
+
this._configBuilder.withLogsPipeline(receivers, processors, exporters);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
withDefault({ prometheusNamespace, prometheusWorkspace, region, logGroupName, logStreamName, }) {
|
|
72
|
+
this._configBuilder.withDefault({
|
|
73
|
+
prometheusNamespace,
|
|
74
|
+
prometheusEndpoint: pulumi.interpolate `${prometheusWorkspace.prometheusEndpoint}api/v1/remote_write`,
|
|
75
|
+
region,
|
|
76
|
+
logGroupName,
|
|
77
|
+
logStreamName,
|
|
78
|
+
});
|
|
64
79
|
this.createAPSInlinePolicy(prometheusWorkspace);
|
|
65
80
|
this.createAWSXRayPolicy();
|
|
81
|
+
this.createCloudWatchLogsPolicy(logGroupName);
|
|
66
82
|
return this;
|
|
67
83
|
}
|
|
68
84
|
build() {
|
|
69
85
|
return new _1.OtelCollector(this._serviceName, this._env, this._configBuilder.build(), { taskRoleInlinePolicies: this._taskRoleInlinePolicies });
|
|
70
86
|
}
|
|
71
87
|
createAPSInlinePolicy(workspace) {
|
|
72
|
-
const policy = pulumi
|
|
73
|
-
this._serviceName,
|
|
74
|
-
|
|
75
|
-
])).apply(([serviceName, workspaceArn]) => ({
|
|
88
|
+
const policy = pulumi
|
|
89
|
+
.all([this._serviceName, workspace.arn])
|
|
90
|
+
.apply(([serviceName, workspaceArn]) => ({
|
|
76
91
|
name: `${serviceName}-task-role-aps-write`,
|
|
77
92
|
policy: JSON.stringify({
|
|
78
93
|
Version: '2012-10-17',
|
|
79
|
-
Statement: [
|
|
94
|
+
Statement: [
|
|
95
|
+
{
|
|
80
96
|
Effect: 'Allow',
|
|
81
97
|
Action: ['aps:RemoteWrite'],
|
|
82
98
|
Resource: workspaceArn,
|
|
83
|
-
}
|
|
99
|
+
},
|
|
100
|
+
],
|
|
84
101
|
}),
|
|
85
102
|
}));
|
|
86
103
|
this._taskRoleInlinePolicies.push(policy);
|
|
87
104
|
}
|
|
88
105
|
createAWSXRayPolicy() {
|
|
89
|
-
const policy = this._serviceName
|
|
90
|
-
.apply(serviceName => ({
|
|
106
|
+
const policy = this._serviceName.apply(serviceName => ({
|
|
91
107
|
name: `${serviceName}-task-role-xray`,
|
|
92
108
|
policy: JSON.stringify({
|
|
93
109
|
Version: '2012-10-17',
|
|
94
|
-
Statement: [
|
|
110
|
+
Statement: [
|
|
111
|
+
{
|
|
95
112
|
Effect: 'Allow',
|
|
96
113
|
Action: [
|
|
97
114
|
'xray:PutTraceSegments',
|
|
@@ -101,10 +118,40 @@ class OtelCollectorBuilder {
|
|
|
101
118
|
'xray:GetSamplingStatisticSummaries',
|
|
102
119
|
],
|
|
103
120
|
Resource: '*',
|
|
104
|
-
}
|
|
121
|
+
},
|
|
122
|
+
],
|
|
105
123
|
}),
|
|
106
124
|
}));
|
|
107
125
|
this._taskRoleInlinePolicies.push(policy);
|
|
108
126
|
}
|
|
127
|
+
createCloudWatchLogsPolicy(logGroupName) {
|
|
128
|
+
const policy = pulumi
|
|
129
|
+
.all([this._serviceName, logGroupName])
|
|
130
|
+
.apply(([serviceName, logGroupName]) => {
|
|
131
|
+
return {
|
|
132
|
+
name: `${serviceName}-task-role-cloudwatch-logs`,
|
|
133
|
+
policy: JSON.stringify({
|
|
134
|
+
Version: '2012-10-17',
|
|
135
|
+
Statement: [
|
|
136
|
+
{
|
|
137
|
+
Effect: 'Allow',
|
|
138
|
+
Action: ['logs:CreateLogGroup', 'logs:PutRetentionPolicy'],
|
|
139
|
+
Resource: '*',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
Effect: 'Allow',
|
|
143
|
+
Action: [
|
|
144
|
+
'logs:CreateLogStream',
|
|
145
|
+
'logs:DescribeLogStreams',
|
|
146
|
+
'logs:PutLogEvents',
|
|
147
|
+
],
|
|
148
|
+
Resource: `arn:aws:logs:*:*:log-group:${logGroupName}:*`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
}),
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
this._taskRoleInlinePolicies.push(policy);
|
|
155
|
+
}
|
|
109
156
|
}
|
|
110
157
|
exports.OtelCollectorBuilder = OtelCollectorBuilder;
|