From 3e35b985d7b62ac35f9e7fdbb902660f11b3fe4b Mon Sep 17 00:00:00 2001 From: lilyeyes Date: Wed, 23 Aug 2023 18:55:19 +0800 Subject: [PATCH] Deploy valid AWS images past their DeprecationTime TEAM-8177 - [AWS][Terraform] qe-sap-deployment cannot deploy valid images past their DeprecationTime --- terraform/aws/modules/get_os_image/main.tf | 12 +++++++++--- terraform/aws/version.tf | 2 +- terraform/gcp/variables.tf | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/terraform/aws/modules/get_os_image/main.tf b/terraform/aws/modules/get_os_image/main.tf index 5f5637b3..efa00e2c 100644 --- a/terraform/aws/modules/get_os_image/main.tf +++ b/terraform/aws/modules/get_os_image/main.tf @@ -1,11 +1,12 @@ # Data used to get the correct AMI image data "aws_ami" "image" { - most_recent = true - owners = [var.os_owner] + most_recent = true + owners = [var.os_owner] + include_deprecated = true filter { name = "name" - values = substr(var.os_image, 0, 4) == "ami-" ? ["*"] : ["${var.os_image}-*"] + values = substr(var.os_image, 0, 4) == "ami-" ? ["*"] : ["${var.os_image}*"] } filter { @@ -22,4 +23,9 @@ data "aws_ami" "image" { name = "virtualization-type" values = ["hvm"] } + + filter { + name = "state" + values = ["available"] + } } diff --git a/terraform/aws/version.tf b/terraform/aws/version.tf index 6be93e84..3266e72b 100644 --- a/terraform/aws/version.tf +++ b/terraform/aws/version.tf @@ -4,7 +4,7 @@ terraform { # Configure the Azure Provider aws = { source = "hashicorp/aws" - version = "~> 4.0.0" + version = "~> 5.13.1" } null = { source = "hashicorp/null" diff --git a/terraform/gcp/variables.tf b/terraform/gcp/variables.tf index 1059dd2d..071a37a2 100644 --- a/terraform/gcp/variables.tf +++ b/terraform/gcp/variables.tf @@ -81,7 +81,7 @@ variable "deployment_name" { default = "" validation { condition = ( - var.deployment_name != "default" && var.deployment_name != "" + var.deployment_name != "default" ) error_message = "Invalid deployment_name (default) ." }