@hiiretail/gcp-infra-generators 1.0.2 → 1.1.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 (35) hide show
  1. package/dist/generators/common-resources/pubsub/index.js +46 -9
  2. package/dist/generators/common-resources/pubsub/templates/pubsub-external-publishers/bindings.yaml +8 -0
  3. package/dist/generators/common-resources/pubsub/templates/pubsub-external-publishers/terragrunt.hcl +37 -0
  4. package/dist/node_modules/.package-lock.json +381 -382
  5. package/dist/node_modules/axios/CHANGELOG.md +35 -0
  6. package/dist/node_modules/axios/README.md +13 -10
  7. package/dist/node_modules/axios/dist/axios.js +358 -289
  8. package/dist/node_modules/axios/dist/axios.js.map +1 -1
  9. package/dist/node_modules/axios/dist/axios.min.js +2 -2
  10. package/dist/node_modules/axios/dist/axios.min.js.map +1 -1
  11. package/dist/node_modules/axios/dist/browser/axios.cjs +286 -211
  12. package/dist/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  13. package/dist/node_modules/axios/dist/esm/axios.js +286 -211
  14. package/dist/node_modules/axios/dist/esm/axios.js.map +1 -1
  15. package/dist/node_modules/axios/dist/esm/axios.min.js +2 -2
  16. package/dist/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  17. package/dist/node_modules/axios/dist/node/axios.cjs +377 -211
  18. package/dist/node_modules/axios/dist/node/axios.cjs.map +1 -1
  19. package/dist/node_modules/axios/index.d.cts +9 -5
  20. package/dist/node_modules/axios/index.d.ts +10 -4
  21. package/dist/node_modules/axios/lib/adapters/adapters.js +6 -4
  22. package/dist/node_modules/axios/lib/adapters/fetch.js +220 -163
  23. package/dist/node_modules/axios/lib/adapters/http.js +18 -0
  24. package/dist/node_modules/axios/lib/adapters/xhr.js +11 -8
  25. package/dist/node_modules/axios/lib/core/AxiosError.js +10 -3
  26. package/dist/node_modules/axios/lib/core/dispatchRequest.js +1 -1
  27. package/dist/node_modules/axios/lib/defaults/index.js +1 -1
  28. package/dist/node_modules/axios/lib/env/data.js +1 -1
  29. package/dist/node_modules/axios/lib/helpers/buildURL.js +1 -3
  30. package/dist/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +73 -0
  31. package/dist/node_modules/axios/lib/helpers/resolveConfig.js +13 -9
  32. package/dist/node_modules/axios/lib/utils.js +7 -3
  33. package/dist/node_modules/axios/package.json +12 -9
  34. package/dist/package.json +2 -2
  35. package/package.json +2 -2
@@ -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 or a subscription?',
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'].forEach(async (file) => {
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'].forEach(async (file) => {
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
- 'prod',
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'].forEach(async (file) => {
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.')} Push this change in a feature branch and open a pull request.
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
  };
@@ -0,0 +1,8 @@
1
+ <% if (createResource == 'topic' && externalTopicPublishers == 'yes') { %>clans:
2
+ # Add External serviceAccounts like:
3
+ # clans:
4
+ # iam:
5
+ # - serviceAccount: ...
6
+ # store-data:
7
+ # - serviceAccount: ...
8
+ <% } %>
@@ -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
+ }