@hiiretail/gcp-infra-cli 0.92.2 → 0.92.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/common-resources/memorystore/templates/redis-instance/spec.hcl +11 -0
- package/generators/common-resources/memorystore/templates/redis-instance/terragrunt.hcl +1 -1
- package/generators/common-resources/monitoring/handle-yaml.js +0 -11
- package/generators/common-resources/monitoring/index.js +3 -40
- package/generators/common-resources/monitoring/templates/alerts/terragrunt.hcl +1 -1
- package/package.json +1 -1
- package/generators/common-resources/monitoring/templates/slos/slos.yaml +0 -41
- package/generators/common-resources/monitoring/templates/slos/terragrunt.hcl +0 -41
|
@@ -2,4 +2,15 @@ locals {
|
|
|
2
2
|
tier = "<%-tier%>"
|
|
3
3
|
connect_mode = "PRIVATE_SERVICE_ACCESS"
|
|
4
4
|
memory_size_gb = "1" # memory size in GiB
|
|
5
|
+
read_replicas_mode = "READ_REPLICAS_DISABLED"
|
|
6
|
+
transit_encryption_mode = "DISABLED"
|
|
7
|
+
maintenance_policy = {
|
|
8
|
+
day = "MONDAY"
|
|
9
|
+
start_time = {
|
|
10
|
+
hours = 0
|
|
11
|
+
minutes = 0
|
|
12
|
+
seconds = 0
|
|
13
|
+
nanos = 0
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
}
|
|
@@ -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-memorystore//?ref=
|
|
4
|
+
source = "git::https://github.com/terraform-google-modules/terraform-google-memorystore//?ref=v8.0.0"
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
# Include all settings from the root terragrunt.hcl file
|
|
@@ -21,16 +21,6 @@ const handleAlerts = (alerts, templates, answers) => {
|
|
|
21
21
|
return alerts;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const handleSlos = (slos, templates, answers) => {
|
|
25
|
-
const template = templates[`${answers.sli}`];
|
|
26
|
-
const newSLO = JSON.parse(ejs.render(JSON.stringify(template), answers));
|
|
27
|
-
|
|
28
|
-
if (answers.burnRateAlert === 'no') newSLO.alert = false;
|
|
29
|
-
|
|
30
|
-
slos.push(newSLO);
|
|
31
|
-
return slos;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
24
|
const handleUptimeChecks = (slos, templates, answers) => {
|
|
35
25
|
const newCheck = JSON.parse(ejs.render(JSON.stringify(templates), answers));
|
|
36
26
|
|
|
@@ -40,7 +30,6 @@ const handleUptimeChecks = (slos, templates, answers) => {
|
|
|
40
30
|
|
|
41
31
|
module.exports = {
|
|
42
32
|
handleAlerts,
|
|
43
|
-
handleSlos,
|
|
44
33
|
handleUptimeChecks,
|
|
45
34
|
cleanAlerts,
|
|
46
35
|
};
|
|
@@ -5,11 +5,10 @@ const yaml = require('js-yaml');
|
|
|
5
5
|
const BaseGenerator = require('../../../src/BaseGenerator');
|
|
6
6
|
const { required } = require('../../../src/validators');
|
|
7
7
|
const validate = require('./validate');
|
|
8
|
-
const {
|
|
8
|
+
const { handleAlerts, handleUptimeChecks } = require('./handle-yaml');
|
|
9
9
|
|
|
10
10
|
const uptimeCheckTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/uptime-checks/uptime-checks.yaml`));
|
|
11
11
|
const alertTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/alerts/service.yaml`));
|
|
12
|
-
const sloTemplates = yaml.load(fs.readFileSync(`${__dirname}/templates/slos/slos.yaml`));
|
|
13
12
|
|
|
14
13
|
module.exports = class extends BaseGenerator {
|
|
15
14
|
async prompting() {
|
|
@@ -21,7 +20,6 @@ module.exports = class extends BaseGenerator {
|
|
|
21
20
|
choices: [
|
|
22
21
|
// 'alerts', // Temporarily disabled due to migration to GKE Autopilot
|
|
23
22
|
'uptime-checks',
|
|
24
|
-
// 'slos' // Temporarily disabled due to migration to GKE Autopilot
|
|
25
23
|
],
|
|
26
24
|
},
|
|
27
25
|
{
|
|
@@ -31,14 +29,14 @@ module.exports = class extends BaseGenerator {
|
|
|
31
29
|
choices: Object.keys(alertTemplates),
|
|
32
30
|
},
|
|
33
31
|
{
|
|
34
|
-
when: (response) => ['
|
|
32
|
+
when: (response) => ['uptime-checks', 'alerts'].includes(response.monitoringResource),
|
|
35
33
|
type: 'input',
|
|
36
34
|
name: 'systemName',
|
|
37
35
|
message: 'Please provide three-letter system name as defined in Styra (example: sre, ptf, sda, che, pnp, iam...)',
|
|
38
36
|
validate: required && validate.systemName,
|
|
39
37
|
},
|
|
40
38
|
{
|
|
41
|
-
when: (response) => ['
|
|
39
|
+
when: (response) => ['uptime-checks', 'alerts'].includes(response.monitoringResource),
|
|
42
40
|
type: 'input',
|
|
43
41
|
name: 'serviceName',
|
|
44
42
|
message: 'Please provide the namespace where the service resides',
|
|
@@ -66,28 +64,6 @@ module.exports = class extends BaseGenerator {
|
|
|
66
64
|
default: '/health',
|
|
67
65
|
validate: required,
|
|
68
66
|
},
|
|
69
|
-
{
|
|
70
|
-
when: (response) => response.monitoringResource === 'slos',
|
|
71
|
-
type: 'list',
|
|
72
|
-
name: 'sli',
|
|
73
|
-
message: 'Please select the SLI',
|
|
74
|
-
choices: Object.keys(sloTemplates),
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
when: (response) => response.monitoringResource === 'slos' && response.sli === 'availability',
|
|
78
|
-
type: 'input',
|
|
79
|
-
name: 'uptimeCheckId',
|
|
80
|
-
message: 'Please provide the "Uptime Check ID" (NOTE: The "Uptime check" needs to have been created first in order to fetch the ID)',
|
|
81
|
-
validate: required,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
when: (response) => response.monitoringResource === 'slos',
|
|
85
|
-
type: 'list',
|
|
86
|
-
name: 'burnRateAlert',
|
|
87
|
-
message: 'Please select yes if you want to have burn-rate alerts included',
|
|
88
|
-
default: 'yes',
|
|
89
|
-
choices: ['yes', 'no'],
|
|
90
|
-
},
|
|
91
67
|
]);
|
|
92
68
|
}
|
|
93
69
|
|
|
@@ -118,19 +94,6 @@ module.exports = class extends BaseGenerator {
|
|
|
118
94
|
fs.writeFileSync(yamlPath, yaml.dump(newYaml, { lineWidth: 250, noArrayIndent: true }));
|
|
119
95
|
}
|
|
120
96
|
|
|
121
|
-
if (monitoringResource === 'slos') {
|
|
122
|
-
const service = serviceName.replace(/ /g, '-').toLowerCase();
|
|
123
|
-
const servicePath = path.join(process.cwd(), 'infra', 'prod', 'monitoring', monitoringResource, service);
|
|
124
|
-
const yamlPath = `${servicePath}/slos.yaml`;
|
|
125
|
-
|
|
126
|
-
copyTemplate('slos', servicePath, yamlPath);
|
|
127
|
-
|
|
128
|
-
const oldYaml = yaml.load(fs.readFileSync(yamlPath, 'utf8')) || [];
|
|
129
|
-
const newYaml = await handleSlos(oldYaml, sloTemplates, this.answers);
|
|
130
|
-
|
|
131
|
-
fs.writeFileSync(yamlPath, yaml.dump(newYaml, { lineWidth: 250, noArrayIndent: true }));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
97
|
if (monitoringResource === 'uptime-checks') {
|
|
135
98
|
const yamlPath = `${resourceDir}/uptime-checks.yaml`;
|
|
136
99
|
|
|
@@ -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/extenda/tf-module-gcp-alert-policy//?ref=
|
|
4
|
+
source = "git::https://github.com/extenda/tf-module-gcp-alert-policy//?ref=v2.0.0"
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
# Include all settings from the root terragrunt.hcl file
|
package/package.json
CHANGED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
availability:
|
|
2
|
-
display_name: Month - Availability
|
|
3
|
-
slo_id: month-availability
|
|
4
|
-
goal: 0.998
|
|
5
|
-
calendar_period: MONTH
|
|
6
|
-
type: windows_based_sli
|
|
7
|
-
method: boolean_filter
|
|
8
|
-
window_period: 60s
|
|
9
|
-
metric_filter: |
|
|
10
|
-
metric.type="monitoring.googleapis.com/uptime_check/check_passed"
|
|
11
|
-
resource.type="uptime_url"
|
|
12
|
-
metric.labels.check_id="<%-uptimeCheckId%>"
|
|
13
|
-
error-rate:
|
|
14
|
-
display_name: Month - Error rate
|
|
15
|
-
slo_id: month-error-rate
|
|
16
|
-
goal: 0.998
|
|
17
|
-
calendar_period: MONTH
|
|
18
|
-
type: request_based_sli
|
|
19
|
-
method: good_total_ratio
|
|
20
|
-
bad_service_filter: |
|
|
21
|
-
metric.type="knative.dev/serving/revision/request_count"
|
|
22
|
-
resource.type="knative_revision"
|
|
23
|
-
metric.labels.response_code_class="5xx"
|
|
24
|
-
resource.labels.service_name="<%-serviceName%>"
|
|
25
|
-
total_service_filter: |
|
|
26
|
-
metric.type="knative.dev/serving/revision/request_count"
|
|
27
|
-
resource.type="knative_revision"
|
|
28
|
-
resource.labels.service_name="<%-serviceName%>"
|
|
29
|
-
latency:
|
|
30
|
-
display_name: Month - Latency
|
|
31
|
-
slo_id: month-latency
|
|
32
|
-
goal: 0.95
|
|
33
|
-
calendar_period: MONTH
|
|
34
|
-
type: request_based_sli
|
|
35
|
-
method: distribution_cut
|
|
36
|
-
range_min: 0
|
|
37
|
-
range_max: 500
|
|
38
|
-
metric_filter: |
|
|
39
|
-
metric.type="knative.dev/serving/revision/request_latencies"
|
|
40
|
-
resource.type="knative_revision"
|
|
41
|
-
resource.labels.service_name="<%-serviceName%>"
|
|
@@ -1,41 +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-slo//?ref=v1.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 "notification_channels" {
|
|
13
|
-
config_path = "../../notification-channels"
|
|
14
|
-
mock_outputs = {
|
|
15
|
-
notification_channels = ["dummy-channel"]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
locals {
|
|
20
|
-
project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
|
|
21
|
-
common_vars = read_terragrunt_config(find_in_parent_folders("common.hcl"))
|
|
22
|
-
service_name = basename(get_terragrunt_dir())
|
|
23
|
-
system_name = "<%-systemName%>"
|
|
24
|
-
labels = merge(local.common_vars.locals.default_user_labels, local.project_vars.locals.default_user_labels, {
|
|
25
|
-
component = local.common_vars.locals.component
|
|
26
|
-
product = local.common_vars.locals.product
|
|
27
|
-
tenant-alias = local.common_vars.locals.tenant_alias
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above
|
|
32
|
-
inputs = {
|
|
33
|
-
project = local.project_vars.locals.project_id,
|
|
34
|
-
slos = yamldecode(file("${get_terragrunt_dir()}/slos.yaml"))
|
|
35
|
-
service_name = "${local.system_name}.${local.service_name}"
|
|
36
|
-
telemetry_resource_name = "//container.googleapis.com/projects/${local.project_vars.locals.project_id}/locations/europe-west1/clusters/k8s-cluster/k8s/namespaces/${local.service_name}"
|
|
37
|
-
notification_channel_ids = dependency.notification_channels.outputs.notification_channels,
|
|
38
|
-
fallback_notification_channels = dependency.notification_channels.outputs.fallback_channels_ids,
|
|
39
|
-
default_user_labels = local.labels,
|
|
40
|
-
documentation = "[Alerting guidelines](https://confluence.extendaretail.com/x/71fhBg)"
|
|
41
|
-
}
|