@studion/infra-code-blocks 0.7.0 → 0.8.0-next.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.
Files changed (100) hide show
  1. package/dist/components/acm-certificate.d.ts +1 -0
  2. package/dist/components/acm-certificate.d.ts.map +1 -0
  3. package/dist/components/database-replica.d.ts +1 -0
  4. package/dist/components/database-replica.d.ts.map +1 -0
  5. package/dist/components/database.d.ts +1 -0
  6. package/dist/components/database.d.ts.map +1 -0
  7. package/dist/components/ec2-ssm-connect.d.ts +1 -0
  8. package/dist/components/ec2-ssm-connect.d.ts.map +1 -0
  9. package/dist/components/ecs-service.d.ts +1 -0
  10. package/dist/components/ecs-service.d.ts.map +1 -0
  11. package/dist/components/ecs-service.js +2 -1
  12. package/dist/components/mongo.d.ts +1 -0
  13. package/dist/components/mongo.d.ts.map +1 -0
  14. package/dist/components/nuxt-ssr.d.ts +1 -0
  15. package/dist/components/nuxt-ssr.d.ts.map +1 -0
  16. package/dist/components/password.d.ts +1 -0
  17. package/dist/components/password.d.ts.map +1 -0
  18. package/dist/components/project.d.ts +1 -0
  19. package/dist/components/project.d.ts.map +1 -0
  20. package/dist/components/redis.d.ts +1 -0
  21. package/dist/components/redis.d.ts.map +1 -0
  22. package/dist/components/static-site.d.ts +1 -0
  23. package/dist/components/static-site.d.ts.map +1 -0
  24. package/dist/components/web-server.d.ts +1 -0
  25. package/dist/components/web-server.d.ts.map +1 -0
  26. package/dist/components/web-server.js +2 -1
  27. package/dist/constants.d.ts +1 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +2 -0
  32. package/dist/types/pulumi.d.ts +5 -0
  33. package/dist/types/pulumi.d.ts.map +1 -0
  34. package/dist/types/pulumi.js +2 -0
  35. package/dist/types/size.d.ts +1 -0
  36. package/dist/types/size.d.ts.map +1 -0
  37. package/dist/v2/components/ecs-service/index.d.ts +156 -0
  38. package/dist/v2/components/ecs-service/index.d.ts.map +1 -0
  39. package/dist/v2/components/ecs-service/index.js +362 -0
  40. package/dist/v2/components/ecs-service/policies.d.ts +3 -0
  41. package/dist/v2/components/ecs-service/policies.d.ts.map +1 -0
  42. package/dist/v2/components/ecs-service/policies.js +16 -0
  43. package/dist/v2/components/grafana/dashboards/index.d.ts +3 -0
  44. package/dist/v2/components/grafana/dashboards/index.d.ts.map +1 -0
  45. package/dist/v2/components/grafana/dashboards/index.js +6 -0
  46. package/dist/v2/components/grafana/dashboards/panels.d.ts +6 -0
  47. package/dist/v2/components/grafana/dashboards/panels.d.ts.map +1 -0
  48. package/dist/v2/components/grafana/dashboards/panels.js +91 -0
  49. package/dist/v2/components/grafana/dashboards/types.d.ts +66 -0
  50. package/dist/v2/components/grafana/dashboards/types.d.ts.map +1 -0
  51. package/dist/v2/components/grafana/dashboards/types.js +2 -0
  52. package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts +17 -0
  53. package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts.map +1 -0
  54. package/dist/v2/components/grafana/dashboards/web-server-slo.js +98 -0
  55. package/dist/v2/components/grafana/index.d.ts +2 -0
  56. package/dist/v2/components/grafana/index.d.ts.map +1 -0
  57. package/dist/v2/components/grafana/index.js +4 -0
  58. package/dist/v2/components/prometheus/index.d.ts +2 -0
  59. package/dist/v2/components/prometheus/index.d.ts.map +1 -0
  60. package/dist/v2/components/prometheus/index.js +4 -0
  61. package/dist/v2/components/prometheus/queries.d.ts +10 -0
  62. package/dist/v2/components/prometheus/queries.d.ts.map +1 -0
  63. package/dist/v2/components/prometheus/queries.js +61 -0
  64. package/dist/v2/components/prometheus/queries.test.d.ts +2 -0
  65. package/dist/v2/components/prometheus/queries.test.d.ts.map +1 -0
  66. package/dist/v2/components/prometheus/queries.test.js +52 -0
  67. package/dist/v2/components/web-server/builder.d.ts +34 -0
  68. package/dist/v2/components/web-server/builder.d.ts.map +1 -0
  69. package/dist/v2/components/web-server/builder.js +72 -0
  70. package/dist/v2/components/web-server/index.d.ts +58 -0
  71. package/dist/v2/components/web-server/index.d.ts.map +1 -0
  72. package/dist/v2/components/web-server/index.js +169 -0
  73. package/dist/v2/components/web-server/load-balancer.d.ts +25 -0
  74. package/dist/v2/components/web-server/load-balancer.d.ts.map +1 -0
  75. package/dist/v2/components/web-server/load-balancer.js +106 -0
  76. package/dist/v2/index.d.ts +13 -0
  77. package/dist/v2/index.d.ts.map +1 -0
  78. package/dist/v2/index.js +16 -0
  79. package/dist/v2/otel/batch-processor.d.ts +14 -0
  80. package/dist/v2/otel/batch-processor.d.ts.map +1 -0
  81. package/dist/v2/otel/batch-processor.js +9 -0
  82. package/dist/v2/otel/builder.d.ts +27 -0
  83. package/dist/v2/otel/builder.d.ts.map +1 -0
  84. package/dist/v2/otel/builder.js +110 -0
  85. package/dist/v2/otel/config.d.ts +26 -0
  86. package/dist/v2/otel/config.d.ts.map +1 -0
  87. package/dist/v2/otel/config.js +159 -0
  88. package/dist/v2/otel/index.d.ts +94 -0
  89. package/dist/v2/otel/index.d.ts.map +1 -0
  90. package/dist/v2/otel/index.js +82 -0
  91. package/dist/v2/otel/memory-limiter-processor.d.ts +13 -0
  92. package/dist/v2/otel/memory-limiter-processor.d.ts.map +1 -0
  93. package/dist/v2/otel/memory-limiter-processor.js +8 -0
  94. package/dist/v2/otel/otlp-receiver.d.ts +19 -0
  95. package/dist/v2/otel/otlp-receiver.d.ts.map +1 -0
  96. package/dist/v2/otel/otlp-receiver.js +11 -0
  97. package/dist/v2/otel/prometheus-remote-write-exporter.d.ts +11 -0
  98. package/dist/v2/otel/prometheus-remote-write-exporter.d.ts.map +1 -0
  99. package/dist/v2/otel/prometheus-remote-write-exporter.js +2 -0
  100. package/package.json +30 -6
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EcsService = void 0;
4
+ const pulumi = require("@pulumi/pulumi");
5
+ const aws = require("@pulumi/aws");
6
+ const constants_1 = require("../../../constants");
7
+ const policies_1 = require("./policies");
8
+ const config = new pulumi.Config('aws');
9
+ const awsRegion = config.require('region');
10
+ /**
11
+ * Standard directory permissions:
12
+ * - Owner: read, write, execute (7)
13
+ * - Group: read, execute (5)
14
+ * - Others: read, execute (5)
15
+ */
16
+ const STANDARD_DIRECTORY_PERMISSIONS = '0755';
17
+ const FIRST_POSIX_NON_ROOT_USER = {
18
+ userId: 1000,
19
+ groupId: 1000,
20
+ permissions: STANDARD_DIRECTORY_PERMISSIONS
21
+ };
22
+ const defaults = {
23
+ desiredCount: 1,
24
+ size: 'small',
25
+ environment: [],
26
+ secrets: [],
27
+ volumes: [],
28
+ enableServiceAutoDiscovery: false,
29
+ assignPublicIp: false,
30
+ taskExecutionRoleInlinePolicies: [],
31
+ taskRoleInlinePolicies: [],
32
+ autoscaling: {
33
+ enabled: false,
34
+ minCount: 1,
35
+ maxCount: 1,
36
+ },
37
+ };
38
+ class EcsService extends pulumi.ComponentResource {
39
+ constructor(name, args, opts = {}) {
40
+ super('studion:ecs:Service', name, {}, opts);
41
+ const argsWithDefaults = Object.assign({}, defaults, args);
42
+ const taskExecutionRoleInlinePolicies = pulumi.output(args.taskExecutionRoleInlinePolicies || defaults.taskExecutionRoleInlinePolicies);
43
+ const taskRoleInlinePolicies = pulumi.output(args.taskRoleInlinePolicies || defaults.taskRoleInlinePolicies);
44
+ this.name = name;
45
+ this.securityGroups = [];
46
+ this.vpc = pulumi.output(argsWithDefaults.vpc);
47
+ this.logGroup = this.createLogGroup();
48
+ this.taskExecutionRole = this.createTaskExecutionRole(taskExecutionRoleInlinePolicies);
49
+ this.taskRole = this.createTaskRole(taskRoleInlinePolicies);
50
+ if (argsWithDefaults.volumes.length) {
51
+ this.persistentStorage = this.createPersistentStorage(this.vpc);
52
+ }
53
+ this.taskDefinition = this.createTaskDefinition(argsWithDefaults.containers, pulumi.output(argsWithDefaults.volumes), this.taskExecutionRole, this.taskRole, argsWithDefaults.size, Object.assign(Object.assign({}, constants_1.commonTags), argsWithDefaults.tags));
54
+ if (argsWithDefaults.enableServiceAutoDiscovery) {
55
+ this.serviceDiscoveryService = this.createServiceDiscovery();
56
+ }
57
+ this.service = this.createEcsService(argsWithDefaults);
58
+ if (argsWithDefaults.autoscaling.enabled) {
59
+ this.enableAutoscaling(pulumi.output(argsWithDefaults.cluster).name, this.service.name, argsWithDefaults.autoscaling.minCount, argsWithDefaults.autoscaling.maxCount);
60
+ }
61
+ this.registerOutputs();
62
+ }
63
+ static createTcpPortMapping(port) {
64
+ return {
65
+ containerPort: port,
66
+ hostPort: port,
67
+ protocol: 'tcp'
68
+ };
69
+ }
70
+ createLogGroup() {
71
+ const logGroup = new aws.cloudwatch.LogGroup(`${this.name}-log-group`, {
72
+ retentionInDays: 14,
73
+ namePrefix: `/ecs/${this.name}-`,
74
+ tags: constants_1.commonTags,
75
+ }, { parent: this });
76
+ return logGroup;
77
+ }
78
+ createTaskDefinition(containers, volumes, taskExecutionRole, taskRole, size, tags) {
79
+ const stack = pulumi.getStack();
80
+ const { cpu, memory } = pulumi.output(size).apply(parseSize);
81
+ const containerDefinitions = containers.map(container => {
82
+ return this.createContainerDefinition(container);
83
+ });
84
+ const taskDefinitionVolumes = this.createTaskDefinitionVolumes(volumes);
85
+ return pulumi.all(containerDefinitions).apply(containerDefinitions => {
86
+ return taskDefinitionVolumes.apply(volumes => {
87
+ return new aws.ecs.TaskDefinition(`${this.name}-task-definition`, Object.assign(Object.assign({ family: `${this.name}-task-definition-${stack}`, networkMode: 'awsvpc', executionRoleArn: taskExecutionRole.arn, taskRoleArn: taskRole.arn, cpu,
88
+ memory, requiresCompatibilities: ['FARGATE'], containerDefinitions: JSON.stringify(containerDefinitions) }, ((volumes === null || volumes === void 0 ? void 0 : volumes.length) ? { volumes } : {})), { tags: Object.assign(Object.assign({}, constants_1.commonTags), tags) }), { parent: this });
89
+ });
90
+ });
91
+ }
92
+ createTaskDefinitionVolumes(volumes) {
93
+ return volumes.apply(volumes => {
94
+ if (!volumes.length || !this.persistentStorage)
95
+ return;
96
+ return volumes.map(volume => ({
97
+ name: pulumi.output(volume).name,
98
+ efsVolumeConfiguration: {
99
+ fileSystemId: this.persistentStorage.fileSystem.id,
100
+ transitEncryption: 'ENABLED',
101
+ authorizationConfig: {
102
+ accessPointId: this.persistentStorage.accessPoint.id,
103
+ iam: 'ENABLED',
104
+ },
105
+ }
106
+ }));
107
+ });
108
+ }
109
+ createContainerDefinition(container) {
110
+ return this.logGroup.name.apply(logGroupName => (Object.assign(Object.assign(Object.assign(Object.assign({}, container), { readonlyRootFilesystem: false }), container.mountPoints && {
111
+ mountPoints: container.mountPoints.map(mountPoint => pulumi.all([
112
+ mountPoint.sourceVolume,
113
+ mountPoint.containerPath,
114
+ mountPoint.readOnly
115
+ ]).apply(([sourceVolume, containerPath, readOnly]) => ({
116
+ containerPath,
117
+ sourceVolume,
118
+ readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : false,
119
+ })))
120
+ }), { logConfiguration: {
121
+ logDriver: 'awslogs',
122
+ options: {
123
+ 'awslogs-group': logGroupName,
124
+ 'awslogs-region': awsRegion,
125
+ 'awslogs-stream-prefix': 'ecs',
126
+ },
127
+ } })));
128
+ }
129
+ createTaskExecutionRole(inlinePolicies) {
130
+ const secretManagerSecretsInlinePolicy = {
131
+ name: `${this.name}-secret-manager-access`,
132
+ policy: JSON.stringify({
133
+ Version: '2012-10-17',
134
+ Statement: [
135
+ {
136
+ Sid: 'AllowContainerToGetSecretManagerSecrets',
137
+ Effect: 'Allow',
138
+ Action: ['ssm:GetParameters', 'secretsmanager:GetSecretValue'],
139
+ Resource: '*',
140
+ },
141
+ ],
142
+ }),
143
+ };
144
+ const taskExecutionRole = new aws.iam.Role(`${this.name}-task-exec-role`, {
145
+ namePrefix: `${this.name}-task-exec-role-`,
146
+ assumeRolePolicy: policies_1.assumeRolePolicy,
147
+ managedPolicyArns: [
148
+ 'arn:aws:iam::aws:policy/CloudWatchFullAccess',
149
+ 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess',
150
+ ],
151
+ inlinePolicies: inlinePolicies.apply(policies => [
152
+ secretManagerSecretsInlinePolicy,
153
+ ...policies,
154
+ ]),
155
+ tags: constants_1.commonTags,
156
+ }, { parent: this });
157
+ return taskExecutionRole;
158
+ }
159
+ createTaskRole(inlinePolicies) {
160
+ const execCmdInlinePolicy = {
161
+ name: `${this.name}-exec`,
162
+ policy: JSON.stringify({
163
+ Version: '2012-10-17',
164
+ Statement: [
165
+ {
166
+ Sid: 'AllowContainerToCreateECSExecSSMChannel',
167
+ Effect: 'Allow',
168
+ Action: [
169
+ 'ssmmessages:CreateControlChannel',
170
+ 'ssmmessages:CreateDataChannel',
171
+ 'ssmmessages:OpenControlChannel',
172
+ 'ssmmessages:OpenDataChannel',
173
+ ],
174
+ Resource: '*',
175
+ },
176
+ ],
177
+ }),
178
+ };
179
+ return new aws.iam.Role(`${this.name}-task-role`, {
180
+ namePrefix: `${this.name}-task-role-`,
181
+ assumeRolePolicy: policies_1.assumeRolePolicy,
182
+ inlinePolicies: inlinePolicies.apply(policies => [
183
+ execCmdInlinePolicy,
184
+ ...policies,
185
+ ]),
186
+ tags: constants_1.commonTags,
187
+ }, { parent: this });
188
+ }
189
+ addSecurityGroup(securityGroup) {
190
+ this.securityGroups.push(securityGroup);
191
+ }
192
+ createDefaultSecurityGroup() {
193
+ const securityGroup = pulumi.all([
194
+ this.vpc,
195
+ this.vpc.vpcId,
196
+ this.vpc.vpc.cidrBlock
197
+ ]).apply(([vpc, vpcId, cidrBlock]) => {
198
+ return new aws.ec2.SecurityGroup(`${this.name}-service-security-group`, {
199
+ vpcId,
200
+ ingress: [
201
+ {
202
+ fromPort: 0,
203
+ toPort: 0,
204
+ protocol: '-1',
205
+ cidrBlocks: [cidrBlock],
206
+ },
207
+ ],
208
+ egress: [
209
+ {
210
+ fromPort: 0,
211
+ toPort: 0,
212
+ protocol: '-1',
213
+ cidrBlocks: ['0.0.0.0/0'],
214
+ },
215
+ ],
216
+ tags: constants_1.commonTags,
217
+ }, { parent: this, dependsOn: [vpc] });
218
+ });
219
+ this.addSecurityGroup(securityGroup);
220
+ }
221
+ createEcsService(ecsServiceArgs) {
222
+ if (!this.securityGroups.length)
223
+ this.createDefaultSecurityGroup();
224
+ const networkConfiguration = {
225
+ assignPublicIp: ecsServiceArgs.assignPublicIp,
226
+ subnets: ecsServiceArgs.assignPublicIp ? this.vpc.publicSubnetIds : this.vpc.privateSubnetIds,
227
+ securityGroups: pulumi
228
+ .all(this.securityGroups)
229
+ .apply(groups => groups.map(it => it.id)),
230
+ };
231
+ return new aws.ecs.Service(`${this.name}-service`, Object.assign(Object.assign(Object.assign({ name: this.name, cluster: pulumi.output(ecsServiceArgs.cluster).id, launchType: 'FARGATE', desiredCount: ecsServiceArgs.desiredCount, taskDefinition: this.taskDefinition.arn, enableExecuteCommand: true, networkConfiguration }, ecsServiceArgs.loadBalancers && { loadBalancers: ecsServiceArgs.loadBalancers }), this.serviceDiscoveryService && {
232
+ serviceRegistries: {
233
+ registryArn: this.serviceDiscoveryService.arn,
234
+ },
235
+ }), { tags: Object.assign(Object.assign({}, constants_1.commonTags), ecsServiceArgs.tags) }), { parent: this, });
236
+ }
237
+ createServiceDiscovery() {
238
+ const privateDnsNamespace = this.createPrivateDnsNameSpace();
239
+ return new aws.servicediscovery.Service(`${this.name}-service-discovery`, {
240
+ name: this.name,
241
+ dnsConfig: {
242
+ namespaceId: privateDnsNamespace.id,
243
+ dnsRecords: [
244
+ {
245
+ ttl: 10,
246
+ type: 'A',
247
+ },
248
+ ],
249
+ routingPolicy: 'MULTIVALUE',
250
+ },
251
+ tags: constants_1.commonTags,
252
+ }, { parent: this });
253
+ }
254
+ createPrivateDnsNameSpace() {
255
+ return new aws.servicediscovery.PrivateDnsNamespace(`${this.name}-private-dns-namespace`, {
256
+ vpc: this.vpc.vpcId,
257
+ name: this.name,
258
+ tags: constants_1.commonTags,
259
+ }, { parent: this });
260
+ }
261
+ enableAutoscaling(clusterName, serviceName, minCount, maxCount) {
262
+ const autoscalingTarget = new aws.appautoscaling.Target(`${this.name}-autoscale-target`, {
263
+ minCapacity: minCount,
264
+ maxCapacity: maxCount,
265
+ resourceId: pulumi.interpolate `service/${clusterName}/${serviceName}`,
266
+ serviceNamespace: 'ecs',
267
+ scalableDimension: 'ecs:service:DesiredCount',
268
+ tags: constants_1.commonTags,
269
+ }, { parent: this });
270
+ const memoryAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-memory-autoscale-policy`, {
271
+ policyType: 'TargetTrackingScaling',
272
+ resourceId: autoscalingTarget.resourceId,
273
+ scalableDimension: autoscalingTarget.scalableDimension,
274
+ serviceNamespace: autoscalingTarget.serviceNamespace,
275
+ targetTrackingScalingPolicyConfiguration: {
276
+ predefinedMetricSpecification: {
277
+ predefinedMetricType: 'ECSServiceAverageMemoryUtilization',
278
+ },
279
+ targetValue: 70,
280
+ },
281
+ }, { parent: this });
282
+ const cpuAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-cpu-autoscale-policy`, {
283
+ policyType: 'TargetTrackingScaling',
284
+ resourceId: autoscalingTarget.resourceId,
285
+ scalableDimension: autoscalingTarget.scalableDimension,
286
+ serviceNamespace: autoscalingTarget.serviceNamespace,
287
+ targetTrackingScalingPolicyConfiguration: {
288
+ predefinedMetricSpecification: {
289
+ predefinedMetricType: 'ECSServiceAverageCPUUtilization',
290
+ },
291
+ targetValue: 70,
292
+ },
293
+ }, { parent: this });
294
+ }
295
+ createPersistentStorage(vpc) {
296
+ const efs = new aws.efs.FileSystem(`${this.name}-efs`, {
297
+ encrypted: true,
298
+ lifecyclePolicies: [
299
+ {
300
+ transitionToPrimaryStorageClass: 'AFTER_1_ACCESS',
301
+ },
302
+ {
303
+ transitionToIa: 'AFTER_7_DAYS',
304
+ },
305
+ ],
306
+ performanceMode: 'generalPurpose',
307
+ throughputMode: 'bursting',
308
+ tags: Object.assign(Object.assign({}, constants_1.commonTags), { Name: `${this.name}-data` }),
309
+ }, { parent: this });
310
+ const securityGroup = new aws.ec2.SecurityGroup(`${this.name}-persistent-storage-security-group`, {
311
+ vpcId: vpc.vpcId,
312
+ ingress: [
313
+ {
314
+ fromPort: 2049,
315
+ toPort: 2049,
316
+ protocol: 'tcp',
317
+ cidrBlocks: [vpc.vpc.cidrBlock],
318
+ },
319
+ ],
320
+ tags: constants_1.commonTags,
321
+ }, { parent: this });
322
+ this.vpc.privateSubnetIds.apply((subnetIds) => {
323
+ subnetIds.forEach(subnetId => {
324
+ const mountTarget = new aws.efs.MountTarget(`${this.name}-mount-target-${subnetId}`, {
325
+ fileSystemId: efs.id,
326
+ subnetId,
327
+ securityGroups: [securityGroup.id],
328
+ }, { parent: this });
329
+ });
330
+ });
331
+ const accessPoint = new aws.efs.AccessPoint(`${this.name}-efs-ap`, {
332
+ fileSystemId: efs.id,
333
+ posixUser: {
334
+ uid: FIRST_POSIX_NON_ROOT_USER.userId,
335
+ gid: FIRST_POSIX_NON_ROOT_USER.groupId,
336
+ },
337
+ rootDirectory: {
338
+ path: '/data',
339
+ creationInfo: {
340
+ ownerUid: FIRST_POSIX_NON_ROOT_USER.userId,
341
+ ownerGid: FIRST_POSIX_NON_ROOT_USER.groupId,
342
+ permissions: FIRST_POSIX_NON_ROOT_USER.permissions,
343
+ },
344
+ },
345
+ });
346
+ return { fileSystem: efs, accessPoint };
347
+ }
348
+ }
349
+ exports.EcsService = EcsService;
350
+ function parseSize(size) {
351
+ const mapCapabilities = ({ cpu, memory }) => ({
352
+ cpu: String(cpu),
353
+ memory: String(memory),
354
+ });
355
+ if (typeof size === 'string') {
356
+ return mapCapabilities(constants_1.PredefinedSize[size]);
357
+ }
358
+ if (typeof size === 'object') {
359
+ return mapCapabilities(size);
360
+ }
361
+ throw Error('Incorrect EcsService size argument');
362
+ }
@@ -0,0 +1,3 @@
1
+ import * as aws from '@pulumi/aws';
2
+ export declare const assumeRolePolicy: aws.iam.PolicyDocument;
3
+ //# sourceMappingURL=policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/ecs-service/policies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,eAAO,MAAM,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,cAYtC,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assumeRolePolicy = void 0;
4
+ exports.assumeRolePolicy = {
5
+ Version: '2012-10-17',
6
+ Statement: [
7
+ {
8
+ Action: 'sts:AssumeRole',
9
+ Principal: {
10
+ Service: 'ecs-tasks.amazonaws.com',
11
+ },
12
+ Effect: 'Allow',
13
+ Sid: '',
14
+ },
15
+ ],
16
+ };
@@ -0,0 +1,3 @@
1
+ export { default as WebServerSloDashboardBuilder } from "./web-server-slo";
2
+ export * as panel from './panels';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/grafana/dashboards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.panel = exports.WebServerSloDashboardBuilder = void 0;
4
+ var web_server_slo_1 = require("./web-server-slo");
5
+ Object.defineProperty(exports, "WebServerSloDashboardBuilder", { enumerable: true, get: function () { return web_server_slo_1.default; } });
6
+ exports.panel = require("./panels");
@@ -0,0 +1,6 @@
1
+ import { Grafana } from './types';
2
+ export declare function createStatPercentagePanel(title: string, position: Grafana.Panel.Position, dataSource: string, metric: Grafana.Metric): Grafana.Panel;
3
+ export declare function createTimeSeriesPercentagePanel(title: string, position: Grafana.Panel.Position, dataSource: string, metric: Grafana.Metric): Grafana.Panel;
4
+ export declare function createTimeSeriesPanel(title: string, position: Grafana.Panel.Position, dataSource: string, metric: Grafana.Metric, unit?: string, min?: number, max?: number): Grafana.Panel;
5
+ export declare function createBurnRatePanel(title: string, position: Grafana.Panel.Position, dataSource: string, metric: Grafana.Metric): Grafana.Panel;
6
+ //# sourceMappingURL=panels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/grafana/dashboards/panels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,GACrB,OAAO,CAAC,KAAK,CAsBf;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,GACrB,OAAO,CAAC,KAAK,CAUf;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,IAAI,CAAC,EAAE,MAAM,EACb,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,CAwBf;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,CAAC,MAAM,GACrB,OAAO,CAAC,KAAK,CAkCf"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStatPercentagePanel = createStatPercentagePanel;
4
+ exports.createTimeSeriesPercentagePanel = createTimeSeriesPercentagePanel;
5
+ exports.createTimeSeriesPanel = createTimeSeriesPanel;
6
+ exports.createBurnRatePanel = createBurnRatePanel;
7
+ const percentageFieldConfig = {
8
+ unit: 'percent',
9
+ min: 0,
10
+ max: 100
11
+ };
12
+ function createStatPercentagePanel(title, position, dataSource, metric) {
13
+ return {
14
+ title,
15
+ gridPos: position,
16
+ type: 'stat',
17
+ datasource: dataSource,
18
+ targets: [{
19
+ expr: metric.query,
20
+ legendFormat: metric.label
21
+ }],
22
+ fieldConfig: {
23
+ defaults: Object.assign(Object.assign({}, percentageFieldConfig), (metric.thresholds ? {
24
+ thresholds: {
25
+ mode: 'absolute',
26
+ steps: metric.thresholds
27
+ }
28
+ } : {}))
29
+ }
30
+ };
31
+ }
32
+ function createTimeSeriesPercentagePanel(title, position, dataSource, metric) {
33
+ return createTimeSeriesPanel(title, position, dataSource, metric, percentageFieldConfig.unit, percentageFieldConfig.min, percentageFieldConfig.max);
34
+ }
35
+ function createTimeSeriesPanel(title, position, dataSource, metric, unit, min, max) {
36
+ return {
37
+ title,
38
+ type: 'timeseries',
39
+ datasource: dataSource,
40
+ gridPos: position,
41
+ targets: [{
42
+ expr: metric.query,
43
+ legendFormat: metric.label
44
+ }],
45
+ fieldConfig: {
46
+ defaults: Object.assign({ unit,
47
+ min,
48
+ max }, (metric.thresholds ? {
49
+ thresholds: {
50
+ mode: 'absolute',
51
+ steps: metric.thresholds
52
+ }
53
+ } : {}))
54
+ }
55
+ };
56
+ }
57
+ function createBurnRatePanel(title, position, dataSource, metric) {
58
+ return {
59
+ type: 'stat',
60
+ title,
61
+ gridPos: position,
62
+ datasource: dataSource,
63
+ targets: [{
64
+ expr: metric.query,
65
+ legendFormat: metric.label
66
+ }],
67
+ options: {
68
+ reduceOptions: {
69
+ calcs: ['last'],
70
+ fields: '',
71
+ values: false
72
+ },
73
+ colorMode: 'value',
74
+ graphMode: 'none',
75
+ textMode: 'value'
76
+ },
77
+ fieldConfig: {
78
+ defaults: {
79
+ unit: 'none',
80
+ thresholds: {
81
+ mode: 'absolute',
82
+ steps: [
83
+ { color: 'green', value: null },
84
+ { color: 'orange', value: 1 },
85
+ { color: 'red', value: 2 }
86
+ ]
87
+ }
88
+ }
89
+ },
90
+ };
91
+ }
@@ -0,0 +1,66 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import * as grafana from '@pulumiverse/grafana';
3
+ export declare namespace Grafana {
4
+ type Threshold = {
5
+ value: number | null;
6
+ color: string;
7
+ };
8
+ type Metric = {
9
+ label: string;
10
+ query: string;
11
+ thresholds: Threshold[];
12
+ };
13
+ type Args = {
14
+ title: pulumi.Input<string>;
15
+ provider: pulumi.Input<grafana.Provider>;
16
+ tags: pulumi.Input<pulumi.Input<string>[]>;
17
+ };
18
+ type Panel = {
19
+ title: string;
20
+ gridPos: Panel.Position;
21
+ type: string;
22
+ datasource: string;
23
+ targets: {
24
+ expr: string;
25
+ legendFormat: string;
26
+ }[];
27
+ fieldConfig: {
28
+ defaults: {
29
+ unit?: string;
30
+ min?: number;
31
+ max?: number;
32
+ color?: {
33
+ mode: string;
34
+ };
35
+ thresholds?: {
36
+ mode: string;
37
+ steps: Threshold[];
38
+ };
39
+ custom?: {
40
+ lineInterpolation?: string;
41
+ spanNulls: boolean;
42
+ };
43
+ };
44
+ };
45
+ options?: {
46
+ colorMode?: string;
47
+ graphMode?: string;
48
+ justifyMode?: string;
49
+ textMode?: string;
50
+ reduceOptions?: {
51
+ calcs?: string[];
52
+ fields?: string;
53
+ values?: boolean;
54
+ };
55
+ };
56
+ };
57
+ namespace Panel {
58
+ type Position = {
59
+ x: number;
60
+ y: number;
61
+ w: number;
62
+ h: number;
63
+ };
64
+ }
65
+ }
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/grafana/dashboards/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAGhD,yBAAiB,OAAO,CAAC;IAIvB,KAAY,SAAS,GAAG;QACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,KAAY,MAAM,GAAG;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,SAAS,EAAE,CAAC;KACzB,CAAC;IAEF,KAAY,IAAI,GAAG;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KAC5C,CAAC;IAEF,KAAY,KAAK,GAAG;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,YAAY,EAAE,MAAM,CAAC;SACtB,EAAE,CAAC;QACJ,WAAW,EAAE;YACX,QAAQ,EAAE;gBACR,IAAI,CAAC,EAAE,MAAM,CAAC;gBACd,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,KAAK,CAAC,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC;iBACd,CAAC;gBACF,UAAU,CAAC,EAAE;oBACX,IAAI,EAAE,MAAM,CAAC;oBACb,KAAK,EAAE,SAAS,EAAE,CAAC;iBACpB,CAAC;gBACF,MAAM,CAAC,EAAE;oBACP,iBAAiB,CAAC,EAAE,MAAM,CAAC;oBAC3B,SAAS,EAAE,OAAO,CAAA;iBACnB,CAAA;aACF,CAAC;SACH,CAAC;QACF,OAAO,CAAC,EAAE;YACR,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE;gBACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;gBACjB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,MAAM,CAAC,EAAE,OAAO,CAAC;aAClB,CAAC;SACH,CAAC;KACH,CAAA;IAED,UAAiB,KAAK,CAAC;QACrB,KAAY,QAAQ,GAAG;YACrB,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;SACX,CAAA;KACF;CACF"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import * as grafana from '@pulumiverse/grafana';
3
+ import { queries as promQ } from '../../prometheus';
4
+ import { Grafana } from './types';
5
+ declare class WebServerSloDashboardBuilder {
6
+ name: string;
7
+ title: pulumi.Output<string>;
8
+ panels: Grafana.Panel[];
9
+ tags?: pulumi.Output<string[]>;
10
+ constructor(name: string, args: Grafana.Args);
11
+ withAvailability(target: number, window: promQ.TimeRange, dataSource: string, prometheusNamespace: string): this;
12
+ withSuccessRate(target: number, window: promQ.TimeRange, shortWindow: promQ.TimeRange, filter: string, dataSource: string, prometheusNamespace: string): this;
13
+ withLatency(target: number, targetLatency: number, window: promQ.TimeRange, shortWindow: promQ.TimeRange, filter: string, dataSource: string, prometheusNamespace: string): this;
14
+ build(provider: pulumi.Output<grafana.Provider>): pulumi.Output<grafana.oss.Dashboard>;
15
+ }
16
+ export default WebServerSloDashboardBuilder;
17
+ //# sourceMappingURL=web-server-slo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-server-slo.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/grafana/dashboards/web-server-slo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,cAAM,4BAA4B;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAM;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBAG7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,IAAI;IAMpB,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,CAAC,SAAS,EACvB,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAC1B,IAAI;IA0BP,eAAe,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,CAAC,SAAS,EACvB,WAAW,EAAE,KAAK,CAAC,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAC1B,IAAI;IAyCP,WAAW,CACT,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,KAAK,CAAC,SAAS,EACvB,WAAW,EAAE,KAAK,CAAC,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,GAC1B,IAAI;IA0DP,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;CAuBvF;AAED,eAAe,4BAA4B,CAAC"}