@hiiretail/gcp-infra-cli 0.79.0 → 0.80.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.
@@ -1,8 +1,8 @@
1
1
  const validate = {};
2
2
 
3
3
  validate.jiraProjectKey = (input) => {
4
- if (!/\s/.test(input) && input === input.toUpperCase()) return true;
5
- return 'Must be uppercase and not contain any whitepace';
4
+ if (!/\s/.test(input) && input === input.toLowerCase()) return true;
5
+ return 'Must be lowercase and not contain any whitepace';
6
6
  };
7
7
 
8
8
  module.exports = validate;
@@ -7,10 +7,12 @@ const { required } = require('../../../src/validators');
7
7
  const validate = require('./validate');
8
8
  const { handleSlos, handleAlerts, handleUptimeChecks } = require('./handle-yaml');
9
9
  const { getProjectId } = require('../pubsub/get-gcp-projects');
10
+ const getTribeAndClanName = require('../../init/clan-infra/tribe-clan-repo');
10
11
 
11
12
  const uptimeCheckTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/uptime-checks/uptime-checks.yaml`));
12
13
  const alertTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/alerts/alerts.yaml`));
13
14
  const sloTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/slos/slos.yaml`));
15
+ const { clan: defaultClan } = getTribeAndClanName();
14
16
  const projectId = getProjectId('prod');
15
17
 
16
18
  module.exports = class extends BaseGenerator {
@@ -35,7 +37,7 @@ module.exports = class extends BaseGenerator {
35
37
  choices: (answers) => Object.keys(alertTemplates[`${answers.alertResource}`]),
36
38
  },
37
39
  {
38
- when: (response) => ['alerts', 'slos', 'uptime-checks'].includes(response.monitoringResource),
40
+ when: (response) => ['slos', 'uptime-checks'].includes(response.monitoringResource) || response.alertResource === 'cloud_run',
39
41
  type: 'input',
40
42
  name: 'systemName',
41
43
  message: 'Please provide three-letter system name as defined in Styra (example: sre, ptf, sda, che, pnp, iam...)',
@@ -146,8 +148,10 @@ module.exports = class extends BaseGenerator {
146
148
  const yamlPath = `${resourceDir}/alerts.yaml`;
147
149
 
148
150
  copyTemplate('alerts', resourceDir, yamlPath);
151
+
149
152
  const oldYaml = yaml.load(fs.readFileSync(yamlPath, 'utf8')) || [];
150
- const newYaml = await handleAlerts(oldYaml, alertTemplates, this.answers);
153
+ const newYaml = await handleAlerts(oldYaml, alertTemplates,
154
+ { ...this.answers, clan: defaultClan });
151
155
 
152
156
  fs.writeFileSync(yamlPath, yaml.dump(newYaml));
153
157
  }
@@ -18,7 +18,7 @@ cloud_run:
18
18
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
19
19
  cloud_scheduler:
20
20
  failed_job:
21
- display_name: "[P4] <%-systemName%> - Cloud Scheduler | Job Failed"
21
+ display_name: "[P4] <%-clan%> - Cloud Scheduler | Job Failed"
22
22
  conditions:
23
23
  - display_name: Cloud Scheduler Job - Log entries with SEVERITY=Error exceed threshold
24
24
  condition_threshold:
@@ -36,7 +36,7 @@ cloud_scheduler:
36
36
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
37
37
  cloud_sql:
38
38
  cpu_over_65:
39
- display_name: "[P3] <%-systemName%> - CloudSQL | CPU over 65%"
39
+ display_name: "[P3] <%-clan%> - CloudSQL | CPU over 65%"
40
40
  conditions:
41
41
  - display_name: Cloud SQL Database - CPU utilization above 65% over 5 min
42
42
  condition_threshold:
@@ -53,7 +53,7 @@ cloud_sql:
53
53
  documentation:
54
54
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
55
55
  cpu_over_85:
56
- display_name: "[P3] <%-systemName%> - CloudSQL | CPU over 85%"
56
+ display_name: "[P3] <%-clan%> - CloudSQL | CPU over 85%"
57
57
  conditions:
58
58
  - display_name: "Cloud SQL Database - CPU-usage above 85% over 1 min"
59
59
  condition_threshold:
@@ -70,7 +70,7 @@ cloud_sql:
70
70
  documentation:
71
71
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
72
72
  cpu_over_90:
73
- display_name: "[P3] <%-systemName%> - CloudSQL | CPU over 90%"
73
+ display_name: "[P3] <%-clan%> - CloudSQL | CPU over 90%"
74
74
  conditions:
75
75
  - display_name: Cloud SQL Database - CPU-usage above 90%
76
76
  condition_threshold:
@@ -86,7 +86,7 @@ cloud_sql:
86
86
  documentation:
87
87
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
88
88
  query_over_1s:
89
- display_name: "[P4] <%-systemName%> - CloudSQL | Query resolve time"
89
+ display_name: "[P4] <%-clan%> - CloudSQL | Query resolve time"
90
90
  conditions:
91
91
  - display_name: Cloud SQL Instance Database - Per query execution times above 1000 ms
92
92
  condition_threshold:
@@ -103,7 +103,7 @@ cloud_sql:
103
103
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
104
104
  memorystore:
105
105
  memory_over_50:
106
- display_name: "[P4] <%-systemName%> - Memorystore | Memory over 50%"
106
+ display_name: "[P4] <%-clan%> - Memorystore | Memory over 50%"
107
107
  conditions:
108
108
  - display_name: Memorystore Redis Instance - Memory Usage above 50% over 5 min
109
109
  condition_threshold:
@@ -120,7 +120,7 @@ memorystore:
120
120
  documentation:
121
121
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
122
122
  memory_over_75:
123
- display_name: "[P4] <%-systemName%> - Memorystore | Memory over 75%"
123
+ display_name: "[P4] <%-clan%> - Memorystore | Memory over 75%"
124
124
  conditions:
125
125
  - display_name: Memorystore Redis Instance - Memory Usage above 75% for 5min
126
126
  condition_threshold:
@@ -137,7 +137,7 @@ memorystore:
137
137
  documentation:
138
138
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
139
139
  memory_over_90:
140
- display_name: "[P2] <%-systemName%> - Memorystore | Memory over 90%"
140
+ display_name: "[P2] <%-clan%> - Memorystore | Memory over 90%"
141
141
  conditions:
142
142
  - display_name: Memorystore Redis Instance - Memory Usage above 90%
143
143
  condition_threshold:
@@ -155,7 +155,7 @@ memorystore:
155
155
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
156
156
  pub_sub:
157
157
  unacknowledged_messages:
158
- display_name: "[P3] <%-systemName%> - Pub/Sub | Undelivered message(s)"
158
+ display_name: "[P3] <%-clan%> - Pub/Sub | Undelivered message(s)"
159
159
  conditions:
160
160
  - display_name: Cloud Pub/Sub Subscription - Undelivered messages above 1 for 5 min
161
161
  condition_threshold:
@@ -172,7 +172,7 @@ pub_sub:
172
172
  documentation:
173
173
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
174
174
  messages_in_dlq:
175
- display_name: "[P3] <%-systemName%> - Pub/Sub | Message(s) in DLQ"
175
+ display_name: "[P3] <%-clan%> - Pub/Sub | Message(s) in DLQ"
176
176
  conditions:
177
177
  - display_name: Cloud Pub/Sub Subscription - Number of undelivered message(s) forwarded to DLQ
178
178
  condition_threshold:
@@ -189,7 +189,7 @@ pub_sub:
189
189
  documentation:
190
190
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
191
191
  latency:
192
- display_name: "[P3] <%-systemName%> - Pub/Sub | Response latency distribution"
192
+ display_name: "[P3] <%-clan%> - Pub/Sub | Response latency distribution"
193
193
  conditions:
194
194
  - display_name: Cloud Pub/Sub Subscription - Latency above 3s
195
195
  condition_threshold:
@@ -208,7 +208,7 @@ pub_sub:
208
208
  content: <% if (runbookLink) { %>[Runbook](<%-runbookLink%>)<%} else { %> <% } %>
209
209
  cloud_function:
210
210
  failed_execution:
211
- display_name: "[P2] <%-systemName%> - Cloud Function | Failed job execution"
211
+ display_name: "[P2] <%-clan%> - Cloud Function | Failed job execution"
212
212
  conditions:
213
213
  - display_name: Cloud Function - Execution error count
214
214
  condition_threshold:
@@ -18,6 +18,7 @@ dependency "notification_channels" {
18
18
 
19
19
  locals {
20
20
  project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
21
+ common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
21
22
  }
22
23
 
23
24
  # These are the variables we have to pass in to use the module specified in the terragrunt configuration above
@@ -29,5 +30,11 @@ inputs = merge(
29
30
  notification_channels = dependency.notification_channels.outputs.notification_channels,
30
31
  telemetry_resource_name = "//container.googleapis.com/projects/${lookup(local.project_vars.locals, "monitoring_project_id", local.project_vars.locals.tribe_project_id)}/locations/europe-west1/clusters/k8s-cluster/k8s/namespaces/<%-serviceName%>"
31
32
  slos = yamldecode(file("${get_terragrunt_dir()}/slos.yaml")),
33
+ documentation = "[Alerting guidelines](https://confluence.extendaretail.com/x/71fhBg)"
34
+ user_labels = {
35
+ cc = local.common_vars.locals.cost_center
36
+ clan = local.common_vars.locals.clan_name
37
+ jira_project_key = lookup(local.common_vars.locals, "jira_project_key", null)
38
+ },
32
39
  }
33
40
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiiretail/gcp-infra-cli",
3
- "version": "0.79.0",
3
+ "version": "0.80.1",
4
4
  "description": "Infrastructure as code generator for GCP.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {