@studion/infra-code-blocks 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (28) hide show
  1. package/dist/components/acm-certificate/index.js +6 -1
  2. package/dist/components/cloudfront/index.d.ts.map +1 -1
  3. package/dist/components/cloudfront/index.js +97 -55
  4. package/dist/components/cloudfront/lb-cache-strategy.js +9 -1
  5. package/dist/components/cloudfront/s3-cache-strategy.js +12 -4
  6. package/dist/components/database/builder.js +34 -7
  7. package/dist/components/database/database-replica.js +27 -3
  8. package/dist/components/database/ec2-ssm-connect.d.ts +2 -1
  9. package/dist/components/database/ec2-ssm-connect.d.ts.map +1 -1
  10. package/dist/components/database/ec2-ssm-connect.js +33 -16
  11. package/dist/components/database/index.js +55 -7
  12. package/dist/components/ecs-service/index.js +70 -28
  13. package/dist/components/grafana/dashboards/panels.js +23 -17
  14. package/dist/components/grafana/dashboards/web-server-slo.js +4 -1
  15. package/dist/components/password/index.js +7 -1
  16. package/dist/components/prometheus/queries.test.js +10 -19
  17. package/dist/components/redis/elasticache-redis.js +6 -1
  18. package/dist/components/redis/upstash-redis.js +8 -2
  19. package/dist/components/static-site/index.js +7 -1
  20. package/dist/components/static-site/s3-assets.js +4 -1
  21. package/dist/components/vpc/index.js +2 -1
  22. package/dist/components/web-server/builder.js +32 -6
  23. package/dist/components/web-server/index.js +47 -15
  24. package/dist/components/web-server/load-balancer.js +13 -3
  25. package/dist/otel/builder.js +4 -1
  26. package/dist/otel/config.js +11 -14
  27. package/dist/otel/index.js +7 -3
  28. package/package.json +36 -44
@@ -5,8 +5,13 @@ const pulumi = require("@pulumi/pulumi");
5
5
  const aws = require("@pulumi/aws");
6
6
  const common_tags_1 = require("../../shared/common-tags");
7
7
  class AcmCertificate extends pulumi.ComponentResource {
8
+ certificate;
9
+ certificateValidation;
8
10
  constructor(name, args, opts = {}) {
9
- super('studion:acm-certificate:AcmCertificate', name, {}, Object.assign(Object.assign({}, opts), { aliases: [...(opts.aliases || []), { type: 'studion:acm:Certificate' }] }));
11
+ super('studion:acm-certificate:AcmCertificate', name, {}, {
12
+ ...opts,
13
+ aliases: [...(opts.aliases || []), { type: 'studion:acm:Certificate' }],
14
+ });
10
15
  this.certificate = new aws.acm.Certificate(`${args.domain}-certificate`, {
11
16
  domainName: args.domain,
12
17
  subjectAlternativeNames: args.subjectAlternativeNames,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/cloudfront/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,qBAAa,UAAW,SAAQ,MAAM,CAAC,iBAAiB;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;gBAG9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,CAAC,IAAI,EACrB,IAAI,GAAE,MAAM,CAAC,wBAA6B;IA4D5C,OAAO,CAAC,yBAAyB;IAwCjC,OAAO,CAAC,gBAAgB;IA4ExB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,kBAAkB;IA0D1B,OAAO,CAAC,iBAAiB;CA4B1B;AAED,yBAAiB,UAAU,CAAC;IAC1B,MAAM,MAAM,YAAY;QACtB,EAAE,OAAO;QACT,EAAE,OAAO;QACT,MAAM,WAAW;KAClB;IAED,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG;QACtC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QACpC,aAAa,EAAE,MAAM,CAAC,KAAK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AAC,EAAE,CAAC,CAAC;QACrD,QAAQ,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,aAAa,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,qBAAqB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C,uBAAuB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAChD,CAAC;IAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;IAEhE,MAAM,MAAM,IAAI,GAAG;QACjB;;;;;;;WAOG;QACH,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB;;;;;;;;WAQG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B;;;;;;;;;;;WAWG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD;;;WAGG;QACH,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;YAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACrC,CAAC,CAAC;KACJ,CAAC;IAEF,KAAK,YAAY,GAAG;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;;CACH"}
@@ -8,6 +8,9 @@ const acm_certificate_1 = require("../acm-certificate");
8
8
  const s3_cache_strategy_1 = require("./s3-cache-strategy");
9
9
  const lb_cache_strategy_1 = require("./lb-cache-strategy");
10
10
  class CloudFront extends pulumi.ComponentResource {
11
+ name;
12
+ distribution;
13
+ acmCertificate;
11
14
  constructor(name, args, opts = {}) {
12
15
  super('studion:cloudfront:CloudFront', name, {}, opts);
13
16
  this.name = name;
@@ -33,11 +36,14 @@ class CloudFront extends pulumi.ComponentResource {
33
36
  origins: this.createDistributionOrigins(behaviors),
34
37
  defaultCache: this.getCacheBehavior(defaultBehavior),
35
38
  orderedCaches: orderedBehaviors.length
36
- ? orderedBehaviors.map((it, idx) => (Object.assign({ pathPattern: it.pathPattern }, this.getCacheBehavior(it, idx))))
39
+ ? orderedBehaviors.map((it, idx) => this.getCacheBehavior(it, idx).apply(behavior => ({
40
+ pathPattern: it.pathPattern,
41
+ ...behavior,
42
+ })))
37
43
  : undefined,
38
44
  domain,
39
45
  certificate: certificate || this.acmCertificate
40
- ? pulumi.output(certificate !== null && certificate !== void 0 ? certificate : this.acmCertificate.certificate)
46
+ ? pulumi.output(certificate ?? this.acmCertificate.certificate)
41
47
  : undefined,
42
48
  certificateValidation: this.acmCertificate
43
49
  ? this.acmCertificate.certificateValidation
@@ -53,7 +59,6 @@ class CloudFront extends pulumi.ComponentResource {
53
59
  createDistributionOrigins(behaviors) {
54
60
  return pulumi.output(behaviors).apply(entries => {
55
61
  const origins = entries.map(it => {
56
- var _a;
57
62
  if (isS3BehaviorType(it)) {
58
63
  return getOriginWithDefaults({
59
64
  originId: it.bucket.arn,
@@ -66,16 +71,18 @@ class CloudFront extends pulumi.ComponentResource {
66
71
  else if (isLbBehaviorType(it)) {
67
72
  return getOriginWithDefaults({
68
73
  originId: it.loadBalancer.arn,
69
- domainName: (_a = it.dnsName) !== null && _a !== void 0 ? _a : it.loadBalancer.dnsName,
74
+ domainName: it.dnsName ?? it.loadBalancer.dnsName,
70
75
  });
71
76
  }
72
77
  else if (isCustomBehaviorType(it)) {
73
78
  return getOriginWithDefaults({
74
79
  originId: it.originId,
75
80
  domainName: it.domainName,
76
- customOriginConfig: Object.assign({}, (it.originProtocolPolicy
77
- ? { originProtocolPolicy: it.originProtocolPolicy }
78
- : undefined)),
81
+ customOriginConfig: {
82
+ ...(it.originProtocolPolicy
83
+ ? { originProtocolPolicy: it.originProtocolPolicy }
84
+ : undefined),
85
+ },
79
86
  });
80
87
  }
81
88
  else {
@@ -87,7 +94,6 @@ class CloudFront extends pulumi.ComponentResource {
87
94
  });
88
95
  }
89
96
  getCacheBehavior(behavior, order) {
90
- var _a, _b, _c, _d, _e;
91
97
  const isDefault = isDefaultBehavior(behavior);
92
98
  const getStrategyName = (backend) => {
93
99
  const suffix = isDefault ? 'default' : `ordered-${order}`;
@@ -99,35 +105,44 @@ class CloudFront extends pulumi.ComponentResource {
99
105
  bucket: behavior.bucket,
100
106
  cacheTtl: behavior.cacheTtl,
101
107
  }, { parent: this });
102
- return strategy.config;
108
+ return pulumi.output(strategy.config);
103
109
  }
104
110
  else if (isLbBehaviorType(behavior)) {
105
111
  const strategy = new lb_cache_strategy_1.LbCacheStrategy(getStrategyName('lb'), {
106
112
  pathPattern: behavior.pathPattern,
107
113
  loadBalancer: behavior.loadBalancer,
108
114
  }, { parent: this });
109
- return strategy.config;
115
+ return pulumi.output(strategy.config);
110
116
  }
111
117
  else if (isCustomBehaviorType(behavior)) {
112
- return Object.assign(Object.assign({ targetOriginId: behavior.originId, allowedMethods: (_a = behavior.allowedMethods) !== null && _a !== void 0 ? _a : [
113
- 'GET',
114
- 'HEAD',
115
- 'OPTIONS',
116
- 'PUT',
117
- 'POST',
118
- 'PATCH',
119
- 'DELETE',
120
- ], cachedMethods: (_b = behavior.cachedMethods) !== null && _b !== void 0 ? _b : ['GET', 'HEAD'] }, (behavior.compress != null && { compress: behavior.compress })), { viewerProtocolPolicy: 'redirect-to-https', cachePolicyId: (_c = behavior.cachePolicyId) !== null && _c !== void 0 ? _c : aws.cloudfront
121
- .getCachePolicyOutput({ name: 'Managed-CachingDisabled' })
122
- .apply(p => p.id), originRequestPolicyId: (_d = behavior.originRequestPolicyId) !== null && _d !== void 0 ? _d : aws.cloudfront
123
- .getOriginRequestPolicyOutput({
124
- name: 'Managed-AllViewerExceptHostHeader',
125
- })
126
- .apply(p => p.id), responseHeadersPolicyId: (_e = behavior.responseHeadersPolicyId) !== null && _e !== void 0 ? _e : aws.cloudfront
127
- .getResponseHeadersPolicyOutput({
128
- name: 'Managed-SecurityHeadersPolicy',
129
- })
130
- .apply(p => p.id) });
118
+ return isS3Domain(behavior.domainName).apply(isS3 => ({
119
+ targetOriginId: behavior.originId,
120
+ allowedMethods: behavior.allowedMethods ??
121
+ (isS3
122
+ ? ['GET', 'HEAD']
123
+ : ['GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE']),
124
+ cachedMethods: behavior.cachedMethods ?? ['GET', 'HEAD'],
125
+ ...(behavior.compress != null && { compress: behavior.compress }),
126
+ viewerProtocolPolicy: 'redirect-to-https',
127
+ cachePolicyId: behavior.cachePolicyId ??
128
+ aws.cloudfront
129
+ .getCachePolicyOutput({ name: 'Managed-CachingDisabled' })
130
+ .apply(p => p.id),
131
+ originRequestPolicyId: behavior.originRequestPolicyId ??
132
+ (isS3
133
+ ? undefined
134
+ : aws.cloudfront
135
+ .getOriginRequestPolicyOutput({
136
+ name: 'Managed-AllViewerExceptHostHeader',
137
+ })
138
+ .apply(p => p.id)),
139
+ responseHeadersPolicyId: behavior.responseHeadersPolicyId ??
140
+ aws.cloudfront
141
+ .getResponseHeadersPolicyOutput({
142
+ name: 'Managed-SecurityHeadersPolicy',
143
+ })
144
+ .apply(p => p.id),
145
+ }));
131
146
  }
132
147
  else {
133
148
  throw new Error('Unknown CloudFront behavior encountered during mapping to distribution cache behaviors.');
@@ -141,34 +156,51 @@ class CloudFront extends pulumi.ComponentResource {
141
156
  }, { parent: this });
142
157
  }
143
158
  createDistribution({ origins, defaultCache, orderedCaches, domain, certificate, certificateValidation, defaultRootObject, tags, }) {
144
- return new aws.cloudfront.Distribution(`${this.name}-distribution`, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ enabled: true, isIpv6Enabled: true, waitForDeployment: true, httpVersion: 'http2and3' }, (defaultRootObject && { defaultRootObject })), (certificate
145
- ? {
146
- aliases: domain
147
- ? [domain]
148
- : pulumi
149
- .all([
150
- certificate.domainName,
151
- certificate.subjectAlternativeNames,
152
- ])
153
- .apply(([dn, sans = []]) => [...new Set([dn, ...sans])]),
154
- viewerCertificate: {
155
- acmCertificateArn: certificate.arn,
156
- sslSupportMethod: 'sni-only',
157
- minimumProtocolVersion: 'TLSv1.2_2021',
158
- },
159
- }
160
- : {
161
- viewerCertificate: {
162
- cloudfrontDefaultCertificate: true,
163
- },
164
- })), { origins, defaultCacheBehavior: defaultCache }), (orderedCaches && { orderedCacheBehaviors: orderedCaches })), { priceClass: 'PriceClass_100', restrictions: {
159
+ return new aws.cloudfront.Distribution(`${this.name}-distribution`, {
160
+ enabled: true,
161
+ isIpv6Enabled: true,
162
+ waitForDeployment: true,
163
+ httpVersion: 'http2and3',
164
+ ...(defaultRootObject && { defaultRootObject }),
165
+ ...(certificate
166
+ ? {
167
+ aliases: domain
168
+ ? [domain]
169
+ : pulumi
170
+ .all([
171
+ certificate.domainName,
172
+ certificate.subjectAlternativeNames,
173
+ ])
174
+ .apply(([dn, sans = []]) => [...new Set([dn, ...sans])]),
175
+ viewerCertificate: {
176
+ acmCertificateArn: certificate.arn,
177
+ sslSupportMethod: 'sni-only',
178
+ minimumProtocolVersion: 'TLSv1.2_2021',
179
+ },
180
+ }
181
+ : {
182
+ viewerCertificate: {
183
+ cloudfrontDefaultCertificate: true,
184
+ },
185
+ }),
186
+ origins,
187
+ defaultCacheBehavior: defaultCache,
188
+ ...(orderedCaches && { orderedCacheBehaviors: orderedCaches }),
189
+ priceClass: 'PriceClass_100',
190
+ restrictions: {
165
191
  geoRestriction: { restrictionType: 'none' },
166
- }, tags: Object.assign(Object.assign({}, common_tags_1.commonTags), tags) }), Object.assign({ parent: this, aliases: [{ name: `${this.name}-cloudfront` }] }, (certificateValidation
167
- ? { dependsOn: [certificateValidation] }
168
- : undefined)));
192
+ },
193
+ tags: { ...common_tags_1.commonTags, ...tags },
194
+ }, {
195
+ parent: this,
196
+ aliases: [{ name: `${this.name}-cloudfront` }],
197
+ ...(certificateValidation
198
+ ? { dependsOn: [certificateValidation] }
199
+ : undefined),
200
+ });
169
201
  }
170
202
  createAliasRecord({ hostedZoneId, }) {
171
- return this.distribution.aliases.apply(aliases => aliases === null || aliases === void 0 ? void 0 : aliases.map((alias, index) => new aws.route53.Record(`${this.name}-cloudfront-alias-record-${index}`, {
203
+ return this.distribution.aliases.apply(aliases => aliases?.map((alias, index) => new aws.route53.Record(`${this.name}-dns-a-record-${index}`, {
172
204
  type: 'A',
173
205
  name: alias,
174
206
  zoneId: hostedZoneId,
@@ -194,6 +226,7 @@ exports.CloudFront = CloudFront;
194
226
  BehaviorType["CUSTOM"] = "custom";
195
227
  })(BehaviorType = CloudFront.BehaviorType || (CloudFront.BehaviorType = {}));
196
228
  })(CloudFront || (exports.CloudFront = CloudFront = {}));
229
+ const S3_DOMAIN_REGEX = /\.s3(?:[.\-][a-z0-9]+(?:-[a-z0-9]+)*)*\.amazonaws\.com$/;
197
230
  function isDefaultBehavior(value) {
198
231
  return value.pathPattern === '*' || value.pathPattern === '/*';
199
232
  }
@@ -206,10 +239,19 @@ function isLbBehaviorType(value) {
206
239
  function isCustomBehaviorType(value) {
207
240
  return value.type === CloudFront.BehaviorType.CUSTOM;
208
241
  }
242
+ function isS3Domain(domainName) {
243
+ return pulumi.output(domainName).apply(dn => S3_DOMAIN_REGEX.test(dn));
244
+ }
209
245
  function getOriginWithDefaults({ originId, domainName, customOriginConfig, }) {
210
246
  return {
211
247
  originId,
212
248
  domainName,
213
- customOriginConfig: Object.assign({ originProtocolPolicy: 'https-only', httpPort: 80, httpsPort: 443, originSslProtocols: ['TLSv1.2'] }, customOriginConfig),
249
+ customOriginConfig: {
250
+ originProtocolPolicy: 'https-only',
251
+ httpPort: 80,
252
+ httpsPort: 443,
253
+ originSslProtocols: ['TLSv1.2'],
254
+ ...customOriginConfig,
255
+ },
214
256
  };
215
257
  }
@@ -4,6 +4,11 @@ exports.LbCacheStrategy = void 0;
4
4
  const aws = require("@pulumi/aws");
5
5
  const pulumi = require("@pulumi/pulumi");
6
6
  class LbCacheStrategy extends pulumi.ComponentResource {
7
+ name;
8
+ pathPattern;
9
+ config;
10
+ cachePolicy;
11
+ responseHeadersPolicy;
7
12
  constructor(name, args, opts = {}) {
8
13
  super('studion:cloudfront:LbCacheStrategy', name, {}, opts);
9
14
  this.name = name;
@@ -87,7 +92,10 @@ class LbCacheStrategy extends pulumi.ComponentResource {
87
92
  }, { parent: this });
88
93
  }
89
94
  getPathConfig() {
90
- return Object.assign({ pathPattern: this.pathPattern }, this.config);
95
+ return {
96
+ pathPattern: this.pathPattern,
97
+ ...this.config,
98
+ };
91
99
  }
92
100
  }
93
101
  exports.LbCacheStrategy = LbCacheStrategy;
@@ -4,6 +4,11 @@ exports.S3CacheStrategy = void 0;
4
4
  const aws = require("@pulumi/aws");
5
5
  const pulumi = require("@pulumi/pulumi");
6
6
  class S3CacheStrategy extends pulumi.ComponentResource {
7
+ name;
8
+ pathPattern;
9
+ config;
10
+ cachePolicy;
11
+ responseHeadersPolicy;
7
12
  constructor(name, args, opts = {}) {
8
13
  super('studion:cloudfront:S3CacheStrategy', name, {}, opts);
9
14
  this.name = name;
@@ -25,9 +30,9 @@ class S3CacheStrategy extends pulumi.ComponentResource {
25
30
  createCachePolicy(ttl) {
26
31
  const enableEncoding = pulumi.output(ttl).apply(val => val !== 0);
27
32
  return new aws.cloudfront.CachePolicy(`${this.name}-cache-policy`, {
28
- defaultTtl: ttl !== null && ttl !== void 0 ? ttl : 86400, // default to 1 day
29
- minTtl: ttl !== null && ttl !== void 0 ? ttl : 60, // default to 1 minute
30
- maxTtl: ttl !== null && ttl !== void 0 ? ttl : 31536000, // default to 1 year
33
+ defaultTtl: ttl ?? 86400, // default to 1 day
34
+ minTtl: ttl ?? 60, // default to 1 minute
35
+ maxTtl: ttl ?? 31536000, // default to 1 year
31
36
  parametersInCacheKeyAndForwardedToOrigin: {
32
37
  cookiesConfig: {
33
38
  cookieBehavior: 'none',
@@ -73,7 +78,10 @@ class S3CacheStrategy extends pulumi.ComponentResource {
73
78
  }, { parent: this });
74
79
  }
75
80
  getPathConfig() {
76
- return Object.assign({ pathPattern: this.pathPattern }, this.config);
81
+ return {
82
+ pathPattern: this.pathPattern,
83
+ ...this.config,
84
+ };
77
85
  }
78
86
  }
79
87
  exports.S3CacheStrategy = S3CacheStrategy;
@@ -4,6 +4,20 @@ exports.DatabaseBuilder = void 0;
4
4
  const _1 = require(".");
5
5
  const pulumi = require("@pulumi/pulumi");
6
6
  class DatabaseBuilder {
7
+ name;
8
+ instanceConfig;
9
+ credentialsConfig;
10
+ storageConfig;
11
+ vpc;
12
+ enableMonitoring;
13
+ snapshotIdentifier;
14
+ kmsKeyId;
15
+ parameterGroupName;
16
+ tags;
17
+ createReplica;
18
+ replicaConfig;
19
+ enableSSMConnect;
20
+ ssmConnectConfig;
7
21
  constructor(name) {
8
22
  this.name = name;
9
23
  }
@@ -54,20 +68,19 @@ class DatabaseBuilder {
54
68
  return this;
55
69
  }
56
70
  build(opts = {}) {
57
- var _a, _b, _c, _d, _e;
58
- if (!this.snapshotIdentifier && !((_a = this.instanceConfig) === null || _a === void 0 ? void 0 : _a.dbName)) {
71
+ if (!this.snapshotIdentifier && !this.instanceConfig?.dbName) {
59
72
  throw new Error('DbName not provided. Make sure to call DatabaseBuilder.withInstance() and set dbName.');
60
73
  }
61
- if (!this.snapshotIdentifier && !((_b = this.credentialsConfig) === null || _b === void 0 ? void 0 : _b.username)) {
74
+ if (!this.snapshotIdentifier && !this.credentialsConfig?.username) {
62
75
  throw new Error('Username not provided. Make sure to call DatabaseBuilder.withCredentials() and set username.');
63
76
  }
64
- if (this.snapshotIdentifier && ((_c = this.instanceConfig) === null || _c === void 0 ? void 0 : _c.dbName)) {
77
+ if (this.snapshotIdentifier && this.instanceConfig?.dbName) {
65
78
  throw new Error(`You can't set dbName when using snapshotIdentifier.`);
66
79
  }
67
- if (this.snapshotIdentifier && ((_d = this.credentialsConfig) === null || _d === void 0 ? void 0 : _d.username)) {
80
+ if (this.snapshotIdentifier && this.credentialsConfig?.username) {
68
81
  throw new Error(`You can't set username when using snapshotIdentifier.`);
69
82
  }
70
- if (this.createReplica && ((_e = this.replicaConfig) === null || _e === void 0 ? void 0 : _e.enableMonitoring)) {
83
+ if (this.createReplica && this.replicaConfig?.enableMonitoring) {
71
84
  if (!this.enableMonitoring && !this.replicaConfig.monitoringRole) {
72
85
  throw new Error(`If you want enable monitoring on the replica instance either provide monitoring role or
73
86
  enable monitoring on the primary instance to reuse the same monitoring role.`);
@@ -76,7 +89,21 @@ class DatabaseBuilder {
76
89
  if (!this.vpc) {
77
90
  throw new Error('VPC not provided. Make sure to call DatabaseBuilder.withVpc().');
78
91
  }
79
- return new _1.Database(this.name, Object.assign(Object.assign(Object.assign(Object.assign({}, this.instanceConfig), this.credentialsConfig), this.storageConfig), { vpc: this.vpc, enableMonitoring: this.enableMonitoring, snapshotIdentifier: this.snapshotIdentifier, kmsKeyId: this.kmsKeyId, parameterGroupName: this.parameterGroupName, tags: this.tags, createReplica: this.createReplica, replicaConfig: this.replicaConfig, enableSSMConnect: this.enableSSMConnect, ssmConnectConfig: this.ssmConnectConfig }), opts);
92
+ return new _1.Database(this.name, {
93
+ ...this.instanceConfig,
94
+ ...this.credentialsConfig,
95
+ ...this.storageConfig,
96
+ vpc: this.vpc,
97
+ enableMonitoring: this.enableMonitoring,
98
+ snapshotIdentifier: this.snapshotIdentifier,
99
+ kmsKeyId: this.kmsKeyId,
100
+ parameterGroupName: this.parameterGroupName,
101
+ tags: this.tags,
102
+ createReplica: this.createReplica,
103
+ replicaConfig: this.replicaConfig,
104
+ enableSSMConnect: this.enableSSMConnect,
105
+ ssmConnectConfig: this.ssmConnectConfig,
106
+ }, opts);
80
107
  }
81
108
  }
82
109
  exports.DatabaseBuilder = DatabaseBuilder;
@@ -16,14 +16,18 @@ const defaults = {
16
16
  engineVersion: '17.2',
17
17
  };
18
18
  class DatabaseReplica extends pulumi.ComponentResource {
19
+ name;
20
+ instance;
19
21
  constructor(name, args, opts = {}) {
20
- super('studion:database:DatabaseReplica', name, {}, Object.assign(Object.assign({}, opts), { aliases: [...(opts.aliases || []), { type: 'studion:DatabaseReplica' }] }));
22
+ super('studion:database:DatabaseReplica', name, {}, {
23
+ ...opts,
24
+ aliases: [...(opts.aliases || []), { type: 'studion:DatabaseReplica' }],
25
+ });
21
26
  this.name = name;
22
27
  this.instance = this.createDatabaseInstance(args, opts);
23
28
  this.registerOutputs();
24
29
  }
25
30
  createDatabaseInstance(args, opts) {
26
- var _a;
27
31
  const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
28
32
  const monitoringOptions = argsWithDefaults.monitoringRole
29
33
  ? {
@@ -33,7 +37,27 @@ class DatabaseReplica extends pulumi.ComponentResource {
33
37
  performanceInsightsRetentionPeriod: 7,
34
38
  }
35
39
  : {};
36
- const instance = new aws.rds.Instance(`${this.name}-rds`, Object.assign(Object.assign({ identifierPrefix: `${this.name}-`, engine: 'postgres', engineVersion: argsWithDefaults.engineVersion, allocatedStorage: argsWithDefaults.allocatedStorage, maxAllocatedStorage: argsWithDefaults.maxAllocatedStorage, instanceClass: argsWithDefaults.instanceClass, vpcSecurityGroupIds: [argsWithDefaults.dbSecurityGroup.id], dbSubnetGroupName: (_a = argsWithDefaults.dbSubnetGroup) === null || _a === void 0 ? void 0 : _a.name, multiAz: argsWithDefaults.multiAz, applyImmediately: argsWithDefaults.applyImmediately, allowMajorVersionUpgrade: argsWithDefaults.allowMajorVersionUpgrade, autoMinorVersionUpgrade: argsWithDefaults.autoMinorVersionUpgrade, replicateSourceDb: argsWithDefaults.replicateSourceDb, parameterGroupName: argsWithDefaults.parameterGroupName, storageEncrypted: true, publiclyAccessible: false, skipFinalSnapshot: true }, monitoringOptions), { tags: Object.assign(Object.assign({}, common_tags_1.commonTags), argsWithDefaults.tags) }), { parent: this, dependsOn: opts.dependsOn });
40
+ const instance = new aws.rds.Instance(`${this.name}-rds`, {
41
+ identifierPrefix: `${this.name}-`,
42
+ engine: 'postgres',
43
+ engineVersion: argsWithDefaults.engineVersion,
44
+ allocatedStorage: argsWithDefaults.allocatedStorage,
45
+ maxAllocatedStorage: argsWithDefaults.maxAllocatedStorage,
46
+ instanceClass: argsWithDefaults.instanceClass,
47
+ vpcSecurityGroupIds: [argsWithDefaults.dbSecurityGroup.id],
48
+ dbSubnetGroupName: argsWithDefaults.dbSubnetGroup?.name,
49
+ multiAz: argsWithDefaults.multiAz,
50
+ applyImmediately: argsWithDefaults.applyImmediately,
51
+ allowMajorVersionUpgrade: argsWithDefaults.allowMajorVersionUpgrade,
52
+ autoMinorVersionUpgrade: argsWithDefaults.autoMinorVersionUpgrade,
53
+ replicateSourceDb: argsWithDefaults.replicateSourceDb,
54
+ parameterGroupName: argsWithDefaults.parameterGroupName,
55
+ storageEncrypted: true,
56
+ publiclyAccessible: false,
57
+ skipFinalSnapshot: true,
58
+ ...monitoringOptions,
59
+ tags: { ...common_tags_1.commonTags, ...argsWithDefaults.tags },
60
+ }, { parent: this, dependsOn: opts.dependsOn });
37
61
  return instance;
38
62
  }
39
63
  }
@@ -4,6 +4,7 @@ import * as pulumi from '@pulumi/pulumi';
4
4
  export declare namespace Ec2SSMConnect {
5
5
  type Args = {
6
6
  vpc: pulumi.Input<awsx.ec2.Vpc>;
7
+ ami?: pulumi.Input<string>;
7
8
  instanceType?: pulumi.Input<string>;
8
9
  tags?: pulumi.Input<{
9
10
  [key: string]: pulumi.Input<string>;
@@ -19,7 +20,7 @@ export declare class Ec2SSMConnect extends pulumi.ComponentResource {
19
20
  ec2MessagesVpcEndpoint: aws.ec2.VpcEndpoint;
20
21
  ssmMessagesVpcEndpoint: aws.ec2.VpcEndpoint;
21
22
  ec2: aws.ec2.Instance;
22
- ami: pulumi.Output<aws.ec2.GetAmiResult>;
23
+ amiResult?: pulumi.Output<aws.ec2.GetAmiResult>;
23
24
  constructor(name: string, args: Ec2SSMConnect.Args, opts?: pulumi.ComponentResourceOptions);
24
25
  }
25
26
  //# sourceMappingURL=ec2-ssm-connect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ec2-ssm-connect.d.ts","sourceRoot":"","sources":["../../../src/components/database/ec2-ssm-connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAOzC,yBAAiB,aAAa,CAAC;IAC7B,KAAY,IAAI,GAAG;QACjB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;YAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACrC,CAAC,CAAC;KACJ,CAAC;CACH;AAMD,qBAAa,aAAc,SAAQ,MAAM,CAAC,iBAAiB;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC;IACxC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;IACnB,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC;IACpC,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IACpC,sBAAsB,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5C,sBAAsB,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;IAC5C,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,C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AG,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAG9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,CAAC,IAAI,EACxB,IAAI,GAAE,MAAM,CAAC,wBAA6B;CAqK7C"}
@@ -11,26 +11,39 @@ const defaults = {
11
11
  instanceType: 't4g.nano',
12
12
  };
13
13
  class Ec2SSMConnect extends pulumi.ComponentResource {
14
+ name;
15
+ ec2SecurityGroup;
16
+ role;
17
+ ssmProfile;
18
+ ssmVpcEndpoint;
19
+ ec2MessagesVpcEndpoint;
20
+ ssmMessagesVpcEndpoint;
21
+ ec2;
22
+ amiResult;
14
23
  constructor(name, args, opts = {}) {
15
- super('studion:database:Ec2SSMConnect', name, {}, Object.assign(Object.assign({}, opts), { aliases: [
24
+ super('studion:database:Ec2SSMConnect', name, {}, {
25
+ ...opts,
26
+ aliases: [
16
27
  ...(opts.aliases || []),
17
28
  { type: 'studion:Ec2BastionSSMConnect' },
18
- ] }));
19
- const { vpc, instanceType, tags } = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
29
+ ],
30
+ });
31
+ const { vpc, ami, instanceType, tags } = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
20
32
  this.name = name;
21
33
  const vpcOutput = pulumi.output(vpc);
22
34
  const subnetId = vpcOutput.privateSubnetIds.apply(ids => ids[0]);
23
- this.ami = aws.ec2.getAmiOutput({
24
- filters: [
25
- { name: 'architecture', values: ['arm64'] },
26
- { name: 'root-device-type', values: ['ebs'] },
27
- { name: 'virtualization-type', values: ['hvm'] },
28
- { name: 'ena-support', values: ['true'] },
29
- ],
30
- owners: ['amazon'],
31
- nameRegex: 'al2023-ami-2023\.[0-9]+\.[0-9]+\.[0-9]+-kernel-[0-9]+\.[0-9]+-arm64',
32
- mostRecent: true,
33
- });
35
+ const amiId = ami ??
36
+ (this.amiResult = aws.ec2.getAmiOutput({
37
+ filters: [
38
+ { name: 'architecture', values: ['arm64'] },
39
+ { name: 'root-device-type', values: ['ebs'] },
40
+ { name: 'virtualization-type', values: ['hvm'] },
41
+ { name: 'ena-support', values: ['true'] },
42
+ ],
43
+ owners: ['amazon'],
44
+ nameRegex: 'al2023-ami-2023\.[0-9]+\.[0-9]+\.[0-9]+-kernel-[0-9]+\.[0-9]+-arm64',
45
+ mostRecent: true,
46
+ })).id;
34
47
  this.ec2SecurityGroup = new aws.ec2.SecurityGroup(`${this.name}-ec2-security-group`, {
35
48
  ingress: [
36
49
  {
@@ -76,13 +89,17 @@ class Ec2SSMConnect extends pulumi.ComponentResource {
76
89
  tags: common_tags_1.commonTags,
77
90
  }, { parent: this, dependsOn: [ssmPolicyAttachment] });
78
91
  this.ec2 = new aws.ec2.Instance(`${this.name}-ec2`, {
79
- ami: this.ami.id,
92
+ ami: amiId,
80
93
  associatePublicIpAddress: false,
81
94
  instanceType,
82
95
  iamInstanceProfile: this.ssmProfile.name,
83
96
  subnetId,
84
97
  vpcSecurityGroupIds: [this.ec2SecurityGroup.id],
85
- tags: Object.assign(Object.assign(Object.assign({}, common_tags_1.commonTags), { Name: `${this.name}-ec2` }), tags),
98
+ tags: {
99
+ ...common_tags_1.commonTags,
100
+ Name: `${this.name}-ec2`,
101
+ ...tags,
102
+ },
86
103
  }, { parent: this });
87
104
  this.ssmVpcEndpoint = new aws.ec2.VpcEndpoint(`${this.name}-ssm-vpc-endpoint`, {
88
105
  vpcId: vpcOutput.vpcId,
@@ -21,8 +21,22 @@ const defaults = {
21
21
  engineVersion: '17.2',
22
22
  };
23
23
  class Database extends pulumi.ComponentResource {
24
+ name;
25
+ instance;
26
+ vpc;
27
+ dbSubnetGroup;
28
+ dbSecurityGroup;
29
+ password;
30
+ kmsKeyId;
31
+ monitoringRole;
32
+ encryptedSnapshotCopy;
33
+ replica;
34
+ ec2SSMConnect;
24
35
  constructor(name, args, opts = {}) {
25
- super('studion:database:Database', name, {}, Object.assign(Object.assign({}, opts), { aliases: [...(opts.aliases || []), { type: 'studion:Database' }] }));
36
+ super('studion:database:Database', name, {}, {
37
+ ...opts,
38
+ aliases: [...(opts.aliases || []), { type: 'studion:Database' }],
39
+ });
26
40
  this.name = name;
27
41
  const argsWithDefaults = (0, merge_with_defaults_1.mergeWithDefaults)(defaults, args);
28
42
  const { vpc, kmsKeyId, enableMonitoring, snapshotIdentifier, createReplica, replicaConfig = {}, enableSSMConnect, ssmConnectConfig = {}, } = argsWithDefaults;
@@ -117,14 +131,21 @@ class Database extends pulumi.ComponentResource {
117
131
  const monitoringRole = config.enableMonitoring
118
132
  ? config.monitoringRole || this.monitoringRole
119
133
  : undefined;
120
- const replica = new database_replica_1.DatabaseReplica(`${this.name}-replica`, Object.assign({ replicateSourceDb: this.instance.dbInstanceIdentifier.apply(id => id), dbSecurityGroup: this.dbSecurityGroup, monitoringRole }, config), { parent: this, dependsOn: [this.instance] });
134
+ const replica = new database_replica_1.DatabaseReplica(`${this.name}-replica`, {
135
+ replicateSourceDb: this.instance.dbInstanceIdentifier.apply(id => id),
136
+ dbSecurityGroup: this.dbSecurityGroup,
137
+ monitoringRole,
138
+ ...config,
139
+ }, { parent: this, dependsOn: [this.instance] });
121
140
  return replica;
122
141
  }
123
142
  createEc2SSMConnect(config = {}) {
124
- return new ec2_ssm_connect_1.Ec2SSMConnect(`${this.name}-ssm-connect`, Object.assign({ vpc: this.vpc }, config), { parent: this });
143
+ return new ec2_ssm_connect_1.Ec2SSMConnect(`${this.name}-ssm-connect`, {
144
+ vpc: this.vpc,
145
+ ...config,
146
+ }, { parent: this });
125
147
  }
126
148
  createDatabaseInstance(args) {
127
- var _a, _b;
128
149
  const monitoringOptions = args.enableMonitoring && this.monitoringRole
129
150
  ? {
130
151
  monitoringInterval: 60,
@@ -133,11 +154,38 @@ class Database extends pulumi.ComponentResource {
133
154
  performanceInsightsRetentionPeriod: 7,
134
155
  }
135
156
  : {};
136
- const instance = new awsNative.rds.DbInstance(`${this.name}-rds`, Object.assign(Object.assign({ dbInstanceIdentifier: `${this.name}-db-instance`, engine: 'postgres', engineVersion: args.engineVersion, dbInstanceClass: args.instanceClass, dbName: args.dbName, masterUsername: args.username, masterUserPassword: this.password.value, dbSubnetGroupName: this.dbSubnetGroup.name, vpcSecurityGroups: [this.dbSecurityGroup.id], allocatedStorage: (_a = args.allocatedStorage) === null || _a === void 0 ? void 0 : _a.toString(), maxAllocatedStorage: args.maxAllocatedStorage, multiAz: args.multiAz, applyImmediately: args.applyImmediately, allowMajorVersionUpgrade: args.allowMajorVersionUpgrade, autoMinorVersionUpgrade: args.autoMinorVersionUpgrade, kmsKeyId: this.kmsKeyId, storageEncrypted: true, publiclyAccessible: false, preferredMaintenanceWindow: 'Mon:07:00-Mon:07:30', preferredBackupWindow: '06:00-06:30', backupRetentionPeriod: 14, caCertificateIdentifier: 'rds-ca-rsa2048-g1', dbParameterGroupName: args.parameterGroupName, dbSnapshotIdentifier: (_b = this.encryptedSnapshotCopy) === null || _b === void 0 ? void 0 : _b.targetDbSnapshotIdentifier }, monitoringOptions), { tags: pulumi
157
+ const instance = new awsNative.rds.DbInstance(`${this.name}-rds`, {
158
+ dbInstanceIdentifier: `${this.name}-db-instance`,
159
+ engine: 'postgres',
160
+ engineVersion: args.engineVersion,
161
+ dbInstanceClass: args.instanceClass,
162
+ dbName: args.dbName,
163
+ masterUsername: args.username,
164
+ masterUserPassword: this.password.value,
165
+ dbSubnetGroupName: this.dbSubnetGroup.name,
166
+ vpcSecurityGroups: [this.dbSecurityGroup.id],
167
+ allocatedStorage: args.allocatedStorage?.toString(),
168
+ maxAllocatedStorage: args.maxAllocatedStorage,
169
+ multiAz: args.multiAz,
170
+ applyImmediately: args.applyImmediately,
171
+ allowMajorVersionUpgrade: args.allowMajorVersionUpgrade,
172
+ autoMinorVersionUpgrade: args.autoMinorVersionUpgrade,
173
+ kmsKeyId: this.kmsKeyId,
174
+ storageEncrypted: true,
175
+ publiclyAccessible: false,
176
+ preferredMaintenanceWindow: 'Mon:07:00-Mon:07:30',
177
+ preferredBackupWindow: '06:00-06:30',
178
+ backupRetentionPeriod: 14,
179
+ caCertificateIdentifier: 'rds-ca-rsa2048-g1',
180
+ dbParameterGroupName: args.parameterGroupName,
181
+ dbSnapshotIdentifier: this.encryptedSnapshotCopy?.targetDbSnapshotIdentifier,
182
+ ...monitoringOptions,
183
+ tags: pulumi
137
184
  .output(args.tags)
138
185
  .apply(tags => [
139
- ...Object.entries(Object.assign(Object.assign({}, common_tags_1.commonTags), tags)).map(([key, value]) => ({ key, value })),
140
- ]) }), { parent: this, dependsOn: [this.password] });
186
+ ...Object.entries({ ...common_tags_1.commonTags, ...tags }).map(([key, value]) => ({ key, value })),
187
+ ]),
188
+ }, { parent: this, dependsOn: [this.password] });
141
189
  return instance;
142
190
  }
143
191
  }