Skip to content

Commit a8bc162

Browse files
authored
Feat: Add instance_initiated_shutdown_behavior Variable (#101)
* Add variable for instance initiated shutdown behavior.
1 parent 1adf007 commit a8bc162

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Available targets:
274274
| <a name="input_environment"></a> [environment](#input\_environment) | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
275275
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
276276
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
277+
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
277278
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
278279
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
279280
| <a name="input_ipv6_address_count"></a> [ipv6\_address\_count](#input\_ipv6\_address\_count) | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet (-1 to use subnet default) | `number` | `0` | no |
@@ -489,8 +490,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
489490
### Contributors
490491

491492
<!-- markdownlint-disable -->
492-
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]<br/>[Sergey Vasilyev][s2504s_homepage] | [![Valeriy][drama17_avatar]][drama17_homepage]<br/>[Valeriy][drama17_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]<br/>[Ivan Pinatti][ivan-pinatti_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] | [![Konstantin B][comeanother_avatar]][comeanother_homepage]<br/>[Konstantin B][comeanother_homepage] | [![Maarten van der Hoef][maartenvanderhoef_avatar]][maartenvanderhoef_homepage]<br/>[Maarten van der Hoef][maartenvanderhoef_homepage] | [![Chris Weyl][rsrchboy_avatar]][rsrchboy_homepage]<br/>[Chris Weyl][rsrchboy_homepage] |
493-
|---|---|---|---|---|---|---|---|---|---|
493+
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]<br/>[Sergey Vasilyev][s2504s_homepage] | [![Valeriy][drama17_avatar]][drama17_homepage]<br/>[Valeriy][drama17_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]<br/>[Ivan Pinatti][ivan-pinatti_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] | [![Konstantin B][comeanother_avatar]][comeanother_homepage]<br/>[Konstantin B][comeanother_homepage] | [![Maarten van der Hoef][maartenvanderhoef_avatar]][maartenvanderhoef_homepage]<br/>[Maarten van der Hoef][maartenvanderhoef_homepage] | [![Chris Weyl][rsrchboy_avatar]][rsrchboy_homepage]<br/>[Chris Weyl][rsrchboy_homepage] | [![Yonatan Koren][korenyoni_avatar]][korenyoni_homepage]<br/>[Yonatan Koren][korenyoni_homepage] |
494+
|---|---|---|---|---|---|---|---|---|---|---|
494495
<!-- markdownlint-restore -->
495496

496497
[osterman_homepage]: https://github.com/osterman
@@ -513,6 +514,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
513514
[maartenvanderhoef_avatar]: https://img.cloudposse.com/150x150/https://github.com/maartenvanderhoef.png
514515
[rsrchboy_homepage]: https://github.com/rsrchboy
515516
[rsrchboy_avatar]: https://img.cloudposse.com/150x150/https://github.com/rsrchboy.png
517+
[korenyoni_homepage]: https://github.com/korenyoni
518+
[korenyoni_avatar]: https://img.cloudposse.com/150x150/https://github.com/korenyoni.png
516519

517520
[![README Footer][readme_footer_img]][readme_footer_link]
518521
[![Beacon][beacon]][website]

README.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,5 @@ contributors:
150150
github: maartenvanderhoef
151151
- name: Chris Weyl
152152
github: rsrchboy
153+
- name: Yonatan Koren
154+
github: korenyoni

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
| <a name="input_environment"></a> [environment](#input\_environment) | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
7878
| <a name="input_evaluation_periods"></a> [evaluation\_periods](#input\_evaluation\_periods) | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
7979
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
80+
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
8081
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
8182
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
8283
| <a name="input_ipv6_address_count"></a> [ipv6\_address\_count](#input\_ipv6\_address\_count) | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet (-1 to use subnet default) | `number` | `0` | no |

main.tf

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,25 @@ resource "aws_iam_role" "default" {
107107

108108
resource "aws_instance" "default" {
109109
#bridgecrew:skip=BC_AWS_GENERAL_31: Skipping `Ensure Instance Metadata Service Version 1 is not enabled` check until BridgeCrew supports conditional evaluation. See https://github.com/bridgecrewio/checkov/issues/793
110-
count = local.instance_count
111-
ami = local.ami
112-
availability_zone = local.availability_zone
113-
instance_type = var.instance_type
114-
ebs_optimized = var.ebs_optimized
115-
disable_api_termination = var.disable_api_termination
116-
user_data = var.user_data
117-
user_data_base64 = var.user_data_base64
118-
iam_instance_profile = local.instance_profile
119-
associate_public_ip_address = var.associate_public_ip_address
120-
key_name = var.ssh_key_pair
121-
subnet_id = var.subnet
122-
monitoring = var.monitoring
123-
private_ip = var.private_ip
124-
source_dest_check = var.source_dest_check
125-
ipv6_address_count = var.ipv6_address_count < 0 ? null : var.ipv6_address_count
126-
ipv6_addresses = length(var.ipv6_addresses) == 0 ? null : var.ipv6_addresses
110+
#bridgecrew:skip=BC_AWS_NETWORKING_47: Skiping `Ensure AWS EC2 instance is configured with VPC` because it is incorrectly flagging that this instance does not belong to a VPC even though subnet_id is configured.
111+
count = local.instance_count
112+
ami = local.ami
113+
availability_zone = local.availability_zone
114+
instance_type = var.instance_type
115+
ebs_optimized = var.ebs_optimized
116+
disable_api_termination = var.disable_api_termination
117+
user_data = var.user_data
118+
user_data_base64 = var.user_data_base64
119+
iam_instance_profile = local.instance_profile
120+
instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
121+
associate_public_ip_address = var.associate_public_ip_address
122+
key_name = var.ssh_key_pair
123+
subnet_id = var.subnet
124+
monitoring = var.monitoring
125+
private_ip = var.private_ip
126+
source_dest_check = var.source_dest_check
127+
ipv6_address_count = var.ipv6_address_count < 0 ? null : var.ipv6_address_count
128+
ipv6_addresses = length(var.ipv6_addresses) == 0 ? null : var.ipv6_addresses
127129

128130
vpc_security_group_ids = compact(
129131
concat(

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ variable "instance_profile" {
265265
default = ""
266266
}
267267

268+
variable "instance_initiated_shutdown_behavior" {
269+
type = string
270+
description = "Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'."
271+
default = null
272+
}
273+
268274
variable "root_block_device_encrypted" {
269275
type = bool
270276
default = true

0 commit comments

Comments
 (0)