@hiiretail/gcp-infra-cli 0.103.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +9 -46
  2. package/bin/gcp-infra +5 -2
  3. package/package.json +7 -30
  4. package/src/gcp-infra.js +87 -0
  5. package/LICENSE +0 -21
  6. package/generators/clan-resources/clan-project/generator.json +0 -4
  7. package/generators/clan-resources/clan-project/index.js +0 -135
  8. package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat/terragrunt.hcl +0 -52
  9. package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat-static-ip/spec.hcl +0 -7
  10. package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat-static-ip/terragrunt.hcl +0 -25
  11. package/generators/clan-resources/clan-project/templates/clan-resources/cloud-router/terragrunt.hcl +0 -34
  12. package/generators/clan-resources/clan-project/templates/clan-resources/gke/gke-resources/terragrunt.hcl +0 -40
  13. package/generators/clan-resources/clan-project/templates/clan-resources/gke/spec.hcl +0 -18
  14. package/generators/clan-resources/clan-project/templates/clan-resources/gke/terragrunt.hcl +0 -52
  15. package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/config/main.tf +0 -41
  16. package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/config/vars.tf +0 -9
  17. package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/terragrunt.hcl +0 -32
  18. package/generators/clan-resources/clan-project/templates/clan-resources/network/spec.hcl +0 -54
  19. package/generators/clan-resources/clan-project/templates/clan-resources/network/terragrunt.hcl +0 -29
  20. package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/config/main.tf +0 -18
  21. package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/config/vars.tf +0 -27
  22. package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/terragrunt.hcl +0 -35
  23. package/generators/clan-resources/clan-project/templates/clan-resources/serverless-vpc-connector/terragrunt.hcl +0 -40
  24. package/generators/clan-resources/clan-project/templates/clan-resources/terragrunt.hcl +0 -3
  25. package/generators/clan-resources/command.json +0 -7
  26. package/generators/common-resources/bigquery/generator.json +0 -4
  27. package/generators/common-resources/bigquery/index.js +0 -284
  28. package/generators/common-resources/bigquery/templates/bigquery/spec.hcl +0 -8
  29. package/generators/common-resources/bigquery/templates/bigquery/terragrunt.hcl +0 -53
  30. package/generators/common-resources/bigquery/templates/scheduled-queries/terragrunt.hcl +0 -56
  31. package/generators/common-resources/bigquery/templates/schema/schema.json +0 -14
  32. package/generators/common-resources/budget/generator.json +0 -4
  33. package/generators/common-resources/budget/index.js +0 -89
  34. package/generators/common-resources/budget/templates/budget/terragrunt.hcl +0 -45
  35. package/generators/common-resources/cloud-armor/generator.json +0 -4
  36. package/generators/common-resources/cloud-armor/index.js +0 -45
  37. package/generators/common-resources/cloud-armor/templates/policies.yaml +0 -53
  38. package/generators/common-resources/cloud-armor/templates/terragrunt.hcl +0 -30
  39. package/generators/common-resources/cloud-storage/generator.json +0 -4
  40. package/generators/common-resources/cloud-storage/index.js +0 -156
  41. package/generators/common-resources/cloud-storage/templates/cloud-storage/storage.yaml +0 -26
  42. package/generators/common-resources/cloud-storage/templates/cloud-storage/terragrunt.hcl +0 -32
  43. package/generators/common-resources/cloudsql/generator.json +0 -4
  44. package/generators/common-resources/cloudsql/index.js +0 -106
  45. package/generators/common-resources/cloudsql/templates/mssql/instance/spec.hcl +0 -76
  46. package/generators/common-resources/cloudsql/templates/mssql/instance/terragrunt.hcl +0 -38
  47. package/generators/common-resources/cloudsql/templates/mssql/instance-secrets/terragrunt.hcl +0 -37
  48. package/generators/common-resources/cloudsql/templates/mysql/instance/spec.hcl +0 -73
  49. package/generators/common-resources/cloudsql/templates/mysql/instance/terragrunt.hcl +0 -40
  50. package/generators/common-resources/cloudsql/templates/mysql/instance-secrets/terragrunt.hcl +0 -38
  51. package/generators/common-resources/cloudsql/templates/postgres-clan/instance/spec.hcl +0 -102
  52. package/generators/common-resources/cloudsql/templates/postgres-clan/instance/terragrunt.hcl +0 -36
  53. package/generators/common-resources/cloudsql/templates/postgres-clan/instance-secrets/terragrunt.hcl +0 -44
  54. package/generators/common-resources/cloudsql-database/generator.json +0 -4
  55. package/generators/common-resources/cloudsql-database/index.js +0 -70
  56. package/generators/common-resources/cloudsql-database/templates/mysql/database/proxy_port.hcl +0 -4
  57. package/generators/common-resources/cloudsql-database/templates/mysql/database/terragrunt.hcl +0 -69
  58. package/generators/common-resources/cloudsql-database/templates/mysql/outputs.json +0 -5
  59. package/generators/common-resources/cloudsql-database/templates/mysql/secrets/terragrunt.hcl +0 -30
  60. package/generators/common-resources/cloudsql-database/templates/postgres/database/proxy_port.hcl +0 -4
  61. package/generators/common-resources/cloudsql-database/templates/postgres/database/spec.hcl +0 -17
  62. package/generators/common-resources/cloudsql-database/templates/postgres/database/terragrunt.hcl +0 -74
  63. package/generators/common-resources/cloudsql-database/templates/postgres/outputs.json +0 -5
  64. package/generators/common-resources/cloudsql-database/templates/postgres/secrets/terragrunt.hcl +0 -30
  65. package/generators/common-resources/command.json +0 -8
  66. package/generators/common-resources/confluent-cluster/generator.json +0 -4
  67. package/generators/common-resources/confluent-cluster/index.js +0 -52
  68. package/generators/common-resources/confluent-cluster/templates/confluent/spec.hcl +0 -5
  69. package/generators/common-resources/confluent-cluster/templates/confluent/terragrunt.hcl +0 -25
  70. package/generators/common-resources/datastore/generator.json +0 -4
  71. package/generators/common-resources/datastore/index.js +0 -91
  72. package/generators/common-resources/datastore/templates/datastore/indexes.yaml +0 -6
  73. package/generators/common-resources/datastore/templates/datastore/terragrunt.hcl +0 -23
  74. package/generators/common-resources/elastic-cloud/generator.json +0 -4
  75. package/generators/common-resources/elastic-cloud/index.js +0 -52
  76. package/generators/common-resources/elastic-cloud/templates/elastic/spec.hcl +0 -27
  77. package/generators/common-resources/elastic-cloud/templates/elastic/terragrunt.hcl +0 -27
  78. package/generators/common-resources/elastic-index-policy/generator.json +0 -4
  79. package/generators/common-resources/elastic-index-policy/handle-yaml.js +0 -76
  80. package/generators/common-resources/elastic-index-policy/index.js +0 -210
  81. package/generators/common-resources/elastic-index-policy/templates/policy/policy.yaml +0 -28
  82. package/generators/common-resources/elastic-index-policy/templates/policy/terragrunt.hcl +0 -25
  83. package/generators/common-resources/elastic-template/generator.json +0 -4
  84. package/generators/common-resources/elastic-template/index.js +0 -84
  85. package/generators/common-resources/elastic-template/templates/elastic-template/mappings.json +0 -1
  86. package/generators/common-resources/elastic-template/templates/elastic-template/terragrunt.hcl +0 -35
  87. package/generators/common-resources/firestore/generator.json +0 -4
  88. package/generators/common-resources/firestore/index.js +0 -81
  89. package/generators/common-resources/firestore/templates/firestore/indexes.yaml +0 -10
  90. package/generators/common-resources/firestore/templates/firestore/terragrunt.hcl +0 -25
  91. package/generators/common-resources/iam/generator.json +0 -4
  92. package/generators/common-resources/iam/index.js +0 -62
  93. package/generators/common-resources/iam/templates/github/workflows/iam.yml +0 -18
  94. package/generators/common-resources/iam/templates/iam.yaml +0 -8
  95. package/generators/common-resources/iam/valid-prefix.js +0 -8
  96. package/generators/common-resources/kafka-connect/generator.json +0 -4
  97. package/generators/common-resources/kafka-connect/index.js +0 -75
  98. package/generators/common-resources/kafka-connect/templates/elastic/terragrunt.hcl +0 -92
  99. package/generators/common-resources/kafka-connect/templates/pubsub/terragrunt.hcl +0 -75
  100. package/generators/common-resources/kafka-topics/generator.json +0 -4
  101. package/generators/common-resources/kafka-topics/index.js +0 -54
  102. package/generators/common-resources/kafka-topics/templates/kafka/kafka.yaml +0 -20
  103. package/generators/common-resources/kafka-topics/templates/kafka/terragrunt.hcl +0 -21
  104. package/generators/common-resources/kms/generator.json +0 -4
  105. package/generators/common-resources/kms/index.js +0 -69
  106. package/generators/common-resources/kms/templates/kms/spec.hcl +0 -5
  107. package/generators/common-resources/kms/templates/kms/terragrunt.hcl +0 -33
  108. package/generators/common-resources/memorystore/generator.json +0 -4
  109. package/generators/common-resources/memorystore/index.js +0 -69
  110. package/generators/common-resources/memorystore/templates/outputs.json +0 -3
  111. package/generators/common-resources/memorystore/templates/redis-instance/spec.hcl +0 -16
  112. package/generators/common-resources/memorystore/templates/redis-instance/terragrunt.hcl +0 -35
  113. package/generators/common-resources/memorystore/templates/secrets/terragrunt.hcl +0 -31
  114. package/generators/common-resources/monitoring/generator.json +0 -4
  115. package/generators/common-resources/monitoring/handle-yaml.js +0 -48
  116. package/generators/common-resources/monitoring/index.js +0 -192
  117. package/generators/common-resources/monitoring/templates/alerts/generic-infra.yaml +0 -633
  118. package/generators/common-resources/monitoring/templates/alerts/terragrunt.hcl +0 -37
  119. package/generators/common-resources/monitoring/templates/service/service.yaml +0 -16
  120. package/generators/common-resources/monitoring/templates/service/terragrunt.hcl +0 -37
  121. package/generators/common-resources/monitoring/templates/uptime-checks/terragrunt.hcl +0 -36
  122. package/generators/common-resources/monitoring/templates/uptime-checks/uptime-checks.yaml +0 -3
  123. package/generators/common-resources/monitoring/validate.js +0 -58
  124. package/generators/common-resources/pubsub/append.js +0 -120
  125. package/generators/common-resources/pubsub/generator.json +0 -4
  126. package/generators/common-resources/pubsub/get-gcp-projects.js +0 -34
  127. package/generators/common-resources/pubsub/handle-subscribers.js +0 -63
  128. package/generators/common-resources/pubsub/index.js +0 -316
  129. package/generators/common-resources/pubsub/templates/pubsub/spec.hcl +0 -7
  130. package/generators/common-resources/pubsub/templates/pubsub/subscribers.yaml +0 -16
  131. package/generators/common-resources/pubsub/templates/pubsub/terragrunt.hcl +0 -34
  132. package/generators/common-resources/pubsub/templates/pubsub-dlq/terragrunt.hcl +0 -42
  133. package/generators/common-resources/pubsub/templates/pubsub-external/spec.hcl +0 -10
  134. package/generators/common-resources/pubsub/templates/pubsub-external/subscribers.yaml +0 -16
  135. package/generators/common-resources/pubsub/templates/pubsub-external/terragrunt.hcl +0 -31
  136. package/generators/common-resources/pubsub/validate.js +0 -44
  137. package/generators/common-resources/scheduler/append.js +0 -83
  138. package/generators/common-resources/scheduler/generator.json +0 -4
  139. package/generators/common-resources/scheduler/index.js +0 -103
  140. package/generators/common-resources/scheduler/templates/scheduler/terragrunt.hcl +0 -44
  141. package/generators/common-resources/spanner/append.js +0 -27
  142. package/generators/common-resources/spanner/generator.json +0 -4
  143. package/generators/common-resources/spanner/index.js +0 -169
  144. package/generators/common-resources/spanner/templates/spanner/databases.yaml +0 -5
  145. package/generators/common-resources/spanner/templates/spanner/spec.hcl +0 -22
  146. package/generators/common-resources/spanner/templates/spanner/terragrunt.hcl +0 -33
  147. package/generators/common-resources/spanner/validate.js +0 -38
  148. package/generators/docs/command.json +0 -7
  149. package/generators/docs/rca/generator.json +0 -4
  150. package/generators/docs/rca/index.js +0 -50
  151. package/generators/docs/rca/templates/docs/rca_external.md +0 -43
  152. package/generators/docs/rca/templates/docs/rca_internal.md +0 -88
  153. package/generators/docs/runbook/generator.json +0 -4
  154. package/generators/docs/runbook/index.js +0 -42
  155. package/generators/docs/runbook/templates/docs/runbook.md +0 -106
  156. package/generators/docs/srb/generator.json +0 -4
  157. package/generators/docs/srb/index.js +0 -62
  158. package/generators/docs/srb/templates/docs/README.md +0 -42
  159. package/generators/docs/srb/templates/docs/adr.cmd +0 -3
  160. package/generators/docs/srb/templates/docs/adr.sh +0 -4
  161. package/generators/docs/srb/templates/docs/architecture.md +0 -68
  162. package/generators/docs/srb/templates/docs/cost-estimates.md +0 -39
  163. package/generators/docs/srb/templates/docs/dsl2png.cmd +0 -3
  164. package/generators/docs/srb/templates/docs/dsl2png.sh +0 -4
  165. package/generators/docs/srb/templates/docs/sre.md +0 -43
  166. package/generators/docs/srb/templates/sample.dsl +0 -36
  167. package/generators/init/clan-infra/gcp-projects.js +0 -36
  168. package/generators/init/clan-infra/generator.json +0 -4
  169. package/generators/init/clan-infra/index.js +0 -170
  170. package/generators/init/clan-infra/templates/.yamllint +0 -17
  171. package/generators/init/clan-infra/templates/env/project.hcl +0 -15
  172. package/generators/init/clan-infra/templates/env/secrets/secrets.yaml +0 -4
  173. package/generators/init/clan-infra/templates/env/secrets/terragrunt.hcl +0 -31
  174. package/generators/init/clan-infra/templates/github/CODEOWNERS +0 -1
  175. package/generators/init/clan-infra/templates/github/workflows/infra-verify.yml +0 -16
  176. package/generators/init/clan-infra/templates/github/workflows/infra.yml +0 -17
  177. package/generators/init/clan-infra/templates/github/workflows/release-notes.yml +0 -33
  178. package/generators/init/clan-infra/templates/github/workflows/sync-docs.yml +0 -29
  179. package/generators/init/clan-infra/templates/infra/.terraform-version +0 -1
  180. package/generators/init/clan-infra/templates/infra/.terragrunt-version +0 -1
  181. package/generators/init/clan-infra/templates/infra/README.md +0 -5
  182. package/generators/init/clan-infra/templates/infra/common.hcl +0 -24
  183. package/generators/init/clan-infra/templates/infra/terragrunt_root.hcl +0 -44
  184. package/generators/init/clan-infra/templates/notification-channels/notification-channels.yaml +0 -7
  185. package/generators/init/clan-infra/templates/notification-channels/terragrunt.hcl +0 -29
  186. package/generators/init/clan-infra/templates/release-notes/example-service.yaml +0 -23
  187. package/generators/init/clan-infra/templates/release-notes-schema/release-notes.schema.json +0 -63
  188. package/generators/init/clan-infra/tribe-clan-repo.js +0 -38
  189. package/generators/init/clan-infra/validate.js +0 -8
  190. package/generators/init/command.json +0 -7
  191. package/generators/maintenance/command.json +0 -7
  192. package/generators/maintenance/manage-states/generator.json +0 -4
  193. package/generators/maintenance/manage-states/index.js +0 -188
  194. package/generators/maintenance/update-modules/generator.json +0 -4
  195. package/generators/maintenance/update-modules/index.js +0 -102
  196. package/generators/organization/clan-project/__tests__/__snapshots__/googlecloud.test.js.snap +0 -27
  197. package/generators/organization/clan-project/generator.json +0 -4
  198. package/generators/organization/clan-project/googlecloud.js +0 -119
  199. package/generators/organization/clan-project/index.js +0 -139
  200. package/generators/organization/clan-project/templates/clan/clan.yaml +0 -22
  201. package/generators/organization/clan-project/templates/clan/terragrunt.hcl +0 -39
  202. package/generators/organization/clan-project/templates/clan-project/project.yaml +0 -14
  203. package/generators/organization/clan-project/templates/clan-project/terragrunt.hcl +0 -51
  204. package/generators/organization/clan-project/templates/clans-folder/terragrunt.hcl +0 -3
  205. package/generators/organization/clan-project/templates/department/terragrunt.hcl +0 -32
  206. package/generators/organization/clan-project/templates/tribe/terragrunt.hcl +0 -67
  207. package/generators/organization/clan-project/templates/tribe/tribe.yaml +0 -19
  208. package/generators/organization/command.json +0 -8
  209. package/src/BaseGenerator.js +0 -73
  210. package/src/SecretsGenerator.js +0 -105
  211. package/src/cli.js +0 -73
  212. package/src/dependency-check.js +0 -48
  213. package/src/update-check.js +0 -30
  214. package/src/validators.js +0 -32
  215. package/src/yeoman.js +0 -71
@@ -1,16 +0,0 @@
1
- <% if (createResource == 'topic') { %><% } %><% if (createResource == 'subscription' && pushOrPull == 'push') { %>push_subscriptions:
2
- - name: "<%-existingTopic%>+<%-subscriberName%>"
3
- push_endpoint: "<%-pushEndpoint%>" <% if (env == 'prod') { %>
4
- dead_letter_topic: "<%-dlqTopic%>" <% } %>
5
- oidc_service_account_email: "<%-oidcEmail%>"
6
- audience: "<%-audience%>"
7
- expiration_policy: ""
8
- max_delivery_attempts: 5
9
- maximum_backoff: "30s"
10
- minimum_backoff: "2s"
11
- filter: 'attributes.Consumer = "<%-subscriberName%>" OR NOT attributes:Consumer' <% } %><% if (createResource == 'subscription' && pushOrPull == 'pull') { %>pull_subscriptions:
12
- - name: "<%-existingTopic%>+<%-subscriberName%>"
13
- ack_deadline_seconds: "60" <% if (env == 'prod') { %>
14
- dead_letter_topic: "<%-dlqTopic%>" <% } %>
15
- expiration_policy: ""
16
- filter: 'attributes.Consumer = "<%-subscriberName%>" OR NOT attributes:Consumer'<% } %>
@@ -1,34 +0,0 @@
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-pubsub//?ref=v6.0.0"
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
- locals {
13
- spec_vars = read_terragrunt_config("${get_terragrunt_dir()}/spec.hcl")
14
- project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
15
- common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
16
- labels = merge(local.common_vars.locals.default_user_labels, local.project_vars.locals.default_user_labels, {
17
- component = local.common_vars.locals.component
18
- product = local.common_vars.locals.product
19
- tenant-alias = local.common_vars.locals.tenant_alias
20
- })
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(<% if (createResource == 'topic') { %><% } else { %>
25
- yamldecode(
26
- file("${get_terragrunt_dir()}/subscribers.yaml")),<% } %>
27
- local.spec_vars.locals,
28
- local.project_vars.locals,
29
- {
30
- topic_labels = local.labels<% if (createResource == 'topic') { %><% } else { %>
31
- subscription_labels = local.labels<% } %>
32
- grant_token_creator = false
33
- }
34
- )
@@ -1,42 +0,0 @@
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-pubsub//?ref=v6.0.0"
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
- locals {
13
- project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
14
- common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
15
- labels = merge(local.common_vars.locals.default_user_labels, local.project_vars.locals.default_user_labels, {
16
- component = local.common_vars.locals.component
17
- product = local.common_vars.locals.product
18
- tenant-alias = local.common_vars.locals.tenant_alias
19
- })
20
- }
21
-
22
- # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
23
- inputs = merge(
24
- local.project_vars.locals,
25
- {
26
- topic = "dlq.${local.common_vars.locals.clan_name}.common"
27
- create_subscriptions = true
28
- create_topic = true
29
- push_subscriptions = [
30
- {
31
- name = "dlq.${local.common_vars.locals.clan_name}.common+dlq.message-handler",
32
- push_endpoint = "https://europe-west1-sre-prod-5462.cloudfunctions.net/dlq-message-handler",
33
- audience = "https://europe-west1-sre-prod-5462.cloudfunctions.net/dlq-message-handler",
34
- expiration_policy = "",
35
- oidc_service_account_email = "pubsub-dlq-handler@${local.project_vars.locals.project_id}.iam.gserviceaccount.com",
36
- },
37
- ],
38
- topic_labels = local.labels,
39
- subscription_labels = local.labels,
40
- grant_token_creator = false,
41
- }
42
- )
@@ -1,10 +0,0 @@
1
- locals {<% if (env == 'staging') { %>
2
- project_id = "<%-stagingProjectIdConsumer%>" #external project <% } else { %>
3
- project_id = "<%-prodProjectIdConsumer%>" #external project <% } %>
4
- topic_project = "<%-projectId%>"
5
- create_topic = false
6
- create_subscriptions = true
7
- subscription_labels = {
8
- cc = "<%-costCenter%>" #cc of external project
9
- }
10
- }
@@ -1,16 +0,0 @@
1
- <% if (pushOrPull == 'push') { %>push_subscriptions:
2
- - name: "<%-existingTopic%>+<%-subscriberName%>"
3
- push_endpoint: "<%-pushEndpoint%>" <% if (env == 'prod') { %>
4
- dead_letter_topic: "<%-dlqTopic%>" <% } %>
5
- oidc_service_account_email: "<%-oidcEmail%>"
6
- audience: "<%-audience%>"
7
- expiration_policy: ""
8
- max_delivery_attempts: 5
9
- maximum_backoff: "30s"
10
- minimum_backoff: "2s"
11
- filter: 'attributes.Consumer = "<%-subscriberName%>" OR NOT attributes:Consumer'<% } %><% if (pushOrPull == 'pull') { %>pull_subscriptions:
12
- - name: "<%-existingTopic%>+<%-subscriberName%>"
13
- ack_deadline_seconds: "60" <% if (env == 'prod') { %>
14
- dead_letter_topic: "<%-dlqTopic%>" <% } %>
15
- expiration_policy: ""
16
- filter: 'attributes.Consumer = "<%-subscriberName%>" OR NOT attributes:Consumer'<% } %>
@@ -1,31 +0,0 @@
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-pubsub//?ref=v6.0.0"
5
- }
6
-
7
- include {
8
- path = find_in_parent_folders("terragrunt_root.hcl")
9
- }
10
-
11
- dependency "topic-name" {
12
- config_path = "../"
13
- mock_outputs = {
14
- topic = "dummy-topic"
15
- }
16
- }
17
-
18
- locals {
19
- spec_vars = read_terragrunt_config("${get_terragrunt_dir()}/spec.hcl")
20
- }
21
-
22
- # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
23
- inputs = merge(
24
- yamldecode(
25
- file("${get_terragrunt_dir()}/subscribers.yaml")),
26
- local.spec_vars.locals,
27
- {
28
- topic = "projects/${local.spec_vars.locals.topic_project}/topics/${dependency.topic-name.outputs.topic}"
29
- grant_token_creator = false
30
- }
31
- )
@@ -1,44 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const validSystemName = (input) => {
5
- if (input.replace(/\s/g, '').length === 3) {
6
- return true;
7
- }
8
- return 'System name must be 3 characters';
9
- };
10
-
11
- const validVersion = (input) => {
12
- const regex = '^v[0-9]$';
13
- if (input.match(regex)) {
14
- return true;
15
- }
16
- return 'Not supported input of version';
17
- };
18
-
19
- const validSubscriberName = (input) => {
20
- const systemName = input.split('.')[0];
21
- const serviceName = input.split('.')[1];
22
- const serviceNameRexep = '^[a-zA-Z-_]+$';
23
-
24
- if ((systemName.replace(/\s/g, '').length === 3) && (serviceName.match(serviceNameRexep))) {
25
- return true;
26
- }
27
- return 'Not supported input for subscriber name';
28
- };
29
-
30
- const checkExistingTopicPath = (input) => {
31
- const topicDirPath = path.join(process.cwd(), 'infra', 'staging', 'pubsub', input);
32
-
33
- if (fs.existsSync(topicDirPath)) {
34
- return true;
35
- }
36
- return 'Topic does not exist. Check the spelling';
37
- };
38
-
39
- module.exports = {
40
- validSystemName,
41
- validVersion,
42
- validSubscriberName,
43
- checkExistingTopicPath,
44
- };
@@ -1,83 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const findScheduledJobs = (schedulerPath) => {
4
- const fileContent = fs.readFileSync(schedulerPath, 'utf8');
5
- const regex = /scheduled_jobs\s*=\s*\[\s*([\s\S]*?)\s*\]/;
6
- const match = regex.exec(fileContent);
7
- if (match) {
8
- const scheduledJobsText = match[1];
9
- return scheduledJobsText;
10
- }
11
- return '';
12
- };
13
-
14
- const writeScheduledJobs = (schedulerPath, scheduledJobs) => {
15
- const fileContent = fs.readFileSync(schedulerPath, 'utf8');
16
- const updatedContent = fileContent.replace(
17
- /scheduled_jobs\s*=\s*\[([\s\S]*?)\]/,
18
- `scheduled_jobs = [\n ${scheduledJobs}\n ]`,
19
- );
20
- fs.writeFileSync(schedulerPath, updatedContent);
21
- };
22
-
23
- const scheduledJobsToHCL = (scheduledJobs) => `${scheduledJobs.map((job) => {
24
- const httpTargetBlock = job.http_target
25
- ? `
26
- http_target = {
27
- uri = "${job.http_target.uri}"
28
- http_method = "${job.http_target.http_method}"
29
- }
30
- }`
31
- : '';
32
- const pubsubTargetBlock = job.pubsub_target
33
- ? `
34
- pubsub_target = {
35
- topic_name = "${job.pubsub_target.topic_name}"
36
- data = "${job.pubsub_target.data}"
37
- }
38
- }`
39
- : '';
40
- return `
41
- {
42
- name = "${job.name}"
43
- description = "${job.description}"
44
- schedule = "${job.schedule}"
45
- ${httpTargetBlock}${pubsubTargetBlock}`;
46
- })
47
- .join('\n')}`;
48
-
49
- const handleJobs = (schedulerPath, answers) => {
50
- const oldJobs = findScheduledJobs(schedulerPath);
51
- const allJobs = [oldJobs];
52
-
53
- if (answers.target === 'http') {
54
- const newHttpJob = {
55
- name: answers.name,
56
- description: answers.description,
57
- schedule: answers.schedule,
58
- http_target: {
59
- uri: answers.uri,
60
- http_method: answers.httpMethod,
61
- },
62
- };
63
-
64
- const newHttpJobHcl = scheduledJobsToHCL([newHttpJob]);
65
- allJobs.push(newHttpJobHcl);
66
- } else {
67
- const newPubsubJob = {
68
- name: answers.name,
69
- description: answers.description,
70
- schedule: answers.schedule,
71
- pubsub_target: {
72
- topic_name: answers.topicName,
73
- data: answers.data,
74
- },
75
- };
76
- const newPubsubJobHcl = scheduledJobsToHCL([newPubsubJob]);
77
- allJobs.push(newPubsubJobHcl);
78
- }
79
-
80
- writeScheduledJobs(schedulerPath, allJobs);
81
- };
82
-
83
- module.exports = handleJobs;
@@ -1,4 +0,0 @@
1
- {
2
- "name": "Scheduler",
3
- "description": "Create scheduled jobs"
4
- }
@@ -1,103 +0,0 @@
1
- const path = require('path');
2
- const chalk = require('chalk');
3
- const fs = require('fs');
4
- const BaseGenerator = require('../../../src/BaseGenerator');
5
- const { required } = require('../../../src/validators');
6
- const handleJobs = require('./append');
7
-
8
- module.exports = class extends BaseGenerator {
9
- prompting() {
10
- const prompts = [
11
- {
12
- type: 'input',
13
- name: 'name',
14
- message: 'Please provide the name of the job',
15
- validate: required,
16
- },
17
- {
18
- type: 'input',
19
- name: 'description',
20
- message: 'Please provide the description for the job',
21
- validate: required,
22
- },
23
- {
24
- type: 'list',
25
- name: 'timeZone',
26
- message: 'Please select the time zone to be used in interpreting schedule',
27
- default: 'Etc/UTC',
28
- choices: ['Etc/UTC', 'Etc/GMT'],
29
- },
30
- {
31
- type: 'input',
32
- name: 'schedule',
33
- message: 'Please provide the schedule on which the job will be executed(unix-cron format - * * * * *)',
34
- validate: required,
35
- },
36
- {
37
- type: 'list',
38
- name: 'target',
39
- message: 'Select the target for the job',
40
- choices: ['http', 'pubsub'],
41
- },
42
- {
43
- when: (response) => response.target === 'http',
44
- type: 'input',
45
- name: 'uri',
46
- message: 'Please provide the full URI path that the request will be send to',
47
- validate: required,
48
- },
49
- {
50
- when: (response) => response.target === 'http',
51
- type: 'input',
52
- name: 'httpMethod',
53
- message: 'Please provide which HTTP method to use for the request',
54
- validate: required,
55
- },
56
- {
57
- when: (response) => response.target === 'pubsub',
58
- type: 'input',
59
- name: 'topicName',
60
- message: 'Please provide the full Pub/Sub topic name',
61
- validate: required,
62
- },
63
- {
64
- when: (response) => response.target === 'pubsub',
65
- type: 'input',
66
- name: 'data',
67
- message: 'Please provide the message payload for Pub/Sub message',
68
- validate: required,
69
- },
70
- ];
71
-
72
- return this.prompt(prompts).then((props) => {
73
- this.answers = props;
74
- });
75
- }
76
-
77
- writing() {
78
- ['prod', 'staging'].forEach((env) => {
79
- const schedulerPath = path.join(process.cwd(), 'infra', env, 'scheduler', 'terragrunt.hcl');
80
- if (!fs.existsSync(schedulerPath)) {
81
- this.copyDir(
82
- 'scheduler',
83
- path.join('infra', env, 'scheduler'),
84
- {
85
- ...this.answers,
86
- env,
87
- },
88
- );
89
- } else {
90
- handleJobs(
91
- schedulerPath,
92
- this.answers,
93
- );
94
- }
95
- });
96
- }
97
-
98
- end() {
99
- this.log(`
100
- ${chalk.green('Your job resources have now been created. Please add any other specifications supported by the module if needed')}
101
- ${chalk.green('1.')} Push this change in a feature branch and open a pull request.`);
102
- }
103
- };
@@ -1,44 +0,0 @@
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/extenda/tf-module-gcp-scheduler//?ref=v1.2.0"
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
- <% if (target == 'pubsub') { %>
12
- dependency "topic" {
13
- config_path = "../pubsub/<%-topicName%>"
14
- mock_outputs = {
15
- topic = "dummy-name"
16
- }
17
- }
18
- <% } %>
19
- locals {
20
- project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
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
- local.project_vars.locals,
26
- {
27
- scheduled_jobs = [
28
- {
29
- name = "<%-name%>"
30
- description = "<%-description%>"
31
- schedule = "<%-schedule%>"
32
- <% if (target == 'http') { %>
33
- http_target = {
34
- uri = "<%-uri%>"
35
- http_method = "<%-httpMethod%>"
36
- } <% } else { %>
37
- pubsub_target = {
38
- topic_name = "projects/${local.project_vars.locals.project_id}/topics/${dependency.topic.outputs.topic}"
39
- data = "${base64encode("<%-data%>")}"
40
- }<% } %>
41
- }
42
- ],
43
- },
44
- )
@@ -1,27 +0,0 @@
1
- const fs = require('fs');
2
- const yaml = require('js-yaml');
3
-
4
- const appendToDatabasesYaml = (databasesYamlPath, newDbEntry) => {
5
- const databases = [];
6
- if (fs.existsSync(databasesYamlPath)) {
7
- const existingContent = fs.readFileSync(databasesYamlPath, 'utf8');
8
- const existingDatabases = yaml.load(existingContent).databases;
9
- databases.push(...existingDatabases);
10
- }
11
-
12
- // Exclude empty fields from newDbEntry
13
- const cleanNewDatabaseEntry = {
14
- name: newDbEntry.name,
15
- ...(newDbEntry.ddl ? { ddl: [newDbEntry.ddl] } : {}),
16
- ...(newDbEntry.retentionPeriod ? { version_retention_period: newDbEntry.retentionPeriod } : {}),
17
- ...(newDbEntry.backupSchedule ? { backup_schedule: newDbEntry.backupSchedule } : {}),
18
- };
19
-
20
- databases.push(cleanNewDatabaseEntry);
21
-
22
- const newYamlContent = yaml.dump({ databases }, { lineWidth: -1 });
23
-
24
- fs.writeFileSync(databasesYamlPath, newYamlContent, 'utf8');
25
- };
26
-
27
- module.exports = appendToDatabasesYaml;
@@ -1,4 +0,0 @@
1
- {
2
- "name": "Spanner",
3
- "description": "Create Cloud Spanner resources"
4
- }
@@ -1,169 +0,0 @@
1
- const path = require('path');
2
- const chalk = require('chalk');
3
- const fs = require('fs');
4
- const BaseGenerator = require('../../../src/BaseGenerator');
5
- const { required } = require('../../../src/validators');
6
- const { validName, validRetentionPeriod, validBackupSchedule } = require('./validate');
7
- const appendToDatabasesYaml = require('./append');
8
-
9
- module.exports = class extends BaseGenerator {
10
- prompting() {
11
- const prompts = [
12
- {
13
- type: 'list',
14
- name: 'resourceType',
15
- message: 'Select the resource you want to create',
16
- default: 'database',
17
- choices: ['instance', 'database'],
18
- },
19
- {
20
- when: (response) => response.resourceType === 'instance',
21
- type: 'list',
22
- name: 'regionalInstance',
23
- message: 'Both staging and prod will get configuration for regional instance. If multi regional is needed contact platform team',
24
- default: 'proceed',
25
- choices: ['proceed'],
26
- },
27
- {
28
- when: (response) => response.resourceType === 'instance',
29
- type: 'input',
30
- name: 'instanceName',
31
- message: 'Please provide a name for the instance',
32
- validate: validName,
33
- },
34
- {
35
- when: (response) => response.resourceType === 'instance',
36
- type: 'input',
37
- name: 'displayName',
38
- message: 'Please provide the descriptive name for this instance. Unique per project.',
39
- validate: validName,
40
- },
41
- {
42
- when: (response) => response.resourceType === 'instance',
43
- type: 'list',
44
- name: 'instanceAllocation',
45
- message: 'Select the specified config you want to add for the instance. Only one of these can be present in terraform node_count or processing_units',
46
- default: 'processing_units',
47
- choices: ['processing_units', 'num_nodes'],
48
- },
49
- {
50
- when: (response) => response.instanceAllocation === 'processing_units' && response.resourceType === 'instance',
51
- type: 'input',
52
- name: 'processingUnits',
53
- message: 'Please provide the number of processing units allocated to the instance',
54
- validate: required,
55
- },
56
- {
57
- when: (response) => response.instanceAllocation === 'num_nodes' && response.resourceType === 'instance',
58
- type: 'input',
59
- name: 'numNodes',
60
- message: 'Please provide the number of nodes allocated to the instance',
61
- validate: required,
62
- },
63
- {
64
- when: (response) => response.resourceType === 'database',
65
- type: 'input',
66
- name: 'databaseName',
67
- message: 'Please provide a name for the database',
68
- validate: validName,
69
- },
70
- {
71
- when: (response) => response.resourceType === 'database',
72
- type: 'input',
73
- name: 'ddl',
74
- message: 'Please provide an optional list of DDL statements to run inside the newly created database. Leave empty to add them later.',
75
- },
76
- {
77
- when: (response) => response.resourceType === 'database',
78
- type: 'input',
79
- name: 'retentionPeriod',
80
- message: 'Please provide version retention period. Maximum value 7d, possible values include 84000s, 1h, 2d. Leave empty for default value 1h.',
81
- validate: validRetentionPeriod,
82
- },
83
- {
84
- when: (response) => response.resourceType === 'database',
85
- type: 'input',
86
- name: 'backupSchedule',
87
- message: 'Please provide backup schedule. Possible values are valid cron expressions like "0 2 * * *". Leave empty to add later.',
88
- validate: validBackupSchedule,
89
- },
90
- ];
91
-
92
- return this.prompt(prompts).then((props) => {
93
- this.answers = props;
94
- });
95
- }
96
-
97
- writing() {
98
- const {
99
- resourceType,
100
- instanceName,
101
- displayName,
102
- instanceAllocation,
103
- databaseName,
104
- ddl,
105
- retentionPeriod,
106
- backupSchedule,
107
- } = this.answers;
108
-
109
- ['prod', 'staging'].forEach((env) => {
110
- const spannerPath = path.join('infra', env, 'spanner');
111
- const databasesYamlPath = path.join(spannerPath, 'databases.yaml');
112
- const specPath = path.join(spannerPath, 'spec.hcl');
113
-
114
- if (!fs.existsSync(specPath)) {
115
- ['terragrunt.hcl', 'spec.hcl'].forEach((file) => {
116
- this.fs.copyTpl(
117
- this.templatePath(`spanner/${file}`),
118
- this.destinationPath(`${spannerPath}/${file}`),
119
- {
120
- ...this.answers,
121
- resourceType,
122
- env,
123
- instanceName,
124
- displayName,
125
- instanceAllocation,
126
- databaseName,
127
- ddl,
128
- retentionPeriod,
129
- backupSchedule,
130
- },
131
- );
132
- });
133
- }
134
-
135
- if (!fs.existsSync(databasesYamlPath) && resourceType === 'database') {
136
- ['terragrunt.hcl', 'databases.yaml'].forEach((file) => {
137
- this.fs.copyTpl(
138
- this.templatePath(`spanner/${file}`),
139
- this.destinationPath(`${spannerPath}/${file}`),
140
- {
141
- ...this.answers,
142
- databaseName,
143
- ddl,
144
- retentionPeriod,
145
- backupSchedule,
146
- },
147
- );
148
- });
149
- }
150
-
151
- if (fs.existsSync(databasesYamlPath) && resourceType === 'database') {
152
- const newDatabaseEntry = {
153
- name: databaseName,
154
- ddl,
155
- retentionPeriod,
156
- backupSchedule,
157
- };
158
- appendToDatabasesYaml(databasesYamlPath, newDatabaseEntry);
159
- }
160
- });
161
- }
162
-
163
- end() {
164
- this.log(`
165
- ${chalk.green('Your Cloud Spanner resources have now been created.')}
166
- ${chalk.green('Make sure to create a database for your instance. Please add any other specifications supported by the module if needed')}
167
- ${chalk.green('1.')} Push this change in a feature branch and open a pull request.`);
168
- }
169
- };
@@ -1,5 +0,0 @@
1
- databases:
2
- - name: "<%-databaseName%>" <% if (ddl == '') { %><% } else { %>
3
- ddl:
4
- - <%-ddl%> <% } %> <% if (retentionPeriod == '') { %><% } else { %>
5
- version_retention_period: "<%-retentionPeriod%>" <% } %>
@@ -1,22 +0,0 @@
1
- locals {
2
- # A unique identifier for the instance, which cannot be changed after the instance is created.
3
- # The name must be between 6 and 30 characters in length.
4
- instance_name = "<%-instanceName%>"
5
-
6
- # The name of the instance's configuration which defines the geographic placement and replication of your databases in this instance.
7
- # It determines where your data is stored.
8
- instance_config = "regional-europe-west1"
9
-
10
- # The edition decides which edition the spanner instance will have. Default is "STANDARD".
11
- # The other options are "ENTERPRISE" and "ENTERPRISE_PLUS" which enable extra capabilities and additional cost
12
- edition = "STANDARD"
13
-
14
- display_name = "<%-displayName%>"
15
- <% if (instanceAllocation == 'num_nodes') { %>
16
- # The number of nodes allocated to this instance.
17
- # At most one of either num_nodes or processing_units can be present in terraform.
18
- num_nodes = "<%-numNodes%>" <% } %><% if (instanceAllocation == 'processing_units') { %>
19
- # The number of processing units allocated to this instance.
20
- # At most one of either num_nodes or processing_units can be present in terraform.
21
- processing_units = "<%-processingUnits%>" <% } %>
22
- }