Commit 2aaa9901 authored by Melissa Greenbaum's avatar Melissa Greenbaum Committed by GitHub

feat: Add support for `maintenance_options` (#312)

Co-authored-by: magreenbaum <magreenbaum>
Co-authored-by: default avatarBryant Biggs <bryantbiggs@gmail.com>
Resolves undefined
parent 2b0fb73b
...@@ -8,6 +8,7 @@ on: ...@@ -8,6 +8,7 @@ on:
env: env:
TERRAFORM_DOCS_VERSION: v0.16.0 TERRAFORM_DOCS_VERSION: v0.16.0
TFLINT_VERSION: v0.44.1
jobs: jobs:
collectInputs: collectInputs:
...@@ -21,7 +22,7 @@ jobs: ...@@ -21,7 +22,7 @@ jobs:
- name: Get root directories - name: Get root directories
id: dirs id: dirs
uses: clowdhaus/terraform-composite-actions/directories@v1.8.0 uses: clowdhaus/terraform-composite-actions/directories@v1.8.3
preCommitMinVersions: preCommitMinVersions:
name: Min TF pre-commit name: Min TF pre-commit
...@@ -36,24 +37,26 @@ jobs: ...@@ -36,24 +37,26 @@ jobs:
- name: Terraform min/max versions - name: Terraform min/max versions
id: minMax id: minMax
uses: clowdhaus/terraform-min-max@v1.2.0 uses: clowdhaus/terraform-min-max@v1.2.4
with: with:
directory: ${{ matrix.directory }} directory: ${{ matrix.directory }}
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported # Run only validate pre-commit check on min version supported
if: ${{ matrix.directory != '.' }} if: ${{ matrix.directory != '.' }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.0 uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with: with:
terraform-version: ${{ steps.minMax.outputs.minVersion }} terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
# Run only validate pre-commit check on min version supported # Run only validate pre-commit check on min version supported
if: ${{ matrix.directory == '.' }} if: ${{ matrix.directory == '.' }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.0 uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with: with:
terraform-version: ${{ steps.minMax.outputs.minVersion }} terraform-version: ${{ steps.minMax.outputs.minVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'
preCommitMaxVersion: preCommitMaxVersion:
...@@ -69,18 +72,12 @@ jobs: ...@@ -69,18 +72,12 @@ jobs:
- name: Terraform min/max versions - name: Terraform min/max versions
id: minMax id: minMax
uses: clowdhaus/terraform-min-max@v1.2.0 uses: clowdhaus/terraform-min-max@v1.2.4
- name: Install hcledit (for terraform_wrapper_module_for_each hook)
shell: bash
run: |
curl -L "$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 "https://.+?_linux_amd64.tar.gz")" > hcledit.tgz
sudo tar -xzf hcledit.tgz -C /usr/bin/ hcledit
rm -f hcledit.tgz 2> /dev/null
hcledit version
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.0 uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
with: with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }} terraform-version: ${{ steps.minMax.outputs.maxVersion }}
tflint-version: ${{ env.TFLINT_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
install-hcledit: true
repos: repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform - repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.76.0 rev: v1.77.0
hooks: hooks:
- id: terraform_fmt - id: terraform_fmt
- id: terraform_wrapper_module_for_each - id: terraform_wrapper_module_for_each
...@@ -24,7 +24,7 @@ repos: ...@@ -24,7 +24,7 @@ repos:
- '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote' - '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0 rev: v4.4.0
hooks: hooks:
- id: check-merge-conflict - id: check-merge-conflict
- id: end-of-file-fixer - id: end-of-file-fixer
...@@ -232,6 +232,7 @@ No modules. ...@@ -232,6 +232,7 @@ No modules.
| <a name="input_ipv6_addresses"></a> [ipv6\_addresses](#input\_ipv6\_addresses) | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `null` | no | | <a name="input_ipv6_addresses"></a> [ipv6\_addresses](#input\_ipv6\_addresses) | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `null` | no |
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Key name of the Key Pair to use for the instance; which can be managed using the `aws_key_pair` resource | `string` | `null` | no | | <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Key name of the Key Pair to use for the instance; which can be managed using the `aws_key_pair` resource | `string` | `null` | no |
| <a name="input_launch_template"></a> [launch\_template](#input\_launch\_template) | Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template | `map(string)` | `null` | no | | <a name="input_launch_template"></a> [launch\_template](#input\_launch\_template) | Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template | `map(string)` | `null` | no |
| <a name="input_maintenance_options"></a> [maintenance\_options](#input\_maintenance\_options) | The maintenance options for the instance | `any` | `{}` | no |
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | `{}` | no | | <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | `{}` | no |
| <a name="input_monitoring"></a> [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no | | <a name="input_monitoring"></a> [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no |
| <a name="input_name"></a> [name](#input\_name) | Name to be used on EC2 instance created | `string` | `""` | no | | <a name="input_name"></a> [name](#input\_name) | Name to be used on EC2 instance created | `string` | `""` | no |
......
...@@ -129,6 +129,10 @@ module "ec2_t2_unlimited" { ...@@ -129,6 +129,10 @@ module "ec2_t2_unlimited" {
vpc_security_group_ids = [module.security_group.security_group_id] vpc_security_group_ids = [module.security_group.security_group_id]
associate_public_ip_address = true associate_public_ip_address = true
maintenance_options = {
auto_recovery = "default"
}
tags = local.tags tags = local.tags
} }
...@@ -233,7 +237,6 @@ module "ec2_spot_instance" { ...@@ -233,7 +237,6 @@ module "ec2_spot_instance" {
cpu_core_count = 2 # default 4 cpu_core_count = 2 # default 4
cpu_threads_per_core = 1 # default 2 cpu_threads_per_core = 1 # default 2
enable_volume_tags = false enable_volume_tags = false
root_block_device = [ root_block_device = [
{ {
......
...@@ -127,6 +127,13 @@ resource "aws_instance" "this" { ...@@ -127,6 +127,13 @@ resource "aws_instance" "this" {
} }
} }
dynamic "maintenance_options" {
for_each = length(var.maintenance_options) > 0 ? [var.maintenance_options] : []
content {
auto_recovery = try(maintenance_options.value.auto_recovery, null)
}
}
enclave_options { enclave_options {
enabled = var.enclave_options_enabled enabled = var.enclave_options_enabled
} }
......
...@@ -28,6 +28,12 @@ variable "associate_public_ip_address" { ...@@ -28,6 +28,12 @@ variable "associate_public_ip_address" {
default = null default = null
} }
variable "maintenance_options" {
description = "The maintenance options for the instance"
type = any
default = {}
}
variable "availability_zone" { variable "availability_zone" {
description = "AZ to start the instance in" description = "AZ to start the instance in"
type = string type = string
......
...@@ -8,6 +8,7 @@ module "wrapper" { ...@@ -8,6 +8,7 @@ module "wrapper" {
ami_ssm_parameter = try(each.value.ami_ssm_parameter, var.defaults.ami_ssm_parameter, "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2") ami_ssm_parameter = try(each.value.ami_ssm_parameter, var.defaults.ami_ssm_parameter, "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2")
ami = try(each.value.ami, var.defaults.ami, null) ami = try(each.value.ami, var.defaults.ami, null)
associate_public_ip_address = try(each.value.associate_public_ip_address, var.defaults.associate_public_ip_address, null) associate_public_ip_address = try(each.value.associate_public_ip_address, var.defaults.associate_public_ip_address, null)
maintenance_options = try(each.value.maintenance_options, var.defaults.maintenance_options, {})
availability_zone = try(each.value.availability_zone, var.defaults.availability_zone, null) availability_zone = try(each.value.availability_zone, var.defaults.availability_zone, null)
capacity_reservation_specification = try(each.value.capacity_reservation_specification, var.defaults.capacity_reservation_specification, {}) capacity_reservation_specification = try(each.value.capacity_reservation_specification, var.defaults.capacity_reservation_specification, {})
cpu_credits = try(each.value.cpu_credits, var.defaults.cpu_credits, null) cpu_credits = try(each.value.cpu_credits, var.defaults.cpu_credits, null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment