@hiiretail/gcp-infra-cli 0.87.4 → 0.88.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 (153) hide show
  1. package/generators/clan-resources/clan-project/generator.json +4 -0
  2. package/generators/clan-resources/clan-project/index.js +135 -0
  3. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/cloud-nat/terragrunt.hcl +10 -4
  4. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/cloud-nat-static-ip/terragrunt.hcl +2 -2
  5. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/cloud-router/terragrunt.hcl +7 -4
  6. package/generators/clan-resources/clan-project/templates/clan-resources/gke/gke-resources/terragrunt.hcl +40 -0
  7. package/generators/clan-resources/clan-project/templates/clan-resources/gke/spec.hcl +18 -0
  8. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/gke/terragrunt.hcl +11 -6
  9. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/network/firewall-rules/config/main.tf +13 -0
  10. package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/config/vars.tf +9 -0
  11. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/network/firewall-rules/terragrunt.hcl +3 -3
  12. package/generators/clan-resources/clan-project/templates/clan-resources/network/spec.hcl +46 -0
  13. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/network/terragrunt.hcl +2 -2
  14. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/private-vpc-connection/config/main.tf +2 -1
  15. package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/private-vpc-connection/terragrunt.hcl +2 -2
  16. package/generators/clan-resources/clan-project/templates/clan-resources/serverless-vpc-connector/terragrunt.hcl +40 -0
  17. package/generators/{tribe-resources → clan-resources}/command.json +1 -1
  18. package/generators/{resources → common-resources}/command.json +1 -1
  19. package/generators/{resources → common-resources}/spanner/index.js +2 -8
  20. package/generators/common-resources/spanner/validate.js +24 -0
  21. package/generators/organization/clan-project/index.js +6 -0
  22. package/generators/organization/clan-project/templates/clan/clan.yaml +3 -1
  23. package/generators/organization/clan-project/templates/clan-project/terragrunt.hcl +4 -37
  24. package/package.json +1 -1
  25. package/generators/resources/spanner/validate.js +0 -27
  26. package/generators/tribe-resources/tribe-project/generator.json +0 -4
  27. package/generators/tribe-resources/tribe-project/index.js +0 -106
  28. package/generators/tribe-resources/tribe-project/templates/project/gke/opa/config/main.tf +0 -33
  29. package/generators/tribe-resources/tribe-project/templates/project/gke/opa/config/vars.tf +0 -14
  30. package/generators/tribe-resources/tribe-project/templates/project/gke/opa/terragrunt.hcl +0 -34
  31. package/generators/tribe-resources/tribe-project/templates/project/gke/spec.hcl +0 -35
  32. package/generators/tribe-resources/tribe-project/templates/project/gke-ingress-static-ip/spec.hcl +0 -7
  33. package/generators/tribe-resources/tribe-project/templates/project/gke-ingress-static-ip/terragrunt.hcl +0 -25
  34. package/generators/tribe-resources/tribe-project/templates/project/network/firewall-rules/config/vars.tf +0 -9
  35. package/generators/tribe-resources/tribe-project/templates/project/network/spec.hcl +0 -40
  36. package/generators/tribe-resources/tribe-project/templates/project/project.yaml +0 -7
  37. package/generators/tribe-resources/tribe-project/templates/project/terragrunt.hcl +0 -51
  38. /package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/cloud-nat-static-ip/spec.hcl +0 -0
  39. /package/generators/{tribe-resources/tribe-project/templates/project → clan-resources/clan-project/templates/clan-resources}/private-vpc-connection/config/vars.tf +0 -0
  40. /package/generators/{tribe-resources/tribe-project/templates → clan-resources/clan-project/templates/clan-resources}/terragrunt.hcl +0 -0
  41. /package/generators/{resources → common-resources}/bigquery/generator.json +0 -0
  42. /package/generators/{resources → common-resources}/bigquery/index.js +0 -0
  43. /package/generators/{resources → common-resources}/bigquery/templates/bigquery/spec.hcl +0 -0
  44. /package/generators/{resources → common-resources}/bigquery/templates/bigquery/terragrunt.hcl +0 -0
  45. /package/generators/{resources → common-resources}/bigquery/templates/scheduled-queries/terragrunt.hcl +0 -0
  46. /package/generators/{resources → common-resources}/bigquery/templates/schema/schema.json +0 -0
  47. /package/generators/{resources → common-resources}/cloud-storage/generator.json +0 -0
  48. /package/generators/{resources → common-resources}/cloud-storage/index.js +0 -0
  49. /package/generators/{resources → common-resources}/cloud-storage/templates/cloud-storage/storage.yaml +0 -0
  50. /package/generators/{resources → common-resources}/cloud-storage/templates/cloud-storage/terragrunt.hcl +0 -0
  51. /package/generators/{resources → common-resources}/cloudsql/generator.json +0 -0
  52. /package/generators/{resources → common-resources}/cloudsql/index.js +0 -0
  53. /package/generators/{resources → common-resources}/cloudsql/templates/mssql/instance/spec.hcl +0 -0
  54. /package/generators/{resources → common-resources}/cloudsql/templates/mssql/instance/terragrunt.hcl +0 -0
  55. /package/generators/{resources → common-resources}/cloudsql/templates/mssql/instance-secrets/terragrunt.hcl +0 -0
  56. /package/generators/{resources → common-resources}/cloudsql/templates/mysql/instance/spec.hcl +0 -0
  57. /package/generators/{resources → common-resources}/cloudsql/templates/mysql/instance/terragrunt.hcl +0 -0
  58. /package/generators/{resources → common-resources}/cloudsql/templates/mysql/instance-secrets/terragrunt.hcl +0 -0
  59. /package/generators/{resources → common-resources}/cloudsql/templates/postgres/instance/spec.hcl +0 -0
  60. /package/generators/{resources → common-resources}/cloudsql/templates/postgres/instance/terragrunt.hcl +0 -0
  61. /package/generators/{resources → common-resources}/cloudsql/templates/postgres/instance-secrets/terragrunt.hcl +0 -0
  62. /package/generators/{resources → common-resources}/cloudsql-database/generator.json +0 -0
  63. /package/generators/{resources → common-resources}/cloudsql-database/index.js +0 -0
  64. /package/generators/{resources → common-resources}/cloudsql-database/templates/mysql/database/proxy_port.hcl +0 -0
  65. /package/generators/{resources → common-resources}/cloudsql-database/templates/mysql/database/terragrunt.hcl +0 -0
  66. /package/generators/{resources → common-resources}/cloudsql-database/templates/mysql/outputs.json +0 -0
  67. /package/generators/{resources → common-resources}/cloudsql-database/templates/mysql/secrets/terragrunt.hcl +0 -0
  68. /package/generators/{resources → common-resources}/cloudsql-database/templates/postgres/database/proxy_port.hcl +0 -0
  69. /package/generators/{resources → common-resources}/cloudsql-database/templates/postgres/database/spec.hcl +0 -0
  70. /package/generators/{resources → common-resources}/cloudsql-database/templates/postgres/database/terragrunt.hcl +0 -0
  71. /package/generators/{resources → common-resources}/cloudsql-database/templates/postgres/outputs.json +0 -0
  72. /package/generators/{resources → common-resources}/cloudsql-database/templates/postgres/secrets/terragrunt.hcl +0 -0
  73. /package/generators/{resources → common-resources}/confluent-cluster/generator.json +0 -0
  74. /package/generators/{resources → common-resources}/confluent-cluster/index.js +0 -0
  75. /package/generators/{resources → common-resources}/confluent-cluster/templates/confluent/spec.hcl +0 -0
  76. /package/generators/{resources → common-resources}/confluent-cluster/templates/confluent/terragrunt.hcl +0 -0
  77. /package/generators/{resources → common-resources}/datastore/generator.json +0 -0
  78. /package/generators/{resources → common-resources}/datastore/index.js +0 -0
  79. /package/generators/{resources → common-resources}/datastore/templates/datastore/indexes.yaml +0 -0
  80. /package/generators/{resources → common-resources}/datastore/templates/datastore/terragrunt.hcl +0 -0
  81. /package/generators/{resources → common-resources}/elastic-cloud/generator.json +0 -0
  82. /package/generators/{resources → common-resources}/elastic-cloud/index.js +0 -0
  83. /package/generators/{resources → common-resources}/elastic-cloud/templates/elastic/spec.hcl +0 -0
  84. /package/generators/{resources → common-resources}/elastic-cloud/templates/elastic/terragrunt.hcl +0 -0
  85. /package/generators/{resources → common-resources}/elastic-index-policy/generator.json +0 -0
  86. /package/generators/{resources → common-resources}/elastic-index-policy/handle-yaml.js +0 -0
  87. /package/generators/{resources → common-resources}/elastic-index-policy/index.js +0 -0
  88. /package/generators/{resources → common-resources}/elastic-index-policy/templates/policy/policy.yaml +0 -0
  89. /package/generators/{resources → common-resources}/elastic-index-policy/templates/policy/terragrunt.hcl +0 -0
  90. /package/generators/{resources → common-resources}/elastic-template/generator.json +0 -0
  91. /package/generators/{resources → common-resources}/elastic-template/index.js +0 -0
  92. /package/generators/{resources → common-resources}/elastic-template/templates/elastic-template/mappings.json +0 -0
  93. /package/generators/{resources → common-resources}/elastic-template/templates/elastic-template/terragrunt.hcl +0 -0
  94. /package/generators/{resources → common-resources}/firestore/generator.json +0 -0
  95. /package/generators/{resources → common-resources}/firestore/index.js +0 -0
  96. /package/generators/{resources → common-resources}/firestore/templates/firestore/indexes.yaml +0 -0
  97. /package/generators/{resources → common-resources}/firestore/templates/firestore/terragrunt.hcl +0 -0
  98. /package/generators/{resources → common-resources}/iam/generator.json +0 -0
  99. /package/generators/{resources → common-resources}/iam/index.js +0 -0
  100. /package/generators/{resources → common-resources}/iam/templates/github/workflows/iam.yml +0 -0
  101. /package/generators/{resources → common-resources}/iam/templates/iam.yaml +0 -0
  102. /package/generators/{resources → common-resources}/iam/valid-prefix.js +0 -0
  103. /package/generators/{resources → common-resources}/kafka-connect/generator.json +0 -0
  104. /package/generators/{resources → common-resources}/kafka-connect/index.js +0 -0
  105. /package/generators/{resources → common-resources}/kafka-connect/templates/elastic/terragrunt.hcl +0 -0
  106. /package/generators/{resources → common-resources}/kafka-connect/templates/pubsub/terragrunt.hcl +0 -0
  107. /package/generators/{resources → common-resources}/kafka-topics/generator.json +0 -0
  108. /package/generators/{resources → common-resources}/kafka-topics/index.js +0 -0
  109. /package/generators/{resources → common-resources}/kafka-topics/templates/kafka/kafka.yaml +0 -0
  110. /package/generators/{resources → common-resources}/kafka-topics/templates/kafka/terragrunt.hcl +0 -0
  111. /package/generators/{resources → common-resources}/kms/generator.json +0 -0
  112. /package/generators/{resources → common-resources}/kms/index.js +0 -0
  113. /package/generators/{resources → common-resources}/kms/templates/kms/spec.hcl +0 -0
  114. /package/generators/{resources → common-resources}/kms/templates/kms/terragrunt.hcl +0 -0
  115. /package/generators/{resources → common-resources}/memorystore/generator.json +0 -0
  116. /package/generators/{resources → common-resources}/memorystore/index.js +0 -0
  117. /package/generators/{resources → common-resources}/memorystore/templates/outputs.json +0 -0
  118. /package/generators/{resources → common-resources}/memorystore/templates/redis-instance/spec.hcl +0 -0
  119. /package/generators/{resources → common-resources}/memorystore/templates/redis-instance/terragrunt.hcl +0 -0
  120. /package/generators/{resources → common-resources}/memorystore/templates/secrets/terragrunt.hcl +0 -0
  121. /package/generators/{resources → common-resources}/monitoring/generator.json +0 -0
  122. /package/generators/{resources → common-resources}/monitoring/handle-yaml.js +0 -0
  123. /package/generators/{resources → common-resources}/monitoring/index.js +0 -0
  124. /package/generators/{resources → common-resources}/monitoring/templates/alerts/generic-infra.yaml +0 -0
  125. /package/generators/{resources → common-resources}/monitoring/templates/alerts/service.yaml +0 -0
  126. /package/generators/{resources → common-resources}/monitoring/templates/alerts/terragrunt.hcl +0 -0
  127. /package/generators/{resources → common-resources}/monitoring/templates/slos/slos.yaml +0 -0
  128. /package/generators/{resources → common-resources}/monitoring/templates/slos/terragrunt.hcl +0 -0
  129. /package/generators/{resources → common-resources}/monitoring/templates/uptime-checks/terragrunt.hcl +0 -0
  130. /package/generators/{resources → common-resources}/monitoring/templates/uptime-checks/uptime-checks.yaml +0 -0
  131. /package/generators/{resources → common-resources}/monitoring/validate.js +0 -0
  132. /package/generators/{resources → common-resources}/pubsub/append.js +0 -0
  133. /package/generators/{resources → common-resources}/pubsub/generator.json +0 -0
  134. /package/generators/{resources → common-resources}/pubsub/get-gcp-projects.js +0 -0
  135. /package/generators/{resources → common-resources}/pubsub/handle-subscribers.js +0 -0
  136. /package/generators/{resources → common-resources}/pubsub/index.js +0 -0
  137. /package/generators/{resources → common-resources}/pubsub/templates/pubsub/spec.hcl +0 -0
  138. /package/generators/{resources → common-resources}/pubsub/templates/pubsub/subscribers.yaml +0 -0
  139. /package/generators/{resources → common-resources}/pubsub/templates/pubsub/terragrunt.hcl +0 -0
  140. /package/generators/{resources → common-resources}/pubsub/templates/pubsub-dlq/terragrunt.hcl +0 -0
  141. /package/generators/{resources → common-resources}/pubsub/templates/pubsub-external/spec.hcl +0 -0
  142. /package/generators/{resources → common-resources}/pubsub/templates/pubsub-external/subscribers.yaml +0 -0
  143. /package/generators/{resources → common-resources}/pubsub/templates/pubsub-external/terragrunt.hcl +0 -0
  144. /package/generators/{resources → common-resources}/pubsub/validate.js +0 -0
  145. /package/generators/{resources → common-resources}/scheduler/append.js +0 -0
  146. /package/generators/{resources → common-resources}/scheduler/generator.json +0 -0
  147. /package/generators/{resources → common-resources}/scheduler/index.js +0 -0
  148. /package/generators/{resources → common-resources}/scheduler/templates/scheduler/terragrunt.hcl +0 -0
  149. /package/generators/{resources → common-resources}/spanner/append.js +0 -0
  150. /package/generators/{resources → common-resources}/spanner/generator.json +0 -0
  151. /package/generators/{resources → common-resources}/spanner/templates/spanner/databases.yaml +0 -0
  152. /package/generators/{resources → common-resources}/spanner/templates/spanner/spec.hcl +0 -0
  153. /package/generators/{resources → common-resources}/spanner/templates/spanner/terragrunt.hcl +0 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "Clan project with GKE Autopilot",
3
+ "description": "Create resources for clan project with GKE cluster"
4
+ }
@@ -0,0 +1,135 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const chalk = require('chalk');
4
+ const BaseGenerator = require('../../../src/BaseGenerator');
5
+ const { required } = require('../../../src/validators');
6
+
7
+ module.exports = class extends BaseGenerator {
8
+ constructor(args, opts) {
9
+ super(args, opts);
10
+
11
+ // Output directory relative to the tf-infra-gcp directory.
12
+ this.destinationRoot('organization');
13
+ }
14
+
15
+ prompting() {
16
+ const prompts = [
17
+ {
18
+ type: 'list',
19
+ name: 'domain',
20
+ default: 'extendaretail-com',
21
+ message: 'Choose GCP Organization',
22
+ store: true,
23
+ choices: this.listSubDirectories(this.destinationPath()),
24
+ validate: required,
25
+ },
26
+ {
27
+ type: 'list',
28
+ name: 'department',
29
+ message: 'Choose department',
30
+ store: true,
31
+ choices: (answers) => this.listSubDirectories(
32
+ path.join(this.destinationPath(), answers.domain, 'departments'),
33
+ ),
34
+ validate: required,
35
+ },
36
+ {
37
+ type: 'list',
38
+ name: 'tribe',
39
+ message: 'Choose tribe',
40
+ store: true,
41
+ choices: (answers) => this.listSubDirectories(
42
+ path.join(this.destinationPath(), answers.domain, 'departments', answers.department),
43
+ ),
44
+ validate: required,
45
+ },
46
+ {
47
+ type: 'list',
48
+ name: 'clan',
49
+ message: 'Choose clan',
50
+ store: true,
51
+ choices: (answers) => this.listSubDirectories(
52
+ path.join(this.destinationPath(), answers.domain, 'departments', answers.department, answers.tribe, 'clans'),
53
+ ),
54
+ validate: required,
55
+ },
56
+ {
57
+ type: 'list',
58
+ name: 'migration',
59
+ message: 'Is the project in the process of migration to Autopilot?',
60
+ default: 'yes',
61
+ choices: ['yes', 'no'],
62
+ },
63
+ ];
64
+
65
+ return this.prompt(prompts).then((props) => {
66
+ this.answers = props;
67
+ });
68
+ }
69
+
70
+ writing() {
71
+ const {
72
+ domain,
73
+ department,
74
+ tribe,
75
+ clan,
76
+ migration,
77
+ } = this.answers;
78
+
79
+ ['prod', 'staging'].forEach((env) => {
80
+ this.copyDir(
81
+ 'clan-resources',
82
+ path.join(domain, 'departments', department, tribe, 'clans', clan, env, 'resources'),
83
+ {
84
+ ...this.answers,
85
+ env,
86
+ },
87
+ );
88
+ });
89
+
90
+ if (migration === 'yes') {
91
+ ['prod', 'staging'].forEach((env) => {
92
+ const terragruntFilePath = path.join(domain, 'departments', department, tribe, 'clans', clan, env, 'terragrunt.hcl');
93
+
94
+ fs.readFile(terragruntFilePath, 'utf8', (err, data) => {
95
+ if (err) {
96
+ return;
97
+ }
98
+
99
+ const modifiedData = data.replace(
100
+ /source\s*=\s*"git::https:\/\/github\.com\/extenda\/tf-module-gcp-project\/\/\?ref=.+"/,
101
+ 'source = "git::https://github.com/extenda/tf-module-gcp-project//?ref=migration"',
102
+ );
103
+
104
+ fs.writeFile(terragruntFilePath, modifiedData, 'utf8', (error) => {
105
+ if (error) {
106
+ console.error(`Error writing file ${terragruntFilePath}: ${error}`);
107
+ } else {
108
+ console.log(`Updated file ${terragruntFilePath}`);
109
+ }
110
+ });
111
+ });
112
+ });
113
+ }
114
+ }
115
+
116
+ end() {
117
+ const {
118
+ domain,
119
+ department,
120
+ tribe,
121
+ clan,
122
+ } = this.answers;
123
+ const clanDir = path.join(domain, 'departments', department, tribe, 'clans', clan);
124
+ this.log(`
125
+ ${chalk.green(`Your clan resources have now been created. To finalize your configuration, please continue
126
+ with manual editing of the generated files.`)}
127
+ ${chalk.green('1.')} Review the configurations
128
+ \u2192 ${chalk.cyan(path.join(clanDir, 'prod', 'network', 'spec.hcl'))}
129
+ \u2192 ${chalk.cyan(path.join(clanDir, 'prod', 'gke', 'spec.hcl'))}
130
+ \u2192 ${chalk.cyan(path.join(clanDir, 'staging', 'network', 'spec.hcl'))}
131
+ \u2192 ${chalk.cyan(path.join(clanDir, 'staging', 'gke', 'spec.hcl'))}
132
+ ${chalk.green('2.')} Push this change in a feature branch and open a pull request.
133
+ `);
134
+ }
135
+ };
@@ -1,7 +1,7 @@
1
1
  # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
2
2
  # working directory, into a temporary folder, and execute your Terraform commands in that folder.
3
3
  terraform {
4
- source = "git::https://github.com/terraform-google-modules/terraform-google-cloud-nat//?ref=v2.0.0"
4
+ source = "git::https://github.com/terraform-google-modules/terraform-google-cloud-nat//?ref=v2.2.2"
5
5
  }
6
6
 
7
7
  # Include all settings from the root terragrunt.hcl file
@@ -29,18 +29,24 @@ dependency "router" {
29
29
  dependency "static_ip" {
30
30
  config_path = "../cloud-nat-static-ip"
31
31
  mock_outputs = {
32
- self_links = ["https://www.googleapis.com/compute/v1/projects/project-id/regions/europe-west1/addresses/ip"]
32
+ names = ["ip-name"]
33
33
  }
34
34
  }
35
35
 
36
+ locals {
37
+ clan_name = basename(dirname(dirname(dirname(get_terragrunt_dir()))))
38
+ }
39
+
36
40
  # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
37
41
  inputs = merge(
38
42
  {
39
- name = "<%- tribe %>-cloud-nat"
43
+ name = "${local.clan_name}-cloud-nat"
40
44
  region = "europe-west1"
41
45
  project_id = dependency.network.outputs.project_id
42
46
  network = dependency.network.outputs.network_name
43
47
  router = dependency.router.outputs.router.name
44
- nat_ips = dependency.static_ip.outputs.self_links
48
+ nat_ips = dependency.static_ip.outputs.names
49
+
50
+ enable_endpoint_independent_mapping = false
45
51
  }
46
52
  )
@@ -1,9 +1,9 @@
1
1
  terraform {
2
- source = "git::https://github.com/terraform-google-modules/terraform-google-address//?ref=v3.0.0"
2
+ source = "git::https://github.com/terraform-google-modules/terraform-google-address//?ref=v3.1.2"
3
3
  }
4
4
 
5
5
  dependency "project" {
6
- config_path = "../"
6
+ config_path = "../../"
7
7
  mock_outputs = {
8
8
  project_id = "project-dummy-id"
9
9
  }
@@ -1,9 +1,9 @@
1
1
  terraform {
2
- source = "git::https://github.com/terraform-google-modules/terraform-google-cloud-router//?ref=v1.1.0"
2
+ source = "git::https://github.com/terraform-google-modules/terraform-google-cloud-router//?ref=v5.0.0"
3
3
  }
4
4
 
5
5
  dependency "project" {
6
- config_path = "../"
6
+ config_path = "../../"
7
7
  mock_outputs = {
8
8
  project_id = "project-dummy-id"
9
9
  }
@@ -13,7 +13,6 @@ dependency "network" {
13
13
  config_path = "../network"
14
14
  mock_outputs = {
15
15
  network_name = "network-dummy-name"
16
- subnets_names = "subnet-dummy-name"
17
16
  }
18
17
  }
19
18
 
@@ -21,9 +20,13 @@ include {
21
20
  path = find_in_parent_folders("terragrunt_root.hcl")
22
21
  }
23
22
 
23
+ locals {
24
+ clan_name = basename(dirname(dirname(dirname(get_terragrunt_dir()))))
25
+ }
26
+
24
27
  inputs = merge(
25
28
  {
26
- name = "<%- tribe %>-router"
29
+ name = "${local.clan_name}-router"
27
30
  region = "europe-west1"
28
31
  project = dependency.project.outputs.project_id
29
32
  network = dependency.network.outputs.network_name
@@ -0,0 +1,40 @@
1
+ terraform {
2
+ source = "git::https://github.com/extenda/tf-module-gcp-project//modules/gke-resources?ref=v2.0.0"
3
+ }
4
+
5
+ dependency "project" {
6
+ config_path = "../../../"
7
+ mock_outputs = {
8
+ project_id = "project-dummy-id"
9
+ ci_cd_service_account_email = {
10
+ "ci-cd-pipeline" = "dummy"
11
+ }
12
+ }
13
+ }
14
+
15
+ dependency "gke" {
16
+ config_path = "../"
17
+ mock_outputs = {
18
+ endpoint = "dummy-endpoint"
19
+ ca_certificate = base64encode("dummy-ca-certificate")
20
+ }
21
+ }
22
+
23
+ include {
24
+ path = find_in_parent_folders("terragrunt_root.hcl")
25
+ }
26
+
27
+ locals {
28
+ clan_name = basename(dirname(dirname(dirname(get_terragrunt_dir()))))
29
+ project_yaml = yamldecode(file(find_in_parent_folders("project.yaml")))
30
+ }
31
+
32
+ inputs = merge(
33
+ {
34
+ services = local.project_yaml.services
35
+ project_id = dependency.project.outputs.project_id
36
+ gke_host = dependency.gke.outputs.endpoint
37
+ gke_ca_certificate = dependency.gke.outputs.ca_certificate
38
+ cicd_service = dependency.project.outputs.ci_cd_service_account_email["ci-cd-pipeline"]
39
+ }
40
+ )
@@ -0,0 +1,18 @@
1
+ locals {
2
+ regional = true
3
+ region = "europe-west1"
4
+ zones = ["europe-west1-d", "europe-west1-c", "europe-west1-b"]
5
+ ip_range_pods = "pods-cidr"
6
+ ip_range_services = "services-cidr"
7
+ create_service_account = true
8
+ grant_registry_access = true
9
+ http_load_balancing = true
10
+ add_cluster_firewall_rules = false #needs to be changed to true after the first apply
11
+ dns_cache = true
12
+ enable_vertical_pod_autoscaling = true
13
+ enable_private_nodes = true
14
+ master_global_access_enabled = false
15
+ release_channel = "REGULAR"
16
+ enable_cost_allocation = true
17
+ maintenance_start_time = "01:00" #UTC
18
+ }
@@ -1,7 +1,7 @@
1
1
  # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
2
2
  # working directory, into a temporary folder, and execute your Terraform commands in that folder.
3
3
  terraform {
4
- source = "git::https://github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/beta-private-cluster?ref=v13.0.0"
4
+ source = "git::https://github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/beta-autopilot-private-cluster?ref=v25.0.0"
5
5
  }
6
6
 
7
7
  # Include all settings from the root terragrunt.hcl file
@@ -10,7 +10,7 @@ include {
10
10
  }
11
11
 
12
12
  dependency "project" {
13
- config_path = "../"
13
+ config_path = "../../"
14
14
  mock_outputs = {
15
15
  project_id = "project-dummy-id"
16
16
  }
@@ -20,27 +20,32 @@ dependency "network" {
20
20
  config_path = "../network"
21
21
  mock_outputs = {
22
22
  network_name = "network-dummy-name"
23
- subnets_names = "subnet-dummy-name"
24
23
  }
25
24
  }
26
25
 
27
26
  locals {
28
- spec_vars = read_terragrunt_config("${get_terragrunt_dir()}/spec.hcl")
29
- tribe_yaml = yamldecode(file(find_in_parent_folders("tribe.yaml")))
27
+ spec_vars = read_terragrunt_config("${get_terragrunt_dir()}/spec.hcl")
28
+ tribe_yaml = yamldecode(file(find_in_parent_folders("tribe.yaml")))
29
+ clan_name = basename(dirname(dirname(dirname(get_terragrunt_dir()))))
30
+ env_name = basename(dirname(dirname(get_terragrunt_dir())))
30
31
  }
31
32
 
32
33
  # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
33
34
  inputs = merge(
34
35
  local.spec_vars.locals,
35
36
  {
37
+ name = "${local.clan_name}-cluster-${local.env_name}"
36
38
  project_id = dependency.project.outputs.project_id
37
39
  network = dependency.network.outputs.network_name
38
40
  subnetwork = "k8s-subnet"
39
41
  identity_namespace = "${dependency.project.outputs.project_id}.svc.id.goog"
40
42
  authenticator_security_group = "gke-security-groups@extendaretail.com"
41
- registry_project_id = "extenda"
43
+ registry_project_ids = ["extenda"]
42
44
  cluster_resource_labels = {
43
45
  cc = local.tribe_yaml.costcenter
44
46
  }
47
+
48
+ // Binary Auth must be Enabled manually in this console - not supported by the module yet
49
+ enable_binary_authorization = true
45
50
  }
46
51
  )
@@ -13,3 +13,16 @@ resource "google_compute_firewall" "dataflow-workers" {
13
13
  source_tags = ["dataflow"]
14
14
  target_tags = ["dataflow"]
15
15
  }
16
+
17
+ resource "google_compute_firewall" "allow_negs" {
18
+ name = "allow-negs"
19
+ network = var.network
20
+ project = var.project
21
+
22
+ allow {
23
+ protocol = "all"
24
+ }
25
+ source_ranges = ["35.191.0.0/16", "130.211.0.0/22"]
26
+ priority = 1000
27
+ direction = "INGRESS"
28
+ }
@@ -0,0 +1,9 @@
1
+ variable "network" {
2
+ description = "The name or self_link of the network to attach this firewall to"
3
+ type = string
4
+ }
5
+
6
+ variable "project" {
7
+ description = "The ID of the project in which the resource belongs"
8
+ type = string
9
+ }
@@ -16,8 +16,8 @@ dependency "network" {
16
16
  }
17
17
  }
18
18
 
19
- dependency "tribe_project" {
20
- config_path = "../../"
19
+ dependency "clan_project" {
20
+ config_path = "../../../"
21
21
  mock_outputs = {
22
22
  project_id = "dummy-id"
23
23
  }
@@ -27,6 +27,6 @@ dependency "tribe_project" {
27
27
  inputs = merge(
28
28
  {
29
29
  network = dependency.network.outputs.network_self_link
30
- project = dependency.tribe_project.outputs.project_id
30
+ project = dependency.clan_project.outputs.project_id
31
31
  }
32
32
  )
@@ -0,0 +1,46 @@
1
+ locals {
2
+ network_name = "clan-network"
3
+
4
+ subnets = [
5
+ {
6
+ subnet_name = "k8s-subnet"
7
+ subnet_ip = "10.152.16.0/23"
8
+ subnet_region = "europe-west1"
9
+ subnet_private_access = true
10
+ },
11
+ {
12
+ subnet_name = "clan-resources"
13
+ subnet_ip = "10.152.20.0/22"
14
+ subnet_region = "europe-west1"
15
+ subnet_private_access = true
16
+ },
17
+ {
18
+ subnet_name = "vpc-connector-subnet"
19
+ subnet_ip = "10.8.0.0/28"
20
+ subnet_region = "europe-west1"
21
+ description = "The subnet must be used only for Serverless VPC connector"
22
+ subnet_private_access = true
23
+ },
24
+ {
25
+ subnet_name = "internal-lb-subnet"
26
+ subnet_ip = "10.10.0.0/23"
27
+ subnet_region = "europe-west1"
28
+ purpose = "REGIONAL_MANAGED_PROXY"
29
+ role = "ACTIVE"
30
+ description = "The subnet must be used only for Serverless VPC connector"
31
+ }
32
+ ]
33
+
34
+ secondary_ranges = {
35
+ "k8s-subnet" = [
36
+ {
37
+ range_name = "pods-cidr"
38
+ ip_cidr_range = "172.18.0.0/20"
39
+ },
40
+ {
41
+ range_name = "services-cidr"
42
+ ip_cidr_range = "172.19.0.0/20"
43
+ }
44
+ ]
45
+ }
46
+ }
@@ -1,7 +1,7 @@
1
1
  # Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the
2
2
  # working directory, into a temporary folder, and execute your Terraform commands in that folder.
3
3
  terraform {
4
- source = "git::https://github.com/terraform-google-modules/terraform-google-network//?ref=v3.3.0"
4
+ source = "git::https://github.com/terraform-google-modules/terraform-google-network//?ref=v6.0.1"
5
5
  }
6
6
 
7
7
  # Include all settings from the root terragrunt.hcl file
@@ -10,7 +10,7 @@ include {
10
10
  }
11
11
 
12
12
  dependency "project" {
13
- config_path = "../"
13
+ config_path = "../../"
14
14
  mock_outputs = {
15
15
  project_id = "project-dummy-id"
16
16
  }
@@ -2,7 +2,8 @@ resource "google_compute_global_address" "private_ip_alloc" {
2
2
  provider = google-beta
3
3
 
4
4
  project = var.project
5
- name = "private-ip-alloc"
5
+ name = "private-ip-peering"
6
+ description = "VPC Private connection"
6
7
  purpose = var.purpose
7
8
  address_type = var.address_type
8
9
  prefix_length = var.prefix_length
@@ -3,7 +3,7 @@ terraform {
3
3
  }
4
4
 
5
5
  dependency "project" {
6
- config_path = "../"
6
+ config_path = "../../"
7
7
  mock_outputs = {
8
8
  project_id = "project-dummy-id"
9
9
  }
@@ -21,7 +21,7 @@ include {
21
21
  }
22
22
 
23
23
  locals {
24
- tribe_yaml = yamldecode(file(find_in_parent_folders("tribe.yaml")))
24
+ tribe_yaml = yamldecode(file(find_in_parent_folders("tribe.yaml")))
25
25
  }
26
26
 
27
27
  inputs = merge(
@@ -0,0 +1,40 @@
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-network//modules/vpc-serverless-connector-beta?ref=v6.0.1"
5
+ }
6
+
7
+ # Include all settings from the root terragrunt.hcl file
8
+ include {
9
+ path = find_in_parent_folders("terragrunt_root.hcl")
10
+ }
11
+
12
+ dependency "project" {
13
+ config_path = "../../"
14
+ mock_outputs = {
15
+ project_id = "project-dummy-id"
16
+ }
17
+ }
18
+
19
+ locals {
20
+ clan_name = basename(dirname(dirname(dirname(get_terragrunt_dir()))))
21
+ }
22
+
23
+ # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
24
+ inputs = merge(
25
+ {
26
+ project_id = dependency.project.outputs.project_id
27
+ vpc_connectors = [
28
+ {
29
+ name = "${local.clan_name}-connector"
30
+ region = "europe-west1"
31
+ subnet_name = "vpc-connector-subnet"
32
+ host_project_id = dependency.project.outputs.project_id
33
+ machine_type = "e2-micro"
34
+ min_instances = 2
35
+ max_instances = 3
36
+ max_throughput = 300
37
+ }
38
+ ]
39
+ }
40
+ )
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Create tribe project with GKE and related resources",
2
+ "description": "Create clan resources with GKE Autopilot cluster.",
3
3
  "query": "What do you want to create?",
4
4
  "require": [
5
5
  "org"
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Create GCP resources.",
2
+ "description": "Create common clan GCP resources.",
3
3
  "query": "What do you want to create?",
4
4
  "require": [
5
5
  "git-repo",
@@ -63,10 +63,7 @@ module.exports = class extends BaseGenerator {
63
63
  type: 'input',
64
64
  name: 'databaseName',
65
65
  message: 'Please provide a name for the database',
66
- validate: (input) => {
67
- const validation = validName(input);
68
- return validation.valid ? true : validation.message;
69
- },
66
+ validate: validName,
70
67
  },
71
68
  {
72
69
  when: (response) => response.resourceType === 'database',
@@ -79,10 +76,7 @@ module.exports = class extends BaseGenerator {
79
76
  type: 'input',
80
77
  name: 'retentionPeriod',
81
78
  message: 'Please provide version retention period. Maximum value 7d, possible values include 84000s, 1h, 2d. Leave empty for default value 1h.',
82
- validate: (input) => {
83
- const validation = validRetentionPeriod(input);
84
- return validation.valid ? true : validation.message;
85
- },
79
+ validate: validRetentionPeriod,
86
80
  },
87
81
  ];
88
82
 
@@ -0,0 +1,24 @@
1
+ const validName = (input) => {
2
+ if (input.replace(/\s/g, '').length >= 6 && input.length <= 30) {
3
+ return true;
4
+ }
5
+ return 'Name must be between 6 and 30 characters in length';
6
+ };
7
+
8
+ const validRetentionPeriod = (input) => {
9
+ const validFormats = /^(84000s|1h|2d|7d)$/;
10
+
11
+ if (input === '') {
12
+ return true;
13
+ }
14
+ if (validFormats.test(input)) {
15
+ return true;
16
+ }
17
+
18
+ return 'Invalid retention period format. Possible values are 84000s, 1h, 2d, or leave empty for default value 1h';
19
+ };
20
+
21
+ module.exports = {
22
+ validName,
23
+ validRetentionPeriod,
24
+ };
@@ -55,6 +55,12 @@ module.exports = class extends BaseGenerator {
55
55
  message: 'Name of GitHub repository for clan common infrastructure',
56
56
  default: (answers) => `${answers.tribe}-${answers.clan}-common`,
57
57
  },
58
+ {
59
+ type: 'input',
60
+ name: 'costCenter',
61
+ message: 'Please provide the Cost Center of the Clan',
62
+ validate: required,
63
+ },
58
64
  ];
59
65
 
60
66
  return this.prompt(prompts).then((props) => {
@@ -14,7 +14,9 @@
14
14
  # email: bob@extendaretail.com
15
15
  ###
16
16
  ---
17
- common-infra-repo: <%-commonInfraRepo%>
17
+ common-infra-repo: "<%-commonInfraRepo%>"
18
18
  members:
19
19
  groups: []
20
20
  users: []
21
+
22
+ costcenter: "<%-costCenter%>"