Skip to content

Commit

Permalink
fix: ec2 instance constant termination/creation if ebs enabled (#239)
Browse files Browse the repository at this point in the history
* fix ec2 instance termination if ebs enabled

* build doc
  • Loading branch information
www44 authored Nov 27, 2024
1 parent 9ab02bd commit 2b9ba4b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Available targets:
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <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 |
| <a name="input_host_name"></a> [host\_name](#input\_host\_name) | The Bastion hostname created in Route53 | `string` | `"bastion"` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <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 |
| <a name="input_host_name"></a> [host\_name](#input\_host\_name) | The Bastion hostname created in Route53 | `string` | `"bastion"` | no |
Expand Down
15 changes: 10 additions & 5 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ output "security_group_name" {
}

output "public_subnet_cidrs" {
value = module.subnets.public_subnet_cidrs
value = module.subnets.public_subnet_cidrs
description = "Public subnets CIDR"
}

output "private_subnet_cidrs" {
value = module.subnets.private_subnet_cidrs
value = module.subnets.private_subnet_cidrs
description = "Private subnets CIDR"
}

output "vpc_cidr" {
value = module.vpc.vpc_cidr_block
value = module.vpc.vpc_cidr_block
description = "VPC CIDR"
}

output "key_name" {
value = module.aws_key_pair.key_name
value = module.aws_key_pair.key_name
description = "Bastion ssh keypair name"
}

output "public_key" {
value = module.aws_key_pair.public_key
value = module.aws_key_pair.public_key
description = "Bastion ssh public key"
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ resource "aws_instance" "default" {
volume_size = var.ebs_block_device_volume_size
delete_on_termination = var.ebs_delete_on_termination
device_name = var.ebs_device_name
snapshot_id = var.ebs_snapshot_id
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ variable "ebs_device_name" {
description = "The name of the EBS block device to mount on the instance"
}

variable "ebs_snapshot_id" {
type = string
default = ""
description = "The snapshot id to use for the EBS block device"
}

variable "instance_profile" {
type = string
description = "A pre-defined profile to attach to the instance (default is to build our own)"
Expand Down

0 comments on commit 2b9ba4b

Please sign in to comment.