Skip to content

Commit 8607b76

Browse files
Merge pull request #17 from ganesh-arkalgud/main
Adding support for providing sensitive file contents for upload
2 parents 4a51eee + 5a32fa0 commit 8607b76

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
## Unreleased
2+
Upgrade notes:
3+
* node_files argument added: Due to possible terraform `sensitive` issues, the files that are to be uploaded to a node will need to be specified separately.
4+
For existing code change as follows:
5+
```terraform
6+
nodes = [{
7+
node_ip = "172.31.140.18"
8+
node_id = "00"
9+
node_subnet_id = data.aws_subnet.subnet1.id
10+
node_files_toupload = []
11+
}]
12+
```
13+
To new code
14+
```terraform
15+
nodes = [{
16+
node_ip = "172.31.140.18"
17+
node_id = "00"
18+
node_subnet_id = data.aws_subnet.subnet1.id
19+
}]
20+
node_files = [{
21+
node_id = "00"
22+
node_files_toupload = []
23+
}]
24+
```
25+
Note, the node_id can be any string but if you want to retain the node names use the 2 digit node_id (eg. 00, 01, 05, 10 etc) during the upgrades.
26+
27+
Breaking Changes:
28+
* added node_files argument by @ganesh-arkalgud in [#17](https://github.com/prashantkalkar/stateful_application_module/pull/17)
229
330
## v0.4.0
431

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,29 @@ module "cluster" {
2424
node_ip = "<InstanceIPToBeAllocated>"
2525
node_id = "<NodeId>" # should be unique
2626
node_subnet_id = "<subnet_id>"
27-
node_files_toupload = [filebase64("${path.module}/config_file.cfg")]
2827
},
2928
{
3029
node_ip = "<InstanceIPToBeAllocated>"
3130
node_id = "<NodeId>"
3231
node_subnet_id = "<subnet_id>"
33-
node_files_toupload = [filebase64("${path.module}/config_file.cfg")]
3432
},
3533
{
3634
node_ip = "<InstanceIPToBeAllocated>"
3735
node_id = "<NodeId>"
3836
node_subnet_id = "<subnet_id>"
37+
}
38+
]
39+
node_files = [
40+
{
41+
node_id = "<NodeId>" # should be unique
42+
node_files_toupload = [filebase64("${path.module}/config_file.cfg")]
43+
},
44+
{
45+
node_id = "<NodeId>"
46+
node_files_toupload = [filebase64("${path.module}/config_file.cfg")]
47+
},
48+
{
49+
node_id = "<NodeId>"
3950
node_files_toupload = [filebase64("${path.module}/config_file.cfg")]
4051
}
4152
]
@@ -183,9 +194,10 @@ https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ubuntu-secondary-netw
183194
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | n/a | `string` | n/a | yes |
184195
| <a name="input_jq_download_url"></a> [jq\_download\_url](#input\_jq\_download\_url) | n/a | `string` | `"https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64"` | no |
185196
| <a name="input_node_config_script"></a> [node\_config\_script](#input\_node\_config\_script) | Base64 encoded node configuration shell script.<br> Must include configure\_cluster\_node and wait\_for\_healthy\_cluster function. Check documentation for more details about the contract | `string` | n/a | yes |
197+
| <a name="input_node_files"></a> [node\_files](#input\_node\_files) | node\_id = node identifier (this is not a index and need not in any specific ordered).<br> node\_files\_toupload = list of file to be uploaded per node. These can be cluster config files etc.<br> node\_files\_toupload.contents = Base64 encoded contents of the file to be uploaded on the node.<br> node\_files\_toupload.destination = File destination on the node. This will be the file path and name on the node. The file ownership should be changed by node\_config\_script. | <pre>set(object({<br> node_id = string<br> node_files_toupload = optional(list(object({<br> contents = string<br> destination = string<br> })), [])<br> }))</pre> | n/a | yes |
186198
| <a name="input_node_image"></a> [node\_image](#input\_node\_image) | n/a | `string` | n/a | yes |
187199
| <a name="input_node_key_name"></a> [node\_key\_name](#input\_node\_key\_name) | n/a | `string` | n/a | yes |
188-
| <a name="input_nodes"></a> [nodes](#input\_nodes) | node\_id = node identifier (this is not a index and need not in any specific ordered).<br> node\_ip = IP address of the cluster node. This should be available within the subnet.<br> node\_image = image for node of the cluster node.<br> node\_subnet\_id = Id of the subnet where node should be created.<br> node\_files\_toupload = list of file to be uploaded per node. These can be cluster confi files etc.<br> node\_files\_toupload.contents = Base64 encoded contents of the file to be uploaded on the node.<br> node\_files\_toupload.destination = File destination on the node. This will be the file path and name on the node. The file ownership should be changed by node\_config\_script. | <pre>set(object({<br> node_id = string<br> node_ip = string<br> node_image = optional(string)<br> node_subnet_id = string<br> node_files_toupload = optional(list(object({<br> contents = string<br> destination = string<br> })), [])<br> }))</pre> | n/a | yes |
200+
| <a name="input_nodes"></a> [nodes](#input\_nodes) | node\_id = node identifier (this is not a index and need not in any specific ordered).<br> node\_ip = IP address of the cluster node. This should be available within the subnet.<br> node\_image = image for node of the cluster node.<br> node\_subnet\_id = Id of the subnet where node should be created. | <pre>set(object({<br> node_id = string<br> node_ip = string<br> node_image = optional(string)<br> node_subnet_id = string<br> }))</pre> | n/a | yes |
189201
| <a name="input_root_volume"></a> [root\_volume](#input\_root\_volume) | n/a | <pre>object({<br> device_name = string<br> size_in_gibs = number<br> type = string<br> })</pre> | <pre>{<br> "device_name": "/dev/xvda",<br> "size_in_gibs": 16,<br> "type": "gp3"<br>}</pre> | no |
190202
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | n/a | `list(string)` | n/a | yes |
191203

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
locals {
22
node_id_to_node_map = {for node in var.nodes : node.node_id => node}
3+
node_id_to_node_files_map = {for node in var.node_files : node.node_id => node}
34
}
45

56
module "cluster_nodes" {
@@ -12,7 +13,7 @@ module "cluster_nodes" {
1213
node_ip = each.value.node_ip
1314
node_key_name = var.node_key_name
1415
node_subnet_id = each.value.node_subnet_id
15-
node_files_toupload = each.value.node_files_toupload
16+
node_files_toupload = lookup(local.node_id_to_node_files_map, each.key).node_files_toupload
1617
node_config_script = var.node_config_script
1718
security_groups = var.security_groups
1819
node_image = each.value.node_image != null ? each.value.node_image : var.node_image

variables.tf

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@ variable "nodes" {
44
node_ip = string
55
node_image = optional(string)
66
node_subnet_id = string
7+
}))
8+
description = <<EOT
9+
node_id = node identifier (this is not a index and need not in any specific ordered).
10+
node_ip = IP address of the cluster node. This should be available within the subnet.
11+
node_image = image for node of the cluster node.
12+
node_subnet_id = Id of the subnet where node should be created.
13+
EOT
14+
}
15+
16+
variable "node_files" {
17+
type = set(object({
18+
node_id = string
719
node_files_toupload = optional(list(object({
820
contents = string
921
destination = string
1022
})), [])
1123
}))
1224
description = <<EOT
1325
node_id = node identifier (this is not a index and need not in any specific ordered).
14-
node_ip = IP address of the cluster node. This should be available within the subnet.
15-
node_image = image for node of the cluster node.
16-
node_subnet_id = Id of the subnet where node should be created.
17-
node_files_toupload = list of file to be uploaded per node. These can be cluster confi files etc.
26+
node_files_toupload = list of file to be uploaded per node. These can be cluster config files etc.
1827
node_files_toupload.contents = Base64 encoded contents of the file to be uploaded on the node.
1928
node_files_toupload.destination = File destination on the node. This will be the file path and name on the node. The file ownership should be changed by node_config_script.
2029
EOT

0 commit comments

Comments
 (0)