@hiiretail/gcp-infra-cli 0.66.2 → 0.67.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.
@@ -25,6 +25,65 @@ module.exports = class extends BaseGenerator {
25
25
  message: 'Please provide the prefix for the bucket name',
26
26
  validate: required,
27
27
  },
28
+ {
29
+ type: 'list',
30
+ name: 'lifecycleRules',
31
+ message: 'Do you want to set up lifecycle rules for the bucket?',
32
+ default: 'false',
33
+ choices: ['true', 'false'],
34
+ },
35
+ {
36
+ when: (response) => response.lifecycleRules === 'true',
37
+ type: 'list',
38
+ name: 'action',
39
+ message: 'Select the action of this Lifecycle Rule',
40
+ default: 'Delete',
41
+ choices: ['Delete', 'SetStorageClass'],
42
+ },
43
+ {
44
+ when: (response) => response.lifecycleRules === 'true' && response.action === 'SetStorageClass',
45
+ type: 'list',
46
+ name: 'storageClass',
47
+ message: 'Select the Storage Class for objects in the bucket',
48
+ default: 'STANDARD',
49
+ choices: ['STANDARD', 'MULTI_REGIONAL', 'REGIONAL', 'NEARLINE', 'COLDLINE', 'ARCHIVE'],
50
+ },
51
+ {
52
+ when: (response) => response.lifecycleRules === 'true',
53
+ type: 'input',
54
+ name: 'age',
55
+ message: 'Minimum age of an object in days to satisfy the condition. Use null to not set the value',
56
+ validate: required,
57
+ },
58
+ {
59
+ when: (response) => response.lifecycleRules === 'true',
60
+ type: 'input',
61
+ name: 'createdBefore',
62
+ message: 'A date in format YYYY-MM-DD. This condition is satisfied when an object is created before midnight of the specified date in UTC. Use null to not set the value',
63
+ validate: required,
64
+ },
65
+ {
66
+ when: (response) => response.lifecycleRules === 'true',
67
+ type: 'list',
68
+ name: 'withState',
69
+ message: 'Match to live and/or archived objects. Unversioned buckets have only live objects. Use null to not set the value',
70
+ default: 'LIVE',
71
+ choices: ['LIVE', 'ARCHIVED', 'ANY', 'null'],
72
+ },
73
+ {
74
+ when: (response) => response.lifecycleRules === 'true',
75
+ type: 'input',
76
+ name: 'matchesStorageClass',
77
+ message: 'Specify comma delimited string of Storage Class of objects to satisfy the condition. Supported values: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY. Use null to not set the value',
78
+ validate: required,
79
+ },
80
+ {
81
+ when: (response) => response.lifecycleRules === 'true',
82
+ type: 'input',
83
+ name: 'numNewerVersions',
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
+ validate: required,
86
+ },
28
87
  ];
29
88
 
30
89
  return this.prompt(prompts).then((props) => {
@@ -36,6 +95,15 @@ module.exports = class extends BaseGenerator {
36
95
  const {
37
96
  bucketName,
38
97
  prefix,
98
+ lifecycleRules,
99
+ versioning,
100
+ action,
101
+ storageClass,
102
+ age,
103
+ createdBefore,
104
+ withState,
105
+ matchesStorageClass,
106
+ numNewerVersions,
39
107
  } = this.answers;
40
108
 
41
109
  ['prod', 'staging'].forEach((env) => {
@@ -47,6 +115,15 @@ module.exports = class extends BaseGenerator {
47
115
  env,
48
116
  bucketName,
49
117
  prefix,
118
+ lifecycleRules,
119
+ versioning,
120
+ action,
121
+ storageClass,
122
+ age,
123
+ createdBefore,
124
+ withState,
125
+ matchesStorageClass,
126
+ numNewerVersions,
50
127
  },
51
128
  );
52
129
  });
@@ -25,4 +25,25 @@ locals {
25
25
  "<%-bucketName%>" = <%-versioning%>
26
26
  }
27
27
  set_viewer_roles = true
28
+
29
+ <% if (lifecycleRules == 'true') { %>
30
+ lifecycle_rules = [
31
+ {
32
+ action = {
33
+ type = "<%-action%>" <% if (action == 'SetStorageClass') { %>
34
+ storage_class = "<%-storageClass%>" <% } else { %>
35
+ storage_class = null <% } %>
36
+ }
37
+ condition = {
38
+ age = <%-age%> <% if (createdBefore != 'null') { %>
39
+ created_before = "<%-createdBefore%>" <% } else { %>
40
+ created_before = null <% } %> <% if (withState != 'null') { %>
41
+ with_state = "<%-withState%>" <% } else { %>
42
+ with_state = null <% } %> <% if (matchesStorageClass != 'null') { %>
43
+ matches_storage_class = "<%-matchesStorageClass%>" <% } else { %>
44
+ matches_storage_class = null <% } %>
45
+ num_newer_versions = <%-numNewerVersions%>
46
+ }
47
+ } <% } %>
48
+ ]
28
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiiretail/gcp-infra-cli",
3
- "version": "0.66.2",
3
+ "version": "0.67.0",
4
4
  "description": "Infrastructure as code generator for GCP.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {