@studion/infra-code-blocks 0.7.0 → 0.8.0-next.1

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 +365 -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,365 @@
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 ||
43
+ defaults.taskExecutionRoleInlinePolicies);
44
+ const taskRoleInlinePolicies = pulumi.output(args.taskRoleInlinePolicies || defaults.taskRoleInlinePolicies);
45
+ this.name = name;
46
+ this.securityGroups = [];
47
+ this.vpc = pulumi.output(argsWithDefaults.vpc);
48
+ this.logGroup = this.createLogGroup();
49
+ this.taskExecutionRole = this.createTaskExecutionRole(taskExecutionRoleInlinePolicies);
50
+ this.taskRole = this.createTaskRole(taskRoleInlinePolicies);
51
+ pulumi.output(argsWithDefaults.volumes).apply(volume => {
52
+ if (volume.length) {
53
+ this.persistentStorage = this.createPersistentStorage(this.vpc);
54
+ }
55
+ });
56
+ 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));
57
+ if (argsWithDefaults.enableServiceAutoDiscovery) {
58
+ this.serviceDiscoveryService = this.createServiceDiscovery();
59
+ }
60
+ this.service = this.createEcsService(argsWithDefaults);
61
+ if (argsWithDefaults.autoscaling.enabled) {
62
+ this.enableAutoscaling(pulumi.output(argsWithDefaults.cluster).name, this.service.name, argsWithDefaults.autoscaling.minCount, argsWithDefaults.autoscaling.maxCount);
63
+ }
64
+ this.registerOutputs();
65
+ }
66
+ static createTcpPortMapping(port) {
67
+ return {
68
+ containerPort: port,
69
+ hostPort: port,
70
+ protocol: 'tcp',
71
+ };
72
+ }
73
+ createLogGroup() {
74
+ const logGroup = new aws.cloudwatch.LogGroup(`${this.name}-log-group`, {
75
+ retentionInDays: 14,
76
+ namePrefix: `/ecs/${this.name}-`,
77
+ tags: constants_1.commonTags,
78
+ }, { parent: this });
79
+ return logGroup;
80
+ }
81
+ createTaskDefinition(containers, volumes, taskExecutionRole, taskRole, size, tags) {
82
+ const stack = pulumi.getStack();
83
+ const { cpu, memory } = pulumi.output(size).apply(parseSize);
84
+ const containerDefinitions = containers.map(container => {
85
+ return this.createContainerDefinition(container);
86
+ });
87
+ const taskDefinitionVolumes = this.createTaskDefinitionVolumes(volumes);
88
+ return pulumi.all(containerDefinitions).apply(containerDefinitions => {
89
+ return taskDefinitionVolumes.apply(volumes => {
90
+ 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,
91
+ 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 });
92
+ });
93
+ });
94
+ }
95
+ createTaskDefinitionVolumes(volumes) {
96
+ return volumes.apply(volumes => {
97
+ if (!volumes.length || !this.persistentStorage)
98
+ return;
99
+ return volumes.map(volume => ({
100
+ name: pulumi.output(volume).name,
101
+ efsVolumeConfiguration: {
102
+ fileSystemId: this.persistentStorage.fileSystem.id,
103
+ transitEncryption: 'ENABLED',
104
+ authorizationConfig: {
105
+ accessPointId: this.persistentStorage.accessPoint.id,
106
+ iam: 'ENABLED',
107
+ },
108
+ },
109
+ }));
110
+ });
111
+ }
112
+ createContainerDefinition(container) {
113
+ return this.logGroup.name.apply(logGroupName => (Object.assign(Object.assign(Object.assign(Object.assign({}, container), { readonlyRootFilesystem: false }), (container.mountPoints && {
114
+ mountPoints: container.mountPoints.map(mountPoint => pulumi
115
+ .all([
116
+ mountPoint.sourceVolume,
117
+ mountPoint.containerPath,
118
+ mountPoint.readOnly,
119
+ ])
120
+ .apply(([sourceVolume, containerPath, readOnly]) => ({
121
+ containerPath,
122
+ sourceVolume,
123
+ readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : false,
124
+ }))),
125
+ })), { logConfiguration: {
126
+ logDriver: 'awslogs',
127
+ options: {
128
+ 'awslogs-group': logGroupName,
129
+ 'awslogs-region': awsRegion,
130
+ 'awslogs-stream-prefix': 'ecs',
131
+ },
132
+ } })));
133
+ }
134
+ createTaskExecutionRole(inlinePolicies) {
135
+ const secretManagerSecretsInlinePolicy = {
136
+ name: `${this.name}-secret-manager-access`,
137
+ policy: JSON.stringify({
138
+ Version: '2012-10-17',
139
+ Statement: [
140
+ {
141
+ Sid: 'AllowContainerToGetSecretManagerSecrets',
142
+ Effect: 'Allow',
143
+ Action: ['ssm:GetParameters', 'secretsmanager:GetSecretValue'],
144
+ Resource: '*',
145
+ },
146
+ ],
147
+ }),
148
+ };
149
+ const taskExecutionRole = new aws.iam.Role(`${this.name}-task-exec-role`, {
150
+ namePrefix: `${this.name}-task-exec-role-`,
151
+ assumeRolePolicy: policies_1.assumeRolePolicy,
152
+ managedPolicyArns: [
153
+ 'arn:aws:iam::aws:policy/CloudWatchFullAccess',
154
+ 'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess',
155
+ ],
156
+ inlinePolicies: inlinePolicies.apply(policies => [
157
+ secretManagerSecretsInlinePolicy,
158
+ ...policies,
159
+ ]),
160
+ tags: constants_1.commonTags,
161
+ }, { parent: this });
162
+ return taskExecutionRole;
163
+ }
164
+ createTaskRole(inlinePolicies) {
165
+ const execCmdInlinePolicy = {
166
+ name: `${this.name}-exec`,
167
+ policy: JSON.stringify({
168
+ Version: '2012-10-17',
169
+ Statement: [
170
+ {
171
+ Sid: 'AllowContainerToCreateECSExecSSMChannel',
172
+ Effect: 'Allow',
173
+ Action: [
174
+ 'ssmmessages:CreateControlChannel',
175
+ 'ssmmessages:CreateDataChannel',
176
+ 'ssmmessages:OpenControlChannel',
177
+ 'ssmmessages:OpenDataChannel',
178
+ ],
179
+ Resource: '*',
180
+ },
181
+ ],
182
+ }),
183
+ };
184
+ return new aws.iam.Role(`${this.name}-task-role`, {
185
+ namePrefix: `${this.name}-task-role-`,
186
+ assumeRolePolicy: policies_1.assumeRolePolicy,
187
+ inlinePolicies: inlinePolicies.apply(policies => [
188
+ execCmdInlinePolicy,
189
+ ...policies,
190
+ ]),
191
+ tags: constants_1.commonTags,
192
+ }, { parent: this });
193
+ }
194
+ addSecurityGroup(securityGroup) {
195
+ this.securityGroups.push(pulumi.output(securityGroup));
196
+ }
197
+ createDefaultSecurityGroup() {
198
+ const securityGroup = new aws.ec2.SecurityGroup(`${this.name}-service-security-group`, {
199
+ vpcId: this.vpc.vpcId,
200
+ ingress: [
201
+ {
202
+ fromPort: 0,
203
+ toPort: 0,
204
+ protocol: '-1',
205
+ cidrBlocks: [this.vpc.vpc.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 });
218
+ this.addSecurityGroup(securityGroup);
219
+ }
220
+ createEcsService(ecsServiceArgs) {
221
+ if (!this.securityGroups.length)
222
+ this.createDefaultSecurityGroup();
223
+ const networkConfiguration = {
224
+ assignPublicIp: ecsServiceArgs.assignPublicIp,
225
+ subnets: ecsServiceArgs.assignPublicIp
226
+ ? this.vpc.publicSubnetIds
227
+ : this.vpc.privateSubnetIds,
228
+ securityGroups: pulumi
229
+ .all(this.securityGroups)
230
+ .apply(groups => groups.map(it => it.id)),
231
+ };
232
+ 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 && {
233
+ loadBalancers: ecsServiceArgs.loadBalancers,
234
+ })), (this.serviceDiscoveryService && {
235
+ serviceRegistries: {
236
+ registryArn: this.serviceDiscoveryService.arn,
237
+ },
238
+ })), { tags: Object.assign(Object.assign({}, constants_1.commonTags), ecsServiceArgs.tags) }), { parent: this });
239
+ }
240
+ createServiceDiscovery() {
241
+ const privateDnsNamespace = this.createPrivateDnsNameSpace();
242
+ return new aws.servicediscovery.Service(`${this.name}-service-discovery`, {
243
+ name: this.name,
244
+ dnsConfig: {
245
+ namespaceId: privateDnsNamespace.id,
246
+ dnsRecords: [
247
+ {
248
+ ttl: 10,
249
+ type: 'A',
250
+ },
251
+ ],
252
+ routingPolicy: 'MULTIVALUE',
253
+ },
254
+ tags: constants_1.commonTags,
255
+ }, { parent: this });
256
+ }
257
+ createPrivateDnsNameSpace() {
258
+ return new aws.servicediscovery.PrivateDnsNamespace(`${this.name}-private-dns-namespace`, {
259
+ vpc: this.vpc.vpcId,
260
+ name: this.name,
261
+ tags: constants_1.commonTags,
262
+ }, { parent: this });
263
+ }
264
+ enableAutoscaling(clusterName, serviceName, minCount, maxCount) {
265
+ const autoscalingTarget = new aws.appautoscaling.Target(`${this.name}-autoscale-target`, {
266
+ minCapacity: minCount,
267
+ maxCapacity: maxCount,
268
+ resourceId: pulumi.interpolate `service/${clusterName}/${serviceName}`,
269
+ serviceNamespace: 'ecs',
270
+ scalableDimension: 'ecs:service:DesiredCount',
271
+ tags: constants_1.commonTags,
272
+ }, { parent: this });
273
+ const memoryAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-memory-autoscale-policy`, {
274
+ policyType: 'TargetTrackingScaling',
275
+ resourceId: autoscalingTarget.resourceId,
276
+ scalableDimension: autoscalingTarget.scalableDimension,
277
+ serviceNamespace: autoscalingTarget.serviceNamespace,
278
+ targetTrackingScalingPolicyConfiguration: {
279
+ predefinedMetricSpecification: {
280
+ predefinedMetricType: 'ECSServiceAverageMemoryUtilization',
281
+ },
282
+ targetValue: 70,
283
+ },
284
+ }, { parent: this });
285
+ const cpuAutoscalingPolicy = new aws.appautoscaling.Policy(`${this.name}-cpu-autoscale-policy`, {
286
+ policyType: 'TargetTrackingScaling',
287
+ resourceId: autoscalingTarget.resourceId,
288
+ scalableDimension: autoscalingTarget.scalableDimension,
289
+ serviceNamespace: autoscalingTarget.serviceNamespace,
290
+ targetTrackingScalingPolicyConfiguration: {
291
+ predefinedMetricSpecification: {
292
+ predefinedMetricType: 'ECSServiceAverageCPUUtilization',
293
+ },
294
+ targetValue: 70,
295
+ },
296
+ }, { parent: this });
297
+ }
298
+ createPersistentStorage(vpc) {
299
+ const efs = new aws.efs.FileSystem(`${this.name}-efs`, {
300
+ encrypted: true,
301
+ lifecyclePolicies: [
302
+ {
303
+ transitionToPrimaryStorageClass: 'AFTER_1_ACCESS',
304
+ },
305
+ {
306
+ transitionToIa: 'AFTER_7_DAYS',
307
+ },
308
+ ],
309
+ performanceMode: 'generalPurpose',
310
+ throughputMode: 'bursting',
311
+ tags: Object.assign(Object.assign({}, constants_1.commonTags), { Name: `${this.name}-data` }),
312
+ }, { parent: this });
313
+ const securityGroup = new aws.ec2.SecurityGroup(`${this.name}-persistent-storage-security-group`, {
314
+ vpcId: vpc.vpcId,
315
+ ingress: [
316
+ {
317
+ fromPort: 2049,
318
+ toPort: 2049,
319
+ protocol: 'tcp',
320
+ cidrBlocks: [vpc.vpc.cidrBlock],
321
+ },
322
+ ],
323
+ tags: constants_1.commonTags,
324
+ }, { parent: this });
325
+ this.vpc.privateSubnetIds.apply(subnetIds => {
326
+ subnetIds.forEach(subnetId => {
327
+ const mountTarget = new aws.efs.MountTarget(`${this.name}-mount-target-${subnetId}`, {
328
+ fileSystemId: efs.id,
329
+ subnetId,
330
+ securityGroups: [securityGroup.id],
331
+ }, { parent: this });
332
+ });
333
+ });
334
+ const accessPoint = new aws.efs.AccessPoint(`${this.name}-efs-ap`, {
335
+ fileSystemId: efs.id,
336
+ posixUser: {
337
+ uid: FIRST_POSIX_NON_ROOT_USER.userId,
338
+ gid: FIRST_POSIX_NON_ROOT_USER.groupId,
339
+ },
340
+ rootDirectory: {
341
+ path: '/data',
342
+ creationInfo: {
343
+ ownerUid: FIRST_POSIX_NON_ROOT_USER.userId,
344
+ ownerGid: FIRST_POSIX_NON_ROOT_USER.groupId,
345
+ permissions: FIRST_POSIX_NON_ROOT_USER.permissions,
346
+ },
347
+ },
348
+ });
349
+ return { fileSystem: efs, accessPoint };
350
+ }
351
+ }
352
+ exports.EcsService = EcsService;
353
+ function parseSize(size) {
354
+ const mapCapabilities = ({ cpu, memory }) => ({
355
+ cpu: String(cpu),
356
+ memory: String(memory),
357
+ });
358
+ if (typeof size === 'string') {
359
+ return mapCapabilities(constants_1.PredefinedSize[size]);
360
+ }
361
+ if (typeof size === 'object') {
362
+ return mapCapabilities(size);
363
+ }
364
+ throw Error('Incorrect EcsService size argument');
365
+ }
@@ -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"}