Skip to content

Commit 30d5e49

Browse files
authored
hotfix: block override (#6)
* fix: don't overwrite an existing block's content * fix: don't overwrite an existing block's content * README nitpick * README nitpick * terraform-docs
1 parent c11e759 commit 30d5e49

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
### <p align="center">Spin up ETH clients. On AWS. In a minute.</p>
33

44
- The deployment takes no more than a minute
5-
- The default OS is `debian12`
65
- All clients are managed through systemd
76

87
- The module takes care of the:
@@ -12,7 +11,7 @@
1211
- Full examples can be found in the [examples](./examples/) directory.
1312
> :warning: Be mindful with the security group's configuration. All the examples are simplified to allow all external traffic, which in most cases isn't recommended.
1413
15-
## Example with Reth & Lighthouse running sepolia
14+
## Example with Reth & Lighthouse
1615
```hcl
1716
module "nodes" {
1817
source = "../../"
@@ -92,13 +91,16 @@ MIT Licensed. See [LICENSE](./LICENSE) for full details.
9291
<!-- BEGIN_TF_DOCS -->
9392
## Requirements
9493

95-
No requirements.
94+
| Name | Version |
95+
|------|---------|
96+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
97+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
9698

9799
## Providers
98100

99101
| Name | Version |
100102
|------|---------|
101-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
103+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.15.0 |
102104

103105
## Modules
104106

@@ -109,6 +111,7 @@ No modules.
109111
| Name | Type |
110112
|------|------|
111113
| [aws_ebs_volume.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_volume) | resource |
114+
| [aws_ec2_instance_state.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_instance_state) | resource |
112115
| [aws_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource |
113116
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
114117
| [aws_volume_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/volume_attachment) | resource |
@@ -120,9 +123,9 @@ No modules.
120123
| Name | Description | Type | Default | Required |
121124
|------|-------------|------|---------|:--------:|
122125
| <a name="input_ami"></a> [ami](#input\_ami) | The base AMI to use for the EC2 | <pre>object({<br> name = string<br> })</pre> | <pre>{<br> "name": "debian-12-amd64-20230711-1438"<br>}</pre> | no |
123-
| <a name="input_clients"></a> [clients](#input\_clients) | The ETH clients to deploy on the EC2 | <pre>list(<br> object({<br> name = string<br> package_url = string<br> cmd = string<br><br> ebs = optional(object({<br> device_name = string<br> mountpoint = string<br><br> // Required if we're attaching an external EBS, rather than creation one here<br> attach_external_ebs = optional(bool)<br> external_volume_id = optional(string)<br><br> // Required if we're creating an EBS, rather than attaching an external one<br> ebs_name = optional(string)<br> type = optional(string)<br> size = optional(number)<br> }))<br> }))</pre> | n/a | yes |
124-
| <a name="input_ec2"></a> [ec2](#input\_ec2) | The EC2 configuration | <pre>object({<br> type = optional(string)<br> associate_public_ip_address = bool<br> key_name = string<br> security_group_ids = optional(list(string)) // optional external SGs; ones created outside of this module.<br> disable_api_stop = optional(bool)<br> disable_api_termination = optional(bool)<br> ebs_optimized = optional(bool)<br> get_password_data = optional(bool)<br> hibernation = optional(bool)<br> key_name = optional(string)<br> })</pre> | n/a | yes |
125-
| <a name="input_name"></a> [name](#input\_name) | The generic name to apply across the different resources | `string` | n/a | yes |
126+
| <a name="input_clients"></a> [clients](#input\_clients) | The nodes to deploy on the EC2 | <pre>list(<br> object({<br> name = string # name of the ethereum client<br> package_url = string # link to the url of the binary to download<br> cmd = string # the startup command of the client<br><br> ebs = optional(object({<br> device_name = string<br> mountpoint = string<br><br> # Required if we're attaching an external EBS, rather than creation one here<br> attach_external_ebs = optional(bool)<br> external_volume_id = optional(string)<br><br> # Required if we're creating an EBS, rather than attaching an external one<br> ebs_name = optional(string)<br> type = optional(string)<br> size = optional(number)<br> }))<br> }))</pre> | n/a | yes |
127+
| <a name="input_ec2"></a> [ec2](#input\_ec2) | The EC2 configuration | <pre>object({<br> type = optional(string, "t2.micro")<br> state = optional(string, "running")<br> associate_public_ip_address = bool<br> security_group_ids = optional(list(string)) # external SGs;<br> disable_api_stop = optional(bool)<br> disable_api_termination = optional(bool)<br> ebs_optimized = optional(bool)<br> get_password_data = optional(bool)<br> hibernation = optional(bool)<br> key_name = optional(string)<br> })</pre> | <pre>{<br> "associate_public_ip_address": true,<br> "state": "running",<br> "type": "t2.micro"<br>}</pre> | no |
128+
| <a name="input_name"></a> [name](#input\_name) | The generic name to apply across the different resources created in AWS | `string` | n/a | yes |
126129
| <a name="input_security_group"></a> [security\_group](#input\_security\_group) | The security group rules to apply to the EC2 | <pre>list(object({<br> type = string<br> description = optional(string)<br> from = number<br> to = number<br> protocol = string<br> cidr_blocks = list(string)<br> }))</pre> | `[]` | no |
127130
| <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id) | The subnet to deploy the EC2 in. Defaults to the first subnet returned by the data resource | `string` | n/a | yes |
128131

examples/besu-nimbus-mainnet/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ No inputs.
3535

3636
| Name | Description |
3737
|------|-------------|
38-
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | n/a |
39-
| <a name="output_nodes"></a> [nodes](#output\_nodes) | n/a |
38+
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | Details around the SSH key pair for the manager node |
39+
| <a name="output_node"></a> [node](#output\_node) | Details around the EC2 |
4040
<!-- END_TF_DOCS -->

examples/geth-teku-mainnet/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ No inputs.
3434

3535
| Name | Description |
3636
|------|-------------|
37-
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | n/a |
38-
| <a name="output_nodes"></a> [nodes](#output\_nodes) | n/a |
37+
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | Details around the SSH key pair for the manager node |
38+
| <a name="output_node"></a> [node](#output\_node) | Details around the EC2 |
3939
<!-- END_TF_DOCS -->

examples/reth-lighthouse-sepolia/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ No inputs.
3434

3535
| Name | Description |
3636
|------|-------------|
37-
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | n/a |
38-
| <a name="output_nodes"></a> [nodes](#output\_nodes) | n/a |
37+
| <a name="output_key_pair"></a> [key\_pair](#output\_key\_pair) | Details around the SSH key pair for the manager node |
38+
| <a name="output_node"></a> [node](#output\_node) | Details around the EC2 |
3939
<!-- END_TF_DOCS -->

templates/init.sh.tftpl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ function setup() {
1414
local package=$(echo $url | awk -F '/' '{print $NF}')
1515

1616
if [[ -n "$device_name" ]] && [[ -n "$mountpoint" ]]; then
17-
mkdir -p $mountpoint && \
18-
mkfs -t ext4 /dev/$device_name && \
17+
mkdir -p $mountpoint
18+
19+
# determine if we're remounting a block with an already existing FS or creating a new one
20+
# otherwise we'll overwrite the existing content of the block by recreating the FS
21+
if [[ $(blkid /dev/$device_name) ]]; then
22+
echo "Found existing filesystem on /dev/$device_name"
23+
else
24+
echo "Creating new filesystem (ext4) on /dev/$device_name"
25+
mkfs -t ext4 /dev/$device_name
26+
fi
27+
1928
echo "/dev/$device_name $mountpoint ext4 defaults 0 0" >> /etc/fstab && \
20-
mount -a && \
21-
systemctl daemon-reload && \
22-
sleep 2
29+
mount -a
2330
fi
2431

2532
case "$executable_name" in

0 commit comments

Comments
 (0)