Skip to content

Commit 2b9ba4b

Browse files
authored
fix: ec2 instance constant termination/creation if ebs enabled (#239)
* fix ec2 instance termination if ebs enabled * build doc
1 parent 9ab02bd commit 2b9ba4b

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Available targets:
118118
| <a name="input_ebs_block_device_volume_size"></a> [ebs\_block\_device\_volume\_size](#input\_ebs\_block\_device\_volume\_size) | The volume size (in GiB) to provision for the EBS block device. Creation skipped if size is 0 | `number` | `0` | no |
119119
| <a name="input_ebs_delete_on_termination"></a> [ebs\_delete\_on\_termination](#input\_ebs\_delete\_on\_termination) | Whether the EBS volume should be destroyed on instance termination | `bool` | `true` | no |
120120
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | The name of the EBS block device to mount on the instance | `string` | `"/dev/sdh"` | no |
121+
| <a name="input_ebs_snapshot_id"></a> [ebs\_snapshot\_id](#input\_ebs\_snapshot\_id) | The snapshot id to use for the EBS block device | `string` | `""` | no |
121122
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
122123
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
123124
| <a name="input_host_name"></a> [host\_name](#input\_host\_name) | The Bastion hostname created in Route53 | `string` | `"bastion"` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
| <a name="input_ebs_block_device_volume_size"></a> [ebs\_block\_device\_volume\_size](#input\_ebs\_block\_device\_volume\_size) | The volume size (in GiB) to provision for the EBS block device. Creation skipped if size is 0 | `number` | `0` | no |
5555
| <a name="input_ebs_delete_on_termination"></a> [ebs\_delete\_on\_termination](#input\_ebs\_delete\_on\_termination) | Whether the EBS volume should be destroyed on instance termination | `bool` | `true` | no |
5656
| <a name="input_ebs_device_name"></a> [ebs\_device\_name](#input\_ebs\_device\_name) | The name of the EBS block device to mount on the instance | `string` | `"/dev/sdh"` | no |
57+
| <a name="input_ebs_snapshot_id"></a> [ebs\_snapshot\_id](#input\_ebs\_snapshot\_id) | The snapshot id to use for the EBS block device | `string` | `""` | no |
5758
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
5859
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
5960
| <a name="input_host_name"></a> [host\_name](#input\_host\_name) | The Bastion hostname created in Route53 | `string` | `"bastion"` | no |

examples/complete/outputs.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,26 @@ output "security_group_name" {
6464
}
6565

6666
output "public_subnet_cidrs" {
67-
value = module.subnets.public_subnet_cidrs
67+
value = module.subnets.public_subnet_cidrs
68+
description = "Public subnets CIDR"
6869
}
6970

7071
output "private_subnet_cidrs" {
71-
value = module.subnets.private_subnet_cidrs
72+
value = module.subnets.private_subnet_cidrs
73+
description = "Private subnets CIDR"
7274
}
7375

7476
output "vpc_cidr" {
75-
value = module.vpc.vpc_cidr_block
77+
value = module.vpc.vpc_cidr_block
78+
description = "VPC CIDR"
7679
}
7780

7881
output "key_name" {
79-
value = module.aws_key_pair.key_name
82+
value = module.aws_key_pair.key_name
83+
description = "Bastion ssh keypair name"
8084
}
8185

8286
output "public_key" {
83-
value = module.aws_key_pair.public_key
87+
value = module.aws_key_pair.public_key
88+
description = "Bastion ssh public key"
8489
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ resource "aws_instance" "default" {
8686
volume_size = var.ebs_block_device_volume_size
8787
delete_on_termination = var.ebs_delete_on_termination
8888
device_name = var.ebs_device_name
89+
snapshot_id = var.ebs_snapshot_id
8990
}
9091
}
9192

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ variable "ebs_device_name" {
212212
description = "The name of the EBS block device to mount on the instance"
213213
}
214214

215+
variable "ebs_snapshot_id" {
216+
type = string
217+
default = ""
218+
description = "The snapshot id to use for the EBS block device"
219+
}
220+
215221
variable "instance_profile" {
216222
type = string
217223
description = "A pre-defined profile to attach to the instance (default is to build our own)"

0 commit comments

Comments
 (0)