@studion/infra-code-blocks 0.6.12 → 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 (105) hide show
  1. package/README.md +81 -2
  2. package/dist/components/acm-certificate.d.ts +1 -0
  3. package/dist/components/acm-certificate.d.ts.map +1 -0
  4. package/dist/components/database-replica.d.ts +2 -1
  5. package/dist/components/database-replica.d.ts.map +1 -0
  6. package/dist/components/database-replica.js +1 -1
  7. package/dist/components/database.d.ts +2 -1
  8. package/dist/components/database.d.ts.map +1 -0
  9. package/dist/components/database.js +1 -1
  10. package/dist/components/ec2-ssm-connect.d.ts +1 -0
  11. package/dist/components/ec2-ssm-connect.d.ts.map +1 -0
  12. package/dist/components/ecs-service.d.ts +16 -2
  13. package/dist/components/ecs-service.d.ts.map +1 -0
  14. package/dist/components/ecs-service.js +54 -19
  15. package/dist/components/mongo.d.ts +5 -2
  16. package/dist/components/mongo.d.ts.map +1 -0
  17. package/dist/components/mongo.js +8 -2
  18. package/dist/components/nuxt-ssr.d.ts +1 -0
  19. package/dist/components/nuxt-ssr.d.ts.map +1 -0
  20. package/dist/components/password.d.ts +1 -0
  21. package/dist/components/password.d.ts.map +1 -0
  22. package/dist/components/project.d.ts +1 -0
  23. package/dist/components/project.d.ts.map +1 -0
  24. package/dist/components/redis.d.ts +1 -0
  25. package/dist/components/redis.d.ts.map +1 -0
  26. package/dist/components/static-site.d.ts +1 -0
  27. package/dist/components/static-site.d.ts.map +1 -0
  28. package/dist/components/web-server.d.ts +2 -1
  29. package/dist/components/web-server.d.ts.map +1 -0
  30. package/dist/components/web-server.js +2 -1
  31. package/dist/constants.d.ts +1 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/constants.js +4 -4
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +2 -0
  37. package/dist/types/pulumi.d.ts +5 -0
  38. package/dist/types/pulumi.d.ts.map +1 -0
  39. package/dist/types/pulumi.js +2 -0
  40. package/dist/types/size.d.ts +1 -0
  41. package/dist/types/size.d.ts.map +1 -0
  42. package/dist/v2/components/ecs-service/index.d.ts +156 -0
  43. package/dist/v2/components/ecs-service/index.d.ts.map +1 -0
  44. package/dist/v2/components/ecs-service/index.js +362 -0
  45. package/dist/v2/components/ecs-service/policies.d.ts +3 -0
  46. package/dist/v2/components/ecs-service/policies.d.ts.map +1 -0
  47. package/dist/v2/components/ecs-service/policies.js +16 -0
  48. package/dist/v2/components/grafana/dashboards/index.d.ts +3 -0
  49. package/dist/v2/components/grafana/dashboards/index.d.ts.map +1 -0
  50. package/dist/v2/components/grafana/dashboards/index.js +6 -0
  51. package/dist/v2/components/grafana/dashboards/panels.d.ts +6 -0
  52. package/dist/v2/components/grafana/dashboards/panels.d.ts.map +1 -0
  53. package/dist/v2/components/grafana/dashboards/panels.js +91 -0
  54. package/dist/v2/components/grafana/dashboards/types.d.ts +66 -0
  55. package/dist/v2/components/grafana/dashboards/types.d.ts.map +1 -0
  56. package/dist/v2/components/grafana/dashboards/types.js +2 -0
  57. package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts +17 -0
  58. package/dist/v2/components/grafana/dashboards/web-server-slo.d.ts.map +1 -0
  59. package/dist/v2/components/grafana/dashboards/web-server-slo.js +98 -0
  60. package/dist/v2/components/grafana/index.d.ts +2 -0
  61. package/dist/v2/components/grafana/index.d.ts.map +1 -0
  62. package/dist/v2/components/grafana/index.js +4 -0
  63. package/dist/v2/components/prometheus/index.d.ts +2 -0
  64. package/dist/v2/components/prometheus/index.d.ts.map +1 -0
  65. package/dist/v2/components/prometheus/index.js +4 -0
  66. package/dist/v2/components/prometheus/queries.d.ts +10 -0
  67. package/dist/v2/components/prometheus/queries.d.ts.map +1 -0
  68. package/dist/v2/components/prometheus/queries.js +61 -0
  69. package/dist/v2/components/prometheus/queries.test.d.ts +2 -0
  70. package/dist/v2/components/prometheus/queries.test.d.ts.map +1 -0
  71. package/dist/v2/components/prometheus/queries.test.js +52 -0
  72. package/dist/v2/components/web-server/builder.d.ts +34 -0
  73. package/dist/v2/components/web-server/builder.d.ts.map +1 -0
  74. package/dist/v2/components/web-server/builder.js +72 -0
  75. package/dist/v2/components/web-server/index.d.ts +58 -0
  76. package/dist/v2/components/web-server/index.d.ts.map +1 -0
  77. package/dist/v2/components/web-server/index.js +169 -0
  78. package/dist/v2/components/web-server/load-balancer.d.ts +25 -0
  79. package/dist/v2/components/web-server/load-balancer.d.ts.map +1 -0
  80. package/dist/v2/components/web-server/load-balancer.js +106 -0
  81. package/dist/v2/index.d.ts +13 -0
  82. package/dist/v2/index.d.ts.map +1 -0
  83. package/dist/v2/index.js +16 -0
  84. package/dist/v2/otel/batch-processor.d.ts +14 -0
  85. package/dist/v2/otel/batch-processor.d.ts.map +1 -0
  86. package/dist/v2/otel/batch-processor.js +9 -0
  87. package/dist/v2/otel/builder.d.ts +27 -0
  88. package/dist/v2/otel/builder.d.ts.map +1 -0
  89. package/dist/v2/otel/builder.js +110 -0
  90. package/dist/v2/otel/config.d.ts +26 -0
  91. package/dist/v2/otel/config.d.ts.map +1 -0
  92. package/dist/v2/otel/config.js +159 -0
  93. package/dist/v2/otel/index.d.ts +94 -0
  94. package/dist/v2/otel/index.d.ts.map +1 -0
  95. package/dist/v2/otel/index.js +82 -0
  96. package/dist/v2/otel/memory-limiter-processor.d.ts +13 -0
  97. package/dist/v2/otel/memory-limiter-processor.d.ts.map +1 -0
  98. package/dist/v2/otel/memory-limiter-processor.js +8 -0
  99. package/dist/v2/otel/otlp-receiver.d.ts +19 -0
  100. package/dist/v2/otel/otlp-receiver.d.ts.map +1 -0
  101. package/dist/v2/otel/otlp-receiver.js +11 -0
  102. package/dist/v2/otel/prometheus-remote-write-exporter.d.ts +11 -0
  103. package/dist/v2/otel/prometheus-remote-write-exporter.d.ts.map +1 -0
  104. package/dist/v2/otel/prometheus-remote-write-exporter.js +2 -0
  105. package/package.json +37 -13
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OtelCollectorConfigBuilder = void 0;
4
+ const otlp_receiver_1 = require("./otlp-receiver");
5
+ class OtelCollectorConfigBuilder {
6
+ constructor() {
7
+ this._receivers = {};
8
+ this._processors = {};
9
+ this._exporters = {};
10
+ this._extensions = {};
11
+ this._service = {
12
+ pipelines: {}
13
+ };
14
+ }
15
+ withOTLPReceiver(protocols = ['http']) {
16
+ if (!protocols.length) {
17
+ throw new Error('At least one OTLP receiver protocol should be provided');
18
+ }
19
+ const protocolsConfig = protocols.reduce((all, current) => {
20
+ const protocolConfig = otlp_receiver_1.Protocol[current];
21
+ if (!protocolConfig) {
22
+ throw new Error(`OTLP receiver protocol ${current} is not supported`);
23
+ }
24
+ return Object.assign(Object.assign({}, all), { [current]: protocolConfig });
25
+ }, {});
26
+ this._receivers.otlp = { protocols: protocolsConfig };
27
+ return this;
28
+ }
29
+ withBatchProcessor(name = 'batch', size = 8192, maxSize = 10000, timeout = '5s') {
30
+ this._processors[name] = {
31
+ 'send_batch_size': size,
32
+ 'send_batch_max_size': maxSize,
33
+ timeout
34
+ };
35
+ return this;
36
+ }
37
+ withMemoryLimiterProcessor(checkInterval = '1s', limitPercentage = 80, spikeLimitPercentage = 15) {
38
+ this._processors.memory_limiter = {
39
+ check_interval: checkInterval,
40
+ limit_percentage: limitPercentage,
41
+ spike_limit_percentage: spikeLimitPercentage
42
+ };
43
+ return this;
44
+ }
45
+ withAWSXRayExporter(region) {
46
+ this._exporters.awsxray = { region };
47
+ return this;
48
+ }
49
+ withHealthCheckExtension(endpoint = '0.0.0.0:13133') {
50
+ this._extensions.health_check = { endpoint };
51
+ return this;
52
+ }
53
+ withPprofExtension(endpoint = '0.0.0.0:1777') {
54
+ this._extensions.pprof = { endpoint };
55
+ return this;
56
+ }
57
+ withAPS(namespace, endpoint, region) {
58
+ this._exporters.prometheusremotewrite = {
59
+ endpoint,
60
+ namespace,
61
+ auth: {
62
+ authenticator: 'sigv4auth'
63
+ }
64
+ };
65
+ this._extensions.sigv4auth = {
66
+ region,
67
+ service: 'aps'
68
+ };
69
+ return this;
70
+ }
71
+ withDebug(verbosity = 'detailed') {
72
+ this._exporters.debug = { verbosity };
73
+ return this;
74
+ }
75
+ withTelemetry(logLevel = 'error', metricsVerbosity = 'basic') {
76
+ this._service.telemetry = {
77
+ logs: { level: logLevel },
78
+ metrics: { level: metricsVerbosity }
79
+ };
80
+ return this;
81
+ }
82
+ withMetricsPipeline(receivers, processors, exporters) {
83
+ this._service.pipelines.metrics = {
84
+ receivers,
85
+ processors,
86
+ exporters
87
+ };
88
+ return this;
89
+ }
90
+ withTracesPipeline(receivers, processors, exporters) {
91
+ this._service.pipelines.traces = {
92
+ receivers,
93
+ processors,
94
+ exporters
95
+ };
96
+ return this;
97
+ }
98
+ withDefault(prometheusNamespace, prometheusWriteEndpoint, awsRegion) {
99
+ return this.withOTLPReceiver(['http'])
100
+ .withMemoryLimiterProcessor()
101
+ .withBatchProcessor('batch/metrics')
102
+ .withBatchProcessor('batch/traces', 2000, 5000, '2s')
103
+ .withAPS(prometheusNamespace, prometheusWriteEndpoint, awsRegion)
104
+ .withAWSXRayExporter(awsRegion)
105
+ .withHealthCheckExtension()
106
+ .withMetricsPipeline(['otlp'], ['memory_limiter', 'batch/metrics'], ['prometheusremotewrite'])
107
+ .withTracesPipeline(['otlp'], ['memory_limiter', 'batch/traces'], ['awsxray'])
108
+ .withTelemetry();
109
+ }
110
+ build() {
111
+ this.validatePipelineComponents('metrics');
112
+ this.validatePipelineComponents('traces');
113
+ this.validatePipelineProcessorOrder('metrics');
114
+ this.validatePipelineProcessorOrder('traces');
115
+ // FIX: Fix type inference
116
+ const extensions = Object.keys(this._extensions);
117
+ if (extensions.length) {
118
+ this._service.extensions = extensions;
119
+ }
120
+ // TODO: Add schema validation (non-empty receivers, non-empty receiver protocols)
121
+ return {
122
+ receivers: this._receivers,
123
+ processors: this._processors,
124
+ exporters: this._exporters,
125
+ extensions: this._extensions,
126
+ service: this._service
127
+ };
128
+ }
129
+ validatePipelineProcessorOrder(pipelineType) {
130
+ const pipeline = this._service.pipelines[pipelineType];
131
+ if (!pipeline)
132
+ return;
133
+ const { processors } = pipeline;
134
+ const memoryLimiterIndex = processors
135
+ .findIndex(processor => processor === 'memory_limiter');
136
+ if (memoryLimiterIndex > 0) {
137
+ throw new Error(`memory_limiter processor is not the first processor in the ${pipelineType} pipeline.`);
138
+ }
139
+ }
140
+ validatePipelineComponents(pipelineType) {
141
+ var _a, _b, _c;
142
+ (_a = this._service.pipelines[pipelineType]) === null || _a === void 0 ? void 0 : _a.receivers.forEach(receiver => {
143
+ if (!this._receivers[receiver]) {
144
+ throw new Error(`Receiver '${receiver}' is used in ${pipelineType} pipeline but not defined`);
145
+ }
146
+ });
147
+ (_b = this._service.pipelines[pipelineType]) === null || _b === void 0 ? void 0 : _b.processors.forEach(processor => {
148
+ if (!this._processors[processor]) {
149
+ throw new Error(`Processor '${processor}' is used in ${pipelineType} pipeline but not defined`);
150
+ }
151
+ });
152
+ (_c = this._service.pipelines[pipelineType]) === null || _c === void 0 ? void 0 : _c.exporters.forEach(exporter => {
153
+ if (!this._exporters[exporter]) {
154
+ throw new Error(`Exporter '${exporter}' is used in ${pipelineType} pipeline but not defined`);
155
+ }
156
+ });
157
+ }
158
+ }
159
+ exports.OtelCollectorConfigBuilder = OtelCollectorConfigBuilder;
@@ -0,0 +1,94 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import { EcsService } from '../components/ecs-service';
3
+ import { OTLPReceiver } from './otlp-receiver';
4
+ import { BatchProcessor } from './batch-processor';
5
+ import { MemoryLimiterProcessor } from './memory-limiter-processor';
6
+ import { PrometheusRemoteWriteExporter } from './prometheus-remote-write-exporter';
7
+ export declare namespace OtelCollector {
8
+ type Receiver = {
9
+ otlp?: OTLPReceiver.Config;
10
+ };
11
+ type ReceiverType = keyof Receiver;
12
+ type Processor = {
13
+ batch?: BatchProcessor.Config;
14
+ memory_limiter?: MemoryLimiterProcessor.Config;
15
+ } & {
16
+ [name: string]: BatchProcessor.Config;
17
+ };
18
+ type ProcessorType = keyof Processor;
19
+ type AwsXRayExporterConfig = {
20
+ region: string;
21
+ endpoint?: string;
22
+ };
23
+ type DebugExportedConfig = {
24
+ verbosity: string;
25
+ };
26
+ type Exporter = {
27
+ prometheusremotewrite?: PrometheusRemoteWriteExporter.Config;
28
+ awsxray?: AwsXRayExporterConfig;
29
+ debug?: DebugExportedConfig;
30
+ };
31
+ type ExporterType = keyof Exporter;
32
+ type SigV4AuthExtensionConfig = {
33
+ region: string;
34
+ service: string;
35
+ };
36
+ type HealthCheckExtensionConfig = {
37
+ endpoint: string;
38
+ };
39
+ type PprofExtensionConfig = {
40
+ endpoint: string;
41
+ };
42
+ type Extension = {
43
+ sigv4auth?: SigV4AuthExtensionConfig;
44
+ health_check?: HealthCheckExtensionConfig;
45
+ pprof?: PprofExtensionConfig;
46
+ };
47
+ type ExtensionType = keyof Extension;
48
+ type PipelineConfig = {
49
+ receivers: ReceiverType[];
50
+ processors: ProcessorType[];
51
+ exporters: ExporterType[];
52
+ };
53
+ type TelemetryConfig = {
54
+ logs?: {
55
+ level: string;
56
+ };
57
+ metrics?: {
58
+ level: string;
59
+ };
60
+ };
61
+ type Service = {
62
+ pipelines: {
63
+ metrics?: PipelineConfig;
64
+ traces?: PipelineConfig;
65
+ };
66
+ extensions?: ExtensionType[];
67
+ telemetry?: TelemetryConfig;
68
+ };
69
+ type Config = {
70
+ receivers: Receiver;
71
+ processors: Processor;
72
+ exporters: Exporter;
73
+ extensions: Extension;
74
+ service: Service;
75
+ };
76
+ type Opts = {
77
+ containerName?: pulumi.Input<string>;
78
+ configVolumeName?: pulumi.Input<string>;
79
+ taskRoleInlinePolicies?: pulumi.Input<pulumi.Input<EcsService.RoleInlinePolicy>[]>;
80
+ };
81
+ }
82
+ export declare class OtelCollector {
83
+ config: pulumi.Output<OtelCollector.Config>;
84
+ configVolume: pulumi.Output<string>;
85
+ container: pulumi.Output<EcsService.Container>;
86
+ configContainer: EcsService.Container;
87
+ taskRoleInlinePolicies: OtelCollector.Opts['taskRoleInlinePolicies'];
88
+ constructor(serviceName: pulumi.Input<string>, env: pulumi.Input<string>, config: pulumi.Input<OtelCollector.Config>, opts?: OtelCollector.Opts);
89
+ private createContainer;
90
+ private getCollectorEnvironment;
91
+ private getCollectorPortMappings;
92
+ private createConfigContainer;
93
+ }
94
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v2/otel/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,yBAAiB,aAAa,CAAC;IAC7B,KAAY,QAAQ,GAAG;QACrB,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC;KAC5B,CAAC;IACF,KAAY,YAAY,GAAG,MAAM,QAAQ,CAAC;IAE1C,KAAY,SAAS,GAAG;QACtB,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;QAC9B,cAAc,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC;KAChD,GAAG;QACF,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;KACvC,CAAC;IACF,KAAY,aAAa,GAAG,MAAM,SAAS,CAAC;IAE5C,KAAY,qBAAqB,GAAG;QAClC,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAY,mBAAmB,GAAG;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ulumi = require("@pulumi/pulumi");
5
+ const yaml = require("yaml");
6
+ class OtelCollector {
7
+ constructor(serviceName, env, config, opts = {}) {
8
+ const containerName = opts.containerName || pulumi.interpolate `${serviceName}-otel-collector`;
9
+ const configVolumeName = opts.configVolumeName || 'otel-collector-config-volume';
10
+ this.configVolume = pulumi.output(configVolumeName);
11
+ this.taskRoleInlinePolicies = opts.taskRoleInlinePolicies || [];
12
+ this.config = pulumi.output(config);
13
+ this.configContainer = this.createConfigContainer(this.config, configVolumeName);
14
+ this.container = this.createContainer(containerName, this.config, configVolumeName, serviceName, env);
15
+ }
16
+ createContainer(containerName, config, configVolumeName, serviceName, env) {
17
+ return pulumi
18
+ .all([containerName, config, configVolumeName, serviceName, env])
19
+ .apply(([containerName, config, configVolumeName, serviceName, env]) => ({
20
+ name: containerName,
21
+ image: 'otel/opentelemetry-collector-contrib:0.123.0',
22
+ portMappings: this.getCollectorPortMappings(config),
23
+ mountPoints: [
24
+ {
25
+ sourceVolume: configVolumeName,
26
+ containerPath: '/etc/otelcol-contrib',
27
+ readOnly: true,
28
+ },
29
+ ],
30
+ dependsOn: [
31
+ {
32
+ containerName: this.configContainer.name,
33
+ condition: 'COMPLETE',
34
+ },
35
+ ],
36
+ environment: this.getCollectorEnvironment(serviceName, env),
37
+ }));
38
+ }
39
+ getCollectorEnvironment(serviceName, env) {
40
+ return [
41
+ {
42
+ name: 'OTEL_RESOURCE_ATTRIBUTES',
43
+ value: `service.name=${serviceName},env=${env}`,
44
+ },
45
+ ];
46
+ }
47
+ getCollectorPortMappings(config) {
48
+ var _a, _b;
49
+ const hasOTLPGRpcReceiver = !!((_a = config.receivers.otlp) === null || _a === void 0 ? void 0 : _a.protocols.grpc);
50
+ const hasOTLPHttpReceiver = !!((_b = config.receivers.otlp) === null || _b === void 0 ? void 0 : _b.protocols.http);
51
+ const protocol = 'tcp';
52
+ return [
53
+ ...(hasOTLPGRpcReceiver
54
+ ? [{ containerPort: 4317, hostPort: 4317, protocol }]
55
+ : []),
56
+ ...(hasOTLPHttpReceiver
57
+ ? [{ containerPort: 4318, hostPort: 4318, protocol }]
58
+ : []),
59
+ // TODO: Expose 8888 for collector telemetry
60
+ { containerPort: 13133, hostPort: 13133, protocol },
61
+ ];
62
+ }
63
+ createConfigContainer(config, volume) {
64
+ return {
65
+ name: 'otel-config-writer',
66
+ image: 'amazonlinux:latest',
67
+ essential: false,
68
+ command: config.apply(config => [
69
+ 'sh',
70
+ '-c',
71
+ `echo '${yaml.stringify(config)}' > /etc/otelcol-contrib/config.yaml`,
72
+ ]),
73
+ mountPoints: [
74
+ {
75
+ sourceVolume: volume,
76
+ containerPath: '/etc/otelcol-contrib',
77
+ },
78
+ ],
79
+ };
80
+ }
81
+ }
82
+ exports.OtelCollector = OtelCollector;
@@ -0,0 +1,13 @@
1
+ export declare namespace MemoryLimiterProcessor {
2
+ type Config = {
3
+ check_interval: string;
4
+ limit_percentage: number;
5
+ spike_limit_percentage: number;
6
+ };
7
+ }
8
+ export declare const defaults: {
9
+ checkInterval: string;
10
+ limitPercentage: number;
11
+ spikeLimitPercentage: number;
12
+ };
13
+ //# sourceMappingURL=memory-limiter-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-limiter-processor.d.ts","sourceRoot":"","sources":["../../../src/v2/otel/memory-limiter-processor.ts"],"names":[],"mappings":"AAAA,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,MAAM,GAAG;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,sBAAsB,EAAE,MAAM,CAAC;KAChC,CAAC;CACH;AAED,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaults = void 0;
4
+ exports.defaults = {
5
+ checkInterval: '1s',
6
+ limitPercentage: 80,
7
+ spikeLimitPercentage: 15
8
+ };
@@ -0,0 +1,19 @@
1
+ export declare namespace OTLPReceiver {
2
+ type Protocol = 'http' | 'grpc';
3
+ type Config = {
4
+ protocols: {
5
+ [K in Protocol]?: {
6
+ endpoint: string;
7
+ };
8
+ };
9
+ };
10
+ }
11
+ export declare const Protocol: {
12
+ grpc: {
13
+ endpoint: string;
14
+ };
15
+ http: {
16
+ endpoint: string;
17
+ };
18
+ };
19
+ //# sourceMappingURL=otlp-receiver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-receiver.d.ts","sourceRoot":"","sources":["../../../src/v2/otel/otlp-receiver.ts"],"names":[],"mappings":"AAAA,yBAAiB,YAAY,CAAC;IAC5B,KAAY,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACvC,KAAY,MAAM,GAAG;QACnB,SAAS,EAAE;aACR,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE;gBAChB,QAAQ,EAAE,MAAM,CAAC;aAClB;SACF,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,QAAQ;;;;;;;CAOpB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Protocol = void 0;
4
+ exports.Protocol = {
5
+ grpc: {
6
+ endpoint: '0.0.0.0:4317'
7
+ },
8
+ http: {
9
+ endpoint: '0.0.0.0:4318'
10
+ }
11
+ };
@@ -0,0 +1,11 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ export declare namespace PrometheusRemoteWriteExporter {
3
+ type Config = {
4
+ namespace: pulumi.Input<string>;
5
+ endpoint: pulumi.Input<string>;
6
+ auth?: {
7
+ authenticator: pulumi.Input<string>;
8
+ };
9
+ };
10
+ }
11
+ //# sourceMappingURL=prometheus-remote-write-exporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prometheus-remote-write-exporter.d.ts","sourceRoot":"","sources":["../../../src/v2/otel/prometheus-remote-write-exporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,MAAM,GAAG;QACnB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE;YACL,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACrC,CAAC;KACH,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studion/infra-code-blocks",
3
- "version": "0.6.12",
3
+ "version": "0.8.0-next.0",
4
4
  "description": "Studion common infra components",
5
5
  "keywords": [
6
6
  "infrastructure",
@@ -21,34 +21,58 @@
21
21
  },
22
22
  "main": "dist/index.js",
23
23
  "files": [
24
- "dist"
24
+ "dist",
25
+ "!dist/*.tsbuildinfo"
25
26
  ],
26
27
  "scripts": {
27
28
  "clean": "rm -rf dist",
28
- "build": "npm run clean && tsc",
29
+ "build": "npm run clean && tsc -b src",
29
30
  "format": "prettier -w .",
30
31
  "release": "npm run build && release-it",
31
- "test": ""
32
+ "test": "TS_NODE_PROJECT=tests node --test --test-concurrency=none -r ts-node/register tests/**[!build]/index.test.ts",
33
+ "test:build": "npm run build && tstyche build"
32
34
  },
33
35
  "prettier": "@studion/prettier-config",
34
36
  "dependencies": {
35
- "@pulumi/aws": "^5.0.0",
36
- "@pulumi/awsx": "^1.0.0",
37
- "@pulumi/pulumi": "^3.0.0",
38
- "@pulumi/random": "^4.14.0",
39
- "@upstash/pulumi": "^0.2.0"
37
+ "@pulumi/aws": "^6.66.3",
38
+ "@pulumi/awsx": "^2.21.0",
39
+ "@pulumi/pulumi": "^3.146.0",
40
+ "@pulumi/random": "^4.17.0",
41
+ "@pulumiverse/grafana": "^0.16.3",
42
+ "@upstash/pulumi": "^0.3.14",
43
+ "yaml": "^2.7.1"
40
44
  },
41
45
  "devDependencies": {
46
+ "@aws-sdk/client-acm": "^3.782.0",
47
+ "@aws-sdk/client-application-auto-scaling": "^3.758.0",
48
+ "@aws-sdk/client-cloudwatch-logs": "^3.767.0",
49
+ "@aws-sdk/client-ec2": "^3.767.0",
50
+ "@aws-sdk/client-ecs": "^3.766.0",
51
+ "@aws-sdk/client-efs": "^3.758.0",
52
+ "@aws-sdk/client-elastic-load-balancing-v2": "^3.764.0",
53
+ "@aws-sdk/client-route-53": "^3.782.0",
54
+ "@aws-sdk/client-servicediscovery": "^3.758.0",
42
55
  "@studion/prettier-config": "^0.1.0",
43
- "@types/node": "^18",
44
- "prettier": "^3.0.3",
45
- "release-it": "^16.2.1",
46
- "typescript": "^5.2.2"
56
+ "@types/node": "^22",
57
+ "exponential-backoff": "^3.1.2",
58
+ "http-status": "^2.1.0",
59
+ "nanospinner": "^1.2.2",
60
+ "pathe": "^2.0.3",
61
+ "prettier": "^3.4.2",
62
+ "release-it": "^18.1.1",
63
+ "ts-node": "^10.9.2",
64
+ "tsconfig-paths": "^4.2.0",
65
+ "tstyche": "^4.0.0-beta.9",
66
+ "typescript": "^5.7.3",
67
+ "undici": "^6.21.2"
47
68
  },
48
69
  "publishConfig": {
49
70
  "access": "public"
50
71
  },
51
72
  "release-it": {
73
+ "git": {
74
+ "commitMessage": "chore: release ${version}"
75
+ },
52
76
  "github": {
53
77
  "release": true
54
78
  }