@hiiretail/gcp-infra-generators 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/common-resources/monitoring/templates/alerts/generic-infra.yaml +37 -2
- package/dist/generators/common-resources/pubsub/index.js +46 -9
- package/dist/generators/common-resources/pubsub/templates/pubsub-external-publishers/bindings.yaml +8 -0
- package/dist/generators/common-resources/pubsub/templates/pubsub-external-publishers/terragrunt.hcl +37 -0
- package/dist/node_modules/.package-lock.json +416 -417
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/bucket.js +5 -5
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.d.ts +1 -0
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.js +10 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/storage.js +1 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.d.ts +4 -4
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.js +4 -4
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.d.ts +1 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.js +2 -2
- package/dist/node_modules/@google-cloud/storage/build/esm/src/bucket.js +5 -5
- package/dist/node_modules/@google-cloud/storage/build/esm/src/file.d.ts +1 -0
- package/dist/node_modules/@google-cloud/storage/build/esm/src/file.js +10 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/storage.js +1 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.d.ts +4 -4
- package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.js +4 -4
- package/dist/node_modules/@google-cloud/storage/build/esm/src/util.d.ts +1 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/util.js +2 -2
- package/dist/node_modules/@google-cloud/storage/package.json +5 -5
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/node_modules/@google-cloud/storage/CHANGELOG.md +0 -1769
|
@@ -19,6 +19,7 @@ cloud_function:
|
|
|
19
19
|
- resource.label.function_name
|
|
20
20
|
documentation:
|
|
21
21
|
subject: 'Function: `$${resource.label.function_name}`'
|
|
22
|
+
content: 'Review the function in Cloud Functions: https://console.cloud.google.com/run?deploymentType=function&project=<%-projectId%>'
|
|
22
23
|
cloud_run:
|
|
23
24
|
error_count:
|
|
24
25
|
display_name: "[P3] <%-clan%> - Cloud Run | Error rate"
|
|
@@ -40,6 +41,7 @@ cloud_run:
|
|
|
40
41
|
- resource.label.service_name
|
|
41
42
|
documentation:
|
|
42
43
|
subject: 'Service: `$${resource.label.service_name}`'
|
|
44
|
+
content: 'Review the service in Cloud Run: https://console.cloud.google.com/run?project=<%-projectId%>'
|
|
43
45
|
request_latency:
|
|
44
46
|
display_name: "[P3] <%-clan%> - Cloud Run | Request Latency"
|
|
45
47
|
conditions:
|
|
@@ -59,6 +61,7 @@ cloud_run:
|
|
|
59
61
|
- resource.label.service_name
|
|
60
62
|
documentation:
|
|
61
63
|
subject: 'Service: `$${resource.label.service_name}`'
|
|
64
|
+
content: 'Review the service in Cloud Run: https://console.cloud.google.com/run?project=<%-projectId%>'
|
|
62
65
|
cpu_utilization:
|
|
63
66
|
display_name: "[P3] <%-clan%> - Cloud Run | CPU Utilization"
|
|
64
67
|
conditions:
|
|
@@ -72,12 +75,13 @@ cloud_run:
|
|
|
72
75
|
duration: 300s
|
|
73
76
|
aggregations:
|
|
74
77
|
- alignment_period: 60s
|
|
75
|
-
per_series_aligner:
|
|
78
|
+
per_series_aligner: ALIGN_PERCENTILE_99
|
|
76
79
|
cross_series_reducer: REDUCE_PERCENTILE_99
|
|
77
80
|
group_by_fields:
|
|
78
81
|
- resource.label.service_name
|
|
79
82
|
documentation:
|
|
80
83
|
subject: 'Service: `$${resource.label.service_name}`'
|
|
84
|
+
content: 'Review the service in Cloud Run: https://console.cloud.google.com/run?project=<%-projectId%>'
|
|
81
85
|
memory_utilization:
|
|
82
86
|
display_name: "[P3] <%-clan%> - Cloud Run | Memory Utilization"
|
|
83
87
|
conditions:
|
|
@@ -91,12 +95,13 @@ cloud_run:
|
|
|
91
95
|
duration: 300s
|
|
92
96
|
aggregations:
|
|
93
97
|
- alignment_period: 60s
|
|
94
|
-
per_series_aligner:
|
|
98
|
+
per_series_aligner: ALIGN_PERCENTILE_99
|
|
95
99
|
cross_series_reducer: REDUCE_PERCENTILE_99
|
|
96
100
|
group_by_fields:
|
|
97
101
|
- resource.label.service_name
|
|
98
102
|
documentation:
|
|
99
103
|
subject: 'Service: `$${resource.label.service_name}`'
|
|
104
|
+
content: 'Review the service in Cloud Run: https://console.cloud.google.com/run?project=<%-projectId%>'
|
|
100
105
|
startup_latency:
|
|
101
106
|
display_name: "[P4] <%-clan%> - Cloud Run | Startup Latency"
|
|
102
107
|
conditions:
|
|
@@ -116,6 +121,7 @@ cloud_run:
|
|
|
116
121
|
- resource.label.service_name
|
|
117
122
|
documentation:
|
|
118
123
|
subject: 'Service: `$${resource.label.service_name}`'
|
|
124
|
+
content: 'Review the service in Cloud Run: https://console.cloud.google.com/run?project=<%-projectId%>'
|
|
119
125
|
cloud_scheduler:
|
|
120
126
|
failed_job:
|
|
121
127
|
display_name: "[P4] <%-clan%> - Cloud Scheduler | Job Failed"
|
|
@@ -135,6 +141,7 @@ cloud_scheduler:
|
|
|
135
141
|
- resource.label.job_id
|
|
136
142
|
documentation:
|
|
137
143
|
subject: 'Job: `$${resource.label.job_id}`'
|
|
144
|
+
content: 'Review the job in Cloud Scheduler: https://console.cloud.google.com/cloudscheduler?project=<%-projectId%>'
|
|
138
145
|
failed_executions:
|
|
139
146
|
display_name: "[P3] <%-clan%> - Cloud Scheduler | Failed Executions"
|
|
140
147
|
conditions:
|
|
@@ -155,6 +162,7 @@ cloud_scheduler:
|
|
|
155
162
|
- resource.label.job_id
|
|
156
163
|
documentation:
|
|
157
164
|
subject: 'Job: `$${resource.label.job_id}`'
|
|
165
|
+
content: 'Review the job in Cloud Scheduler: https://console.cloud.google.com/cloudscheduler?project=<%-projectId%>'
|
|
158
166
|
cloud_sql:
|
|
159
167
|
cpu_over_65:
|
|
160
168
|
display_name: "[P3] <%-clan%> - CloudSQL | CPU over 65%"
|
|
@@ -175,6 +183,7 @@ cloud_sql:
|
|
|
175
183
|
- resource.label.database_id
|
|
176
184
|
documentation:
|
|
177
185
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
186
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
178
187
|
cpu_over_85:
|
|
179
188
|
display_name: "[P3] <%-clan%> - CloudSQL | CPU over 85%"
|
|
180
189
|
conditions:
|
|
@@ -194,6 +203,7 @@ cloud_sql:
|
|
|
194
203
|
- resource.label.database_id
|
|
195
204
|
documentation:
|
|
196
205
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
206
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
197
207
|
cpu_over_90:
|
|
198
208
|
display_name: "[P3] <%-clan%> - CloudSQL | CPU over 90%"
|
|
199
209
|
conditions:
|
|
@@ -213,6 +223,7 @@ cloud_sql:
|
|
|
213
223
|
- resource.label.database_id
|
|
214
224
|
documentation:
|
|
215
225
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
226
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
216
227
|
memory_over_90:
|
|
217
228
|
display_name: "[P2] <%-clan%> - CloudSQL | Memory utilization above 90%"
|
|
218
229
|
conditions:
|
|
@@ -232,6 +243,7 @@ cloud_sql:
|
|
|
232
243
|
- resource.label.database_id
|
|
233
244
|
documentation:
|
|
234
245
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
246
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
235
247
|
query_over_1s:
|
|
236
248
|
display_name: "[P4] <%-clan%> - CloudSQL | Slow query"
|
|
237
249
|
conditions:
|
|
@@ -251,6 +263,7 @@ cloud_sql:
|
|
|
251
263
|
- resource.label.resource_id
|
|
252
264
|
documentation:
|
|
253
265
|
subject: 'Database: `$${resource.label.resource_id}`'
|
|
266
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
254
267
|
postgresql_connections:
|
|
255
268
|
display_name: "[P3] <%-clan%> - CloudSQL | PostgreSQL Connections"
|
|
256
269
|
conditions:
|
|
@@ -269,6 +282,7 @@ cloud_sql:
|
|
|
269
282
|
- resource.label.database_id
|
|
270
283
|
documentation:
|
|
271
284
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
285
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
272
286
|
aggregated_lock_time:
|
|
273
287
|
display_name: "[P4] <%-clan%> - CloudSQL | Aggregated Lock Time"
|
|
274
288
|
conditions:
|
|
@@ -287,6 +301,7 @@ cloud_sql:
|
|
|
287
301
|
- resource.label.database_id
|
|
288
302
|
documentation:
|
|
289
303
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
304
|
+
content: 'Review the database in Cloud SQL: https://console.cloud.google.com/sql/instances?project=<%-projectId%>'
|
|
290
305
|
firestore:
|
|
291
306
|
request_latencies:
|
|
292
307
|
display_name: "[P3] <%-clan%> - Firestore | High request latencies"
|
|
@@ -306,6 +321,7 @@ firestore:
|
|
|
306
321
|
- resource.label.database_id
|
|
307
322
|
documentation:
|
|
308
323
|
subject: 'Database: `$${resource.label.database_id}`'
|
|
324
|
+
content: 'Review the database in Firestore: https://console.cloud.google.com/firestore/databases?project=<%-projectId%>'
|
|
309
325
|
failed_commits:
|
|
310
326
|
display_name: "[P3] <%-clan%> - Firestore | High failed commits errors"
|
|
311
327
|
conditions:
|
|
@@ -324,6 +340,9 @@ firestore:
|
|
|
324
340
|
cross_series_reducer: REDUCE_SUM
|
|
325
341
|
group_by_fields:
|
|
326
342
|
- metric.label."response_code"
|
|
343
|
+
documentation:
|
|
344
|
+
subject: 'Database: `$${resource.label.database_id}`'
|
|
345
|
+
content: 'Review the database in Firestore: https://console.cloud.google.com/firestore/databases?project=<%-projectId%>'
|
|
327
346
|
memorystore:
|
|
328
347
|
memory_over_50:
|
|
329
348
|
display_name: "[P3] <%-clan%> - Memorystore | Memory over 50%"
|
|
@@ -344,6 +363,7 @@ memorystore:
|
|
|
344
363
|
- resource.label.instance_id
|
|
345
364
|
documentation:
|
|
346
365
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
366
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
347
367
|
memory_over_75:
|
|
348
368
|
display_name: "[P3] <%-clan%> - Memorystore | Memory over 75%"
|
|
349
369
|
conditions:
|
|
@@ -363,6 +383,7 @@ memorystore:
|
|
|
363
383
|
- resource.label.instance_id
|
|
364
384
|
documentation:
|
|
365
385
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
386
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
366
387
|
memory_over_90:
|
|
367
388
|
display_name: "[P2] <%-clan%> - Memorystore | Memory over 90%"
|
|
368
389
|
conditions:
|
|
@@ -382,6 +403,7 @@ memorystore:
|
|
|
382
403
|
- resource.label.instance_id
|
|
383
404
|
documentation:
|
|
384
405
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
406
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
385
407
|
cpu_utilization:
|
|
386
408
|
display_name: "[P2] <%-clan%> - Memorystore | CPU Utilization"
|
|
387
409
|
conditions:
|
|
@@ -401,6 +423,7 @@ memorystore:
|
|
|
401
423
|
- resource.label.instance_id
|
|
402
424
|
documentation:
|
|
403
425
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
426
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
404
427
|
system_memory_overload_duration:
|
|
405
428
|
display_name: "[P1] <%-clan%> - Memorystore | System Memory Overload Duration"
|
|
406
429
|
conditions:
|
|
@@ -419,6 +442,7 @@ memorystore:
|
|
|
419
442
|
- resource.label.instance_id
|
|
420
443
|
documentation:
|
|
421
444
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
445
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
422
446
|
calls:
|
|
423
447
|
display_name: "[P3] <%-clan%> - Memorystore | Calls"
|
|
424
448
|
conditions:
|
|
@@ -438,6 +462,7 @@ memorystore:
|
|
|
438
462
|
- resource.label.instance_id
|
|
439
463
|
documentation:
|
|
440
464
|
subject: 'Instance: `$${resource.label.instance_id}`'
|
|
465
|
+
content: 'Review the instance in Memorystore: https://console.cloud.google.com/memorystore/redis/instances?project=<%-projectId%>'
|
|
441
466
|
pub_sub:
|
|
442
467
|
unacknowledged_messages:
|
|
443
468
|
display_name: "[P3] <%-clan%> - Pub/Sub | Undelivered message(s)"
|
|
@@ -457,6 +482,7 @@ pub_sub:
|
|
|
457
482
|
- resource.label.subscription_id
|
|
458
483
|
documentation:
|
|
459
484
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
485
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
460
486
|
messages_in_dlq:
|
|
461
487
|
display_name: "[P3] <%-clan%> - Pub/Sub | Message(s) in DLQ"
|
|
462
488
|
conditions:
|
|
@@ -477,6 +503,7 @@ pub_sub:
|
|
|
477
503
|
- metric.label.response_code
|
|
478
504
|
documentation:
|
|
479
505
|
subject: 'Subscription: `$${resource.label.subscription_id}`, Response code: `$${metric.label.response_code}`'
|
|
506
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
480
507
|
latency:
|
|
481
508
|
display_name: "[P3] <%-clan%> - Pub/Sub | Response latency distribution"
|
|
482
509
|
conditions:
|
|
@@ -496,6 +523,7 @@ pub_sub:
|
|
|
496
523
|
- resource.label.subscription_id
|
|
497
524
|
documentation:
|
|
498
525
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
526
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
499
527
|
oldest_unacked_message_age:
|
|
500
528
|
display_name: "[P3] <%-clan%> - Pub/Sub | Oldest unacked message age"
|
|
501
529
|
conditions:
|
|
@@ -514,6 +542,7 @@ pub_sub:
|
|
|
514
542
|
- resource.label.subscription_id
|
|
515
543
|
documentation:
|
|
516
544
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
545
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
517
546
|
push_requests_ack:
|
|
518
547
|
display_name: "[P3] <%-clan%> - Pub/Sub | Push requests ack"
|
|
519
548
|
conditions:
|
|
@@ -533,6 +562,7 @@ pub_sub:
|
|
|
533
562
|
- resource.label.subscription_id
|
|
534
563
|
documentation:
|
|
535
564
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
565
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
536
566
|
push_requests_success:
|
|
537
567
|
display_name: "[P3] <%-clan%> - Pub/Sub | Push requests success"
|
|
538
568
|
conditions:
|
|
@@ -552,6 +582,7 @@ pub_sub:
|
|
|
552
582
|
- resource.label.subscription_id
|
|
553
583
|
documentation:
|
|
554
584
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
585
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
555
586
|
delivery_latency_health_score:
|
|
556
587
|
display_name: "[P3] <%-clan%> - Pub/Sub | Delivery latency health score"
|
|
557
588
|
conditions:
|
|
@@ -571,6 +602,7 @@ pub_sub:
|
|
|
571
602
|
- resource.label.subscription_id
|
|
572
603
|
documentation:
|
|
573
604
|
subject: 'Subscription: `$${resource.label.subscription_id}`'
|
|
605
|
+
content: 'Review the subscription in Pub/Sub: https://console.cloud.google.com/cloudpubsub/subscriptions?project=<%-projectId%>'
|
|
574
606
|
spanner:
|
|
575
607
|
cpu_utilization_by_priority:
|
|
576
608
|
display_name: "[P2] <%-clan%> - Spanner | CPU Utilization"
|
|
@@ -591,6 +623,7 @@ spanner:
|
|
|
591
623
|
- metric.label.database
|
|
592
624
|
documentation:
|
|
593
625
|
subject: 'Instance: `$${resource.label.instance_id}`, Database: `$${resource.label.database}`'
|
|
626
|
+
content: 'Review the instance in Spanner: https://console.cloud.google.com/spanner/instances?project=<%-projectId%>'
|
|
594
627
|
api_request_error_rate:
|
|
595
628
|
display_name: "[P2] <%-clan%> - Spanner | API request error rate"
|
|
596
629
|
conditions:
|
|
@@ -611,6 +644,7 @@ spanner:
|
|
|
611
644
|
- resource.label.database
|
|
612
645
|
documentation:
|
|
613
646
|
subject: 'Instance: `$${resource.label.instance_id}`, Database: `$${resource.label.database}`'
|
|
647
|
+
content: 'Review the instance in Spanner: https://console.cloud.google.com/spanner/instances?project=<%-projectId%>'
|
|
614
648
|
request_latencies:
|
|
615
649
|
display_name: '[P3] <%-clan%> - Spanner | API transaction latency'
|
|
616
650
|
conditions:
|
|
@@ -631,3 +665,4 @@ spanner:
|
|
|
631
665
|
per_series_aligner: ALIGN_PERCENTILE_95
|
|
632
666
|
documentation:
|
|
633
667
|
subject: 'Instance: `$${resource.label.instance_id}`, Database: `$${resource.label.database}}`'
|
|
668
|
+
content: 'Review the instance in Spanner: https://console.cloud.google.com/spanner/instances?project=<%-projectId%>'
|
|
@@ -18,7 +18,7 @@ module.exports = class extends BaseGenerator {
|
|
|
18
18
|
{
|
|
19
19
|
type: 'list',
|
|
20
20
|
name: 'createResource',
|
|
21
|
-
message: 'Do you want to create a new topic
|
|
21
|
+
message: 'Do you want to create a new topic, subscription?',
|
|
22
22
|
default: 'subscription',
|
|
23
23
|
choices: ['topic', 'subscription'],
|
|
24
24
|
},
|
|
@@ -168,6 +168,15 @@ module.exports = class extends BaseGenerator {
|
|
|
168
168
|
'Please provide the audience that will be used when generating OIDC token',
|
|
169
169
|
validate: required,
|
|
170
170
|
},
|
|
171
|
+
{
|
|
172
|
+
when: (response) => response.createResource === 'topic',
|
|
173
|
+
type: 'list',
|
|
174
|
+
name: 'externalTopicPublishers',
|
|
175
|
+
message: 'Do you want to allow external publishers onto this topic?',
|
|
176
|
+
default: 'no',
|
|
177
|
+
choices: ['no', 'yes'],
|
|
178
|
+
validate: required,
|
|
179
|
+
},
|
|
171
180
|
];
|
|
172
181
|
|
|
173
182
|
return this.prompt(prompts).then((props) => {
|
|
@@ -195,6 +204,7 @@ module.exports = class extends BaseGenerator {
|
|
|
195
204
|
prodProjectIdConsumer,
|
|
196
205
|
costCenter,
|
|
197
206
|
externalSub,
|
|
207
|
+
externalTopicPublishers,
|
|
198
208
|
} = this.answers;
|
|
199
209
|
|
|
200
210
|
const dlqTopicName = `dlq.${getProjectId('prod').split('-prod')[0]}.common`;
|
|
@@ -224,7 +234,8 @@ module.exports = class extends BaseGenerator {
|
|
|
224
234
|
'pubsub',
|
|
225
235
|
topicName,
|
|
226
236
|
);
|
|
227
|
-
['terragrunt.hcl', 'spec.hcl']
|
|
237
|
+
const files = ['terragrunt.hcl', 'spec.hcl'];
|
|
238
|
+
for (const file of files) {
|
|
228
239
|
this.fs.copyTpl(
|
|
229
240
|
this.templatePath(`pubsub/${file}`),
|
|
230
241
|
this.destinationPath(`${topicDirPath}/${file}`),
|
|
@@ -236,7 +247,7 @@ module.exports = class extends BaseGenerator {
|
|
|
236
247
|
dlqTopic,
|
|
237
248
|
},
|
|
238
249
|
);
|
|
239
|
-
}
|
|
250
|
+
}
|
|
240
251
|
}
|
|
241
252
|
|
|
242
253
|
let projectId = getProjectId(env);
|
|
@@ -276,7 +287,8 @@ module.exports = class extends BaseGenerator {
|
|
|
276
287
|
);
|
|
277
288
|
}
|
|
278
289
|
|
|
279
|
-
['terragrunt.hcl', 'spec.hcl']
|
|
290
|
+
const files = ['terragrunt.hcl', 'spec.hcl'];
|
|
291
|
+
for (const file of files) {
|
|
280
292
|
this.fs.copyTpl(
|
|
281
293
|
this.templatePath(`pubsub/${file}`),
|
|
282
294
|
this.destinationPath(`${subscriptionDirPath}/${file}`),
|
|
@@ -286,7 +298,7 @@ module.exports = class extends BaseGenerator {
|
|
|
286
298
|
existingTopic,
|
|
287
299
|
},
|
|
288
300
|
);
|
|
289
|
-
}
|
|
301
|
+
}
|
|
290
302
|
|
|
291
303
|
await handleSubscribers(
|
|
292
304
|
env,
|
|
@@ -297,11 +309,12 @@ module.exports = class extends BaseGenerator {
|
|
|
297
309
|
dlqTopic,
|
|
298
310
|
);
|
|
299
311
|
}
|
|
312
|
+
|
|
300
313
|
if (createResource === 'subscription' && externalSub === 'yes') {
|
|
301
314
|
const externalDirPath = path.join(
|
|
302
315
|
process.cwd(),
|
|
303
316
|
'infra',
|
|
304
|
-
|
|
317
|
+
env,
|
|
305
318
|
'pubsub',
|
|
306
319
|
existingTopic,
|
|
307
320
|
`${clanName}-${env}`,
|
|
@@ -311,7 +324,8 @@ module.exports = class extends BaseGenerator {
|
|
|
311
324
|
fs.mkdirSync(externalDirPath);
|
|
312
325
|
}
|
|
313
326
|
|
|
314
|
-
['terragrunt.hcl', 'spec.hcl']
|
|
327
|
+
const files = ['terragrunt.hcl', 'spec.hcl'];
|
|
328
|
+
for (const file of files) {
|
|
315
329
|
this.fs.copyTpl(
|
|
316
330
|
this.templatePath(`pubsub-external/${file}`),
|
|
317
331
|
this.destinationPath(`${externalDirPath}/${file}`),
|
|
@@ -326,7 +340,7 @@ module.exports = class extends BaseGenerator {
|
|
|
326
340
|
projectId,
|
|
327
341
|
},
|
|
328
342
|
);
|
|
329
|
-
}
|
|
343
|
+
}
|
|
330
344
|
|
|
331
345
|
const externalSubPath = `${externalDirPath}/subscribers.yaml`;
|
|
332
346
|
if (env === 'staging') {
|
|
@@ -362,6 +376,28 @@ module.exports = class extends BaseGenerator {
|
|
|
362
376
|
dlqTopic,
|
|
363
377
|
);
|
|
364
378
|
}
|
|
379
|
+
|
|
380
|
+
if (createResource === 'topic' && externalTopicPublishers === 'yes') {
|
|
381
|
+
const externalPublishersPath = path.join(
|
|
382
|
+
process.cwd(),
|
|
383
|
+
'infra',
|
|
384
|
+
env,
|
|
385
|
+
'pubsub',
|
|
386
|
+
topicName,
|
|
387
|
+
'external-publishers',
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
const files = ['terragrunt.hcl', 'bindings.yaml'];
|
|
391
|
+
for (const file of files) {
|
|
392
|
+
this.fs.copyTpl(
|
|
393
|
+
this.templatePath(`pubsub-external-publishers/${file}`),
|
|
394
|
+
this.destinationPath(`${externalPublishersPath}/${file}`),
|
|
395
|
+
{
|
|
396
|
+
...this.answers,
|
|
397
|
+
},
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
365
401
|
});
|
|
366
402
|
}
|
|
367
403
|
|
|
@@ -370,7 +406,8 @@ module.exports = class extends BaseGenerator {
|
|
|
370
406
|
${chalk.green(`Your PubSub resources have now been created. To finalize your configuration, please continue
|
|
371
407
|
with manual editing of the generated files.`)}
|
|
372
408
|
${chalk.green('1.')} Review created subscribers.
|
|
373
|
-
${chalk.green('2.')}
|
|
409
|
+
${chalk.green('2.')} Review created external publishers.
|
|
410
|
+
${chalk.green('3.')} Push this change in a feature branch and open a pull request.
|
|
374
411
|
`);
|
|
375
412
|
}
|
|
376
413
|
};
|
package/dist/generators/common-resources/pubsub/templates/pubsub-external-publishers/terragrunt.hcl
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
|
|
2
|
+
# working directory, into a temporary folder, and execute your Terraform commands in that folder.
|
|
3
|
+
terraform {
|
|
4
|
+
source = "git::https://github.com/terraform-google-modules/terraform-google-iam.git//modules/pubsub_topics_iam?ref=v8.1.0"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
include {
|
|
8
|
+
path = find_in_parent_folders("terragrunt_root.hcl")
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
locals {
|
|
12
|
+
project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
|
|
13
|
+
bindings_raw = yamldecode(file("${get_terragrunt_dir()}/bindings.yaml"))
|
|
14
|
+
clan_members = flatten([
|
|
15
|
+
for clan, members in local.bindings_raw.clans : [
|
|
16
|
+
for m in members : (
|
|
17
|
+
can(m.serviceAccount) ? m.serviceAccount : regex_replace("^serviceAccount:", "", m)
|
|
18
|
+
)
|
|
19
|
+
]
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
iam_bindings = {
|
|
23
|
+
"roles/pubsub.publisher" = [
|
|
24
|
+
for sa in local.clan_members : "serviceAccount:${sa}"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
dependency "topic" {
|
|
30
|
+
config_path = "../"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
inputs = {
|
|
34
|
+
project = local.project_vars.locals.project_id
|
|
35
|
+
pubsub_topics = [dependency.topic.outputs.topic]
|
|
36
|
+
bindings = local.iam_bindings
|
|
37
|
+
}
|