@hiiretail/gcp-infra-cli 0.99.11 → 0.99.13

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.
@@ -84,6 +84,20 @@ module.exports = class extends BaseGenerator {
84
84
  message: 'Relevant only for versioned objects. The number of newer versions of an object to satisfy the condition. Use null to not set the value',
85
85
  validate: required,
86
86
  },
87
+ {
88
+ type: 'list',
89
+ name: 'retentionPolicy',
90
+ message: 'Do you want to set up a retention period for the bucket?',
91
+ default: 'false',
92
+ choices: ['true', 'false'],
93
+ },
94
+ {
95
+ when: (response) => response.retentionPolicy === 'true',
96
+ type: 'input',
97
+ name: 'retentionPeriod',
98
+ message: 'The period of time, in seconds, that objects in the bucket must be retained and cannot be deleted, overwritten, or archived. The value must be less than 2147483647 seconds',
99
+ validate: required,
100
+ },
87
101
  ];
88
102
 
89
103
  return this.prompt(prompts).then((props) => {
@@ -96,6 +110,7 @@ module.exports = class extends BaseGenerator {
96
110
  bucketName,
97
111
  prefix,
98
112
  lifecycleRules,
113
+ retentionPolicy,
99
114
  versioning,
100
115
  action,
101
116
  storageClass,
@@ -104,6 +119,7 @@ module.exports = class extends BaseGenerator {
104
119
  withState,
105
120
  matchesStorageClass,
106
121
  numNewerVersions,
122
+ retentionPeriod,
107
123
  } = this.answers;
108
124
 
109
125
  ['prod', 'staging'].forEach((env) => {
@@ -116,6 +132,7 @@ module.exports = class extends BaseGenerator {
116
132
  bucketName,
117
133
  prefix,
118
134
  lifecycleRules,
135
+ retentionPolicy,
119
136
  versioning,
120
137
  action,
121
138
  storageClass,
@@ -124,6 +141,7 @@ module.exports = class extends BaseGenerator {
124
141
  withState,
125
142
  matchesStorageClass,
126
143
  numNewerVersions,
144
+ retentionPeriod,
127
145
  },
128
146
  );
129
147
  });
@@ -20,4 +20,7 @@ lifecycle_rules:
20
20
  with_state: null <% } %> <% if (matchesStorageClass != 'null') { %>
21
21
  matches_storage_class: "<%-matchesStorageClass%>" <% } else { %>
22
22
  matches_storage_class: null <% } %>
23
- num_newer_versions: <%-numNewerVersions%> <% } %>
23
+ num_newer_versions: <%-numNewerVersions%> <% } %> <% if (retentionPolicy == 'true') { %>
24
+ retention_policy:
25
+ "<%-bucketName%><% if (env == 'staging') { %>-staging<% } %>":
26
+ retention_period: <%-retentionPeriod%> <% } %>
@@ -14,6 +14,7 @@ const appendToDatabasesYaml = (databasesYamlPath, newDbEntry) => {
14
14
  name: newDbEntry.name,
15
15
  ...(newDbEntry.ddl ? { ddl: [newDbEntry.ddl] } : {}),
16
16
  ...(newDbEntry.retentionPeriod ? { version_retention_period: newDbEntry.retentionPeriod } : {}),
17
+ ...(newDbEntry.backupSchedule ? { backup_schedule: newDbEntry.backupSchedule } : {}),
17
18
  };
18
19
 
19
20
  databases.push(cleanNewDatabaseEntry);
@@ -3,7 +3,7 @@ const chalk = require('chalk');
3
3
  const fs = require('fs');
4
4
  const BaseGenerator = require('../../../src/BaseGenerator');
5
5
  const { required } = require('../../../src/validators');
6
- const { validName, validRetentionPeriod } = require('./validate');
6
+ const { validName, validRetentionPeriod, validBackupSchedule } = require('./validate');
7
7
  const appendToDatabasesYaml = require('./append');
8
8
 
9
9
  module.exports = class extends BaseGenerator {
@@ -80,6 +80,13 @@ module.exports = class extends BaseGenerator {
80
80
  message: 'Please provide version retention period. Maximum value 7d, possible values include 84000s, 1h, 2d. Leave empty for default value 1h.',
81
81
  validate: validRetentionPeriod,
82
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
+ },
83
90
  ];
84
91
 
85
92
  return this.prompt(prompts).then((props) => {
@@ -96,6 +103,7 @@ module.exports = class extends BaseGenerator {
96
103
  databaseName,
97
104
  ddl,
98
105
  retentionPeriod,
106
+ backupSchedule,
99
107
  } = this.answers;
100
108
 
101
109
  ['prod', 'staging'].forEach((env) => {
@@ -118,6 +126,7 @@ module.exports = class extends BaseGenerator {
118
126
  databaseName,
119
127
  ddl,
120
128
  retentionPeriod,
129
+ backupSchedule,
121
130
  },
122
131
  );
123
132
  });
@@ -133,6 +142,7 @@ module.exports = class extends BaseGenerator {
133
142
  databaseName,
134
143
  ddl,
135
144
  retentionPeriod,
145
+ backupSchedule,
136
146
  },
137
147
  );
138
148
  });
@@ -143,6 +153,7 @@ module.exports = class extends BaseGenerator {
143
153
  name: databaseName,
144
154
  ddl,
145
155
  retentionPeriod,
156
+ backupSchedule,
146
157
  };
147
158
  appendToDatabasesYaml(databasesYamlPath, newDatabaseEntry);
148
159
  }
@@ -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-spanner//?ref=v0.1.5"
4
+ source = "git::https://github.com/extenda/tf-module-gcp-spanner//?ref=v1.0.0"
5
5
  }
6
6
 
7
7
  # Include all settings from the root terragrunt.hcl file
@@ -18,7 +18,21 @@ const validRetentionPeriod = (input) => {
18
18
  return 'Invalid retention period format. Possible values are 84000s, 1h, 2d, or leave empty for default value 1h';
19
19
  };
20
20
 
21
+ const validBackupSchedule = (input) => {
22
+ const validFormats = /^(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5}$/;
23
+
24
+ if (input === '') {
25
+ return true;
26
+ }
27
+ if (validFormats.test(input)) {
28
+ return true;
29
+ }
30
+
31
+ return 'Invalid backup schedule format. Possible values are cron expressions like "0 2 * * *"';
32
+ };
33
+
21
34
  module.exports = {
22
35
  validName,
23
36
  validRetentionPeriod,
37
+ validBackupSchedule,
24
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiiretail/gcp-infra-cli",
3
- "version": "0.99.11",
3
+ "version": "0.99.13",
4
4
  "description": "Infrastructure as code generator for GCP.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {