From 4d7f3d873b0d2be7361d439e62b872a895073342 Mon Sep 17 00:00:00 2001
From: Brad Alexander <10731572+brad-alexander@users.noreply.github.com>
Date: Mon, 9 May 2022 01:52:10 -0700
Subject: [PATCH 1/2] feat!: Add support for user_data_replace_on_change, and
updated AWS provider to v4.7+ (#272)
---
README.md | 5 +++--
examples/complete/README.md | 4 ++--
examples/complete/main.tf | 3 ++-
examples/complete/versions.tf | 2 +-
main.tf | 12 ++++++++----
variables.tf | 6 ++++++
versions.tf | 2 +-
wrappers/main.tf | 1 +
8 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 8fddc030..19fc80e4 100644
--- a/README.md
+++ b/README.md
@@ -168,13 +168,13 @@ The following combinations are supported to conditionally create resources:
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13.1 |
-| [aws](#requirement\_aws) | >= 3.72 |
+| [aws](#requirement\_aws) | >= 4.7 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 3.72 |
+| [aws](#provider\_aws) | >= 4.7 |
## Modules
@@ -240,6 +240,7 @@ No modules.
| [timeouts](#input\_timeouts) | Define maximum timeout for creating, updating, and deleting EC2 instance resources | `map(string)` | `{}` | no |
| [user\_data](#input\_user\_data) | The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user\_data\_base64 instead. | `string` | `null` | no |
| [user\_data\_base64](#input\_user\_data\_base64) | Can be used instead of user\_data to pass base64-encoded binary data directly. Use this instead of user\_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption. | `string` | `null` | no |
+| [user\_data\_replace\_on\_change](#input\_user\_data\_replace\_on\_change) | When used in combination with user\_data or user\_data\_base64 will trigger a destroy and recreate when set to true. Defaults to false if not set. | `bool` | `false` | no |
| [volume\_tags](#input\_volume\_tags) | A mapping of tags to assign to the devices created by the instance at launch time | `map(string)` | `{}` | no |
| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group IDs to associate with | `list(string)` | `null` | no |
diff --git a/examples/complete/README.md b/examples/complete/README.md
index 9a47bfc1..9455766e 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -20,13 +20,13 @@ Note that this example may create resources which can cost money. Run `terraform
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13.1 |
-| [aws](#requirement\_aws) | >= 3.72 |
+| [aws](#requirement\_aws) | >= 4.7 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 3.72 |
+| [aws](#provider\_aws) | >= 4.7 |
## Modules
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 70e3514d..8f9a9553 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -100,7 +100,8 @@ module "ec2_complete" {
hibernation = true
# enclave_options_enabled = true
- user_data_base64 = base64encode(local.user_data)
+ user_data_base64 = base64encode(local.user_data)
+ user_data_replace_on_change = true
cpu_core_count = 2 # default 4
cpu_threads_per_core = 1 # default 2
diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf
index 22e8d726..36060f73 100644
--- a/examples/complete/versions.tf
+++ b/examples/complete/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 3.72"
+ version = ">= 4.7"
}
}
}
diff --git a/main.tf b/main.tf
index e1029dd4..1e027c2d 100644
--- a/main.tf
+++ b/main.tf
@@ -11,10 +11,12 @@ resource "aws_instance" "this" {
instance_type = var.instance_type
cpu_core_count = var.cpu_core_count
cpu_threads_per_core = var.cpu_threads_per_core
- user_data = var.user_data
- user_data_base64 = var.user_data_base64
hibernation = var.hibernation
+ user_data = var.user_data
+ user_data_base64 = var.user_data_base64
+ user_data_replace_on_change = var.user_data_replace_on_change
+
availability_zone = var.availability_zone
subnet_id = var.subnet_id
vpc_security_group_ids = var.vpc_security_group_ids
@@ -144,10 +146,12 @@ resource "aws_spot_instance_request" "this" {
instance_type = var.instance_type
cpu_core_count = var.cpu_core_count
cpu_threads_per_core = var.cpu_threads_per_core
- user_data = var.user_data
- user_data_base64 = var.user_data_base64
hibernation = var.hibernation
+ user_data = var.user_data
+ user_data_base64 = var.user_data_base64
+ user_data_replace_on_change = var.user_data_replace_on_change
+
availability_zone = var.availability_zone
subnet_id = var.subnet_id
vpc_security_group_ids = var.vpc_security_group_ids
diff --git a/variables.tf b/variables.tf
index 00d82fb8..54ec88c1 100644
--- a/variables.tf
+++ b/variables.tf
@@ -208,6 +208,12 @@ variable "user_data_base64" {
default = null
}
+variable "user_data_replace_on_change" {
+ description = "When used in combination with user_data or user_data_base64 will trigger a destroy and recreate when set to true. Defaults to false if not set."
+ type = bool
+ default = false
+}
+
variable "volume_tags" {
description = "A mapping of tags to assign to the devices created by the instance at launch time"
type = map(string)
diff --git a/versions.tf b/versions.tf
index 22e8d726..36060f73 100644
--- a/versions.tf
+++ b/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 3.72"
+ version = ">= 4.7"
}
}
}
diff --git a/wrappers/main.tf b/wrappers/main.tf
index 9937625b..3eec1a5f 100644
--- a/wrappers/main.tf
+++ b/wrappers/main.tf
@@ -38,6 +38,7 @@ module "wrapper" {
tenancy = try(each.value.tenancy, var.defaults.tenancy, null)
user_data = try(each.value.user_data, var.defaults.user_data, null)
user_data_base64 = try(each.value.user_data_base64, var.defaults.user_data_base64, null)
+ user_data_replace_on_change = try(each.value.user_data_replace_on_change, var.defaults.user_data_replace_on_change, false)
volume_tags = try(each.value.volume_tags, var.defaults.volume_tags, {})
enable_volume_tags = try(each.value.enable_volume_tags, var.defaults.enable_volume_tags, true)
vpc_security_group_ids = try(each.value.vpc_security_group_ids, var.defaults.vpc_security_group_ids, null)
From 9aa189fc68de844b9aa27533d68dc18288c155c8 Mon Sep 17 00:00:00 2001
From: semantic-release-bot
Date: Mon, 9 May 2022 08:52:55 +0000
Subject: [PATCH 2/2] chore(release): version 4.0.0 [skip ci]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## [4.0.0](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/compare/v3.6.0...v4.0.0) (2022-05-09)
### ⚠ BREAKING CHANGES
* Add support for user_data_replace_on_change, and updated AWS provider to v4.7+ (#272)
### Features
* Add support for user_data_replace_on_change, and updated AWS provider to v4.7+ ([#272](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/issues/272)) ([4d7f3d8](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/commit/4d7f3d873b0d2be7361d439e62b872a895073342))
---
CHANGELOG.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ca18bd6..06121f97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
+## [4.0.0](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/compare/v3.6.0...v4.0.0) (2022-05-09)
+
+
+### ⚠ BREAKING CHANGES
+
+* Add support for user_data_replace_on_change, and updated AWS provider to v4.7+ (#272)
+
+### Features
+
+* Add support for user_data_replace_on_change, and updated AWS provider to v4.7+ ([#272](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/issues/272)) ([4d7f3d8](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/commit/4d7f3d873b0d2be7361d439e62b872a895073342))
+
## [3.6.0](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/compare/v3.5.0...v3.6.0) (2022-05-06)