@hiiretail/gcp-infra-cli 0.95.0 → 0.95.2
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/budget/index.js +54 -0
- package/generators/common-resources/budget/templates/budget/terragrunt.hcl +6 -1
- package/generators/common-resources/cloudsql/templates/postgres/instance/spec.hcl +5 -0
- package/generators/common-resources/cloudsql/templates/postgres/instance/terragrunt.hcl +1 -3
- package/generators/common-resources/cloudsql/templates/postgres/instance-secrets/terragrunt.hcl +8 -4
- package/package.json +1 -1
|
@@ -10,6 +10,25 @@ module.exports = class extends BaseGenerator {
|
|
|
10
10
|
name: 'monitoringNotificationChannels',
|
|
11
11
|
message: 'Enter a comma-separated list of monitoring notification channels (format: projects/{project_id}/notificationChannels/{channel_id}). At least one email address must be included. Up to 5 channels are permitted.',
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
type: 'list',
|
|
15
|
+
name: 'usingGKE',
|
|
16
|
+
message: 'Is the clan using GKE?',
|
|
17
|
+
default: 'false',
|
|
18
|
+
choices: ['true', 'false'],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: 'input',
|
|
22
|
+
name: 'expectedServiceCount',
|
|
23
|
+
message: 'How many services will eventually be in use simultanously?',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'list',
|
|
27
|
+
name: 'usingInternalTraffic',
|
|
28
|
+
message: 'Is the clan using internal traffic (service to service communication)?',
|
|
29
|
+
default: 'true',
|
|
30
|
+
choices: ['true', 'false'],
|
|
31
|
+
},
|
|
13
32
|
];
|
|
14
33
|
return this.prompt(prompts).then((props) => {
|
|
15
34
|
this.answers = props;
|
|
@@ -18,6 +37,40 @@ module.exports = class extends BaseGenerator {
|
|
|
18
37
|
|
|
19
38
|
writing() {
|
|
20
39
|
const channelsArray = this.answers.monitoringNotificationChannels ? this.answers.monitoringNotificationChannels.split(',').map((channel) => channel.trim()) : [];
|
|
40
|
+
let overheadPercentage = 0.01;
|
|
41
|
+
if (this.answers.usingInternalTraffic === 'false'
|
|
42
|
+
&& this.answers.usingGKE === 'false'
|
|
43
|
+
&& this.answers.expectedServiceCount < 8) {
|
|
44
|
+
overheadPercentage = 0.01;
|
|
45
|
+
} else if (this.answers.usingInternalTraffic === 'true'
|
|
46
|
+
&& this.answers.usingGKE === 'false'
|
|
47
|
+
&& this.answers.expectedServiceCount < 8) {
|
|
48
|
+
overheadPercentage = 0.03;
|
|
49
|
+
} else if (this.answers.usingInternalTraffic === 'true'
|
|
50
|
+
&& this.answers.usingGKE === 'false'
|
|
51
|
+
&& this.answers.expectedServiceCount > 8) {
|
|
52
|
+
overheadPercentage = 0.04;
|
|
53
|
+
} else if (this.answers.usingInternalTraffic === 'true'
|
|
54
|
+
&& this.answers.usingGKE === 'true'
|
|
55
|
+
&& this.answers.expectedServiceCount < 8) {
|
|
56
|
+
overheadPercentage = 0.04;
|
|
57
|
+
} else if (this.answers.usingInternalTraffic === 'true'
|
|
58
|
+
&& this.answers.usingGKE === 'true'
|
|
59
|
+
&& this.answers.expectedServiceCount > 8) {
|
|
60
|
+
overheadPercentage = 0.05;
|
|
61
|
+
} else if (this.answers.usingInternalTraffic === 'false'
|
|
62
|
+
&& this.answers.usingGKE === 'false'
|
|
63
|
+
&& this.answers.expectedServiceCount > 8) {
|
|
64
|
+
overheadPercentage = 0.03;
|
|
65
|
+
} else if (this.answers.usingInternalTraffic === 'false'
|
|
66
|
+
&& this.answers.usingGKE === 'true'
|
|
67
|
+
&& this.answers.expectedServiceCount < 8) {
|
|
68
|
+
overheadPercentage = 0.03;
|
|
69
|
+
} else if (this.answers.usingInternalTraffic === 'false'
|
|
70
|
+
&& this.answers.usingGKE === 'true'
|
|
71
|
+
&& this.answers.expectedServiceCount > 8) {
|
|
72
|
+
overheadPercentage = 0.04;
|
|
73
|
+
}
|
|
21
74
|
|
|
22
75
|
['prod', 'staging'].forEach((env) => {
|
|
23
76
|
this.copyDir(
|
|
@@ -27,6 +80,7 @@ module.exports = class extends BaseGenerator {
|
|
|
27
80
|
...this.answers,
|
|
28
81
|
env,
|
|
29
82
|
monitoringNotificationChannels: channelsArray,
|
|
83
|
+
overheadPercentage,
|
|
30
84
|
},
|
|
31
85
|
);
|
|
32
86
|
});
|
|
@@ -15,12 +15,17 @@ locals {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above
|
|
18
|
+
# The amount has a percentage added if one or more of the following is true:
|
|
19
|
+
# - Clan makes use of GKE
|
|
20
|
+
# - Clan makes use of more than 10 services
|
|
21
|
+
# - Clan makes use of service to service communication (internal traffic)
|
|
22
|
+
# where combinations make steps of 3%, 4% or 5% or 1% if none applies
|
|
18
23
|
inputs = merge(
|
|
19
24
|
{
|
|
20
25
|
projects = [local.project_vars.locals.project_id]
|
|
21
26
|
display_name = "${local.project_vars.locals.project_name}-budget"
|
|
22
27
|
billing_account = "01580F-3DD16A-C066A5"
|
|
23
|
-
amount = local.project_vars.locals.amount
|
|
28
|
+
amount = (local.project_vars.locals.amount + (local.project_vars.locals.amount * <%- overheadPercentage %>))
|
|
24
29
|
monitoring_notification_channels = <%-JSON.stringify(monitoringNotificationChannels)%>
|
|
25
30
|
disable_default_iam_recipients = true
|
|
26
31
|
alert_spent_percents = [0.8, 1.0, 1.2]
|
|
@@ -36,6 +36,11 @@ locals {
|
|
|
36
36
|
#Default: "ZONAL"
|
|
37
37
|
# availability_type = "REGIONAL"
|
|
38
38
|
|
|
39
|
+
#Description: Enables protection of an Cloud SQL instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform).
|
|
40
|
+
#Type: bool
|
|
41
|
+
#Default: false
|
|
42
|
+
deletion_protection_enabled = true
|
|
43
|
+
|
|
39
44
|
#Description: The backup_configuration settings subblock for the database setings
|
|
40
45
|
#Type: object({ binary_log_enabled = bool enabled = bool start_time = string })
|
|
41
46
|
#Default: { "binary_log_enabled": null, "enabled": false, "start_time": null }
|
|
@@ -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-sql-db//modules/postgresql?ref=
|
|
4
|
+
source = "git::https://github.com/terraform-google-modules/terraform-google-sql-db//modules/postgresql?ref=v20.1.0"
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
# Include all settings from the root terragrunt.hcl file
|
|
@@ -31,8 +31,6 @@ inputs = merge(
|
|
|
31
31
|
"private_network" : "https://www.googleapis.com/compute/v1/projects/${local.project_vars.locals.project_id}/global/networks/${local.project_vars.locals.clan_network}",
|
|
32
32
|
"require_ssl" : false
|
|
33
33
|
}
|
|
34
|
-
## Uncomment and apply it before destroy in case of necessary to delete the instance
|
|
35
|
-
# deletion_protection = false
|
|
36
34
|
user_labels = local.labels,
|
|
37
35
|
}
|
|
38
36
|
)
|
package/generators/common-resources/cloudsql/templates/postgres/instance-secrets/terragrunt.hcl
CHANGED
|
@@ -22,8 +22,10 @@ locals {
|
|
|
22
22
|
dependency "instance" {
|
|
23
23
|
config_path = "../instance"
|
|
24
24
|
mock_outputs = {
|
|
25
|
-
|
|
26
|
-
generated_user_password
|
|
25
|
+
instance_connection_name = "dummy-connection-name"
|
|
26
|
+
generated_user_password = "dummy-password"
|
|
27
|
+
public_ip_address = "dummy-ip"
|
|
28
|
+
private_ip_address = "dummy-ip"
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -32,8 +34,10 @@ inputs = merge(
|
|
|
32
34
|
{
|
|
33
35
|
project_id = local.project_vars.locals.project_id
|
|
34
36
|
secrets = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
postgresql_instance_connection_name = dependency.instance.outputs.instance_connection_name
|
|
38
|
+
postgresql_master_password = dependency.instance.outputs.generated_user_password
|
|
39
|
+
postgresql_public_address = dependency.instance.outputs.public_ip_address
|
|
40
|
+
postgresql_address = dependency.instance.outputs.private_ip_address
|
|
37
41
|
}
|
|
38
42
|
labels = local.labels,
|
|
39
43
|
}
|