From 7a0f86b0348f954b7143ca149e38cff7657475af Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:47:42 -0800 Subject: [PATCH 01/21] feat: update deployment --- k8s-housekeeper.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/k8s-housekeeper.tf b/k8s-housekeeper.tf index 98cf76a..55209c5 100644 --- a/k8s-housekeeper.tf +++ b/k8s-housekeeper.tf @@ -4,7 +4,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); */ -resource "kubernetes_deployment" "apiary_hms_housekeeper" { +resource "kubernetes_deployment_v1" "apiary_hms_housekeeper" { count = var.hms_instance_type == "k8s" && var.enable_hms_housekeeper ? 1 : 0 metadata { name = "${local.hms_alias}-housekeeper" @@ -157,11 +157,11 @@ resource "kubernetes_deployment" "apiary_hms_housekeeper" { } resources { - limits { + limits = { cpu = 0.5 memory = "2048Mi" } - requests { + requests = { cpu = 0.5 memory = "2048Mi" } @@ -173,4 +173,4 @@ resource "kubernetes_deployment" "apiary_hms_housekeeper" { } } } -} \ No newline at end of file +} From 3d8cd021d296507b2720b20ed71dda50ac408787 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:48:54 -0800 Subject: [PATCH 02/21] feat: update deployment --- k8s-readonly.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s-readonly.tf b/k8s-readonly.tf index ba02811..89f3ea2 100644 --- a/k8s-readonly.tf +++ b/k8s-readonly.tf @@ -4,7 +4,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); */ -resource "kubernetes_deployment" "apiary_hms_readonly" { +resource "kubernetes_deployment_v1" "apiary_hms_readonly" { count = var.hms_instance_type == "k8s" ? 1 : 0 metadata { name = "${local.hms_alias}-readonly" @@ -218,11 +218,11 @@ resource "kubernetes_deployment" "apiary_hms_readonly" { } resources { - limits { + limits = { cpu = local.k8s_ro_cpu_limit memory = "${var.hms_ro_heapsize}Mi" } - requests { + requests = { cpu = local.k8s_ro_cpu memory = "${var.hms_ro_heapsize}Mi" } From 5013b4c7f3c90a1ac70c15169c4b3e7f00d68c70 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:49:56 -0800 Subject: [PATCH 03/21] feat: update deployment --- k8s-readwrite.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s-readwrite.tf b/k8s-readwrite.tf index 153f5ab..f79e39a 100644 --- a/k8s-readwrite.tf +++ b/k8s-readwrite.tf @@ -4,7 +4,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); */ -resource "kubernetes_deployment" "apiary_hms_readwrite" { +resource "kubernetes_deployment_v1" "apiary_hms_readwrite" { count = var.hms_instance_type == "k8s" ? 1 : 0 metadata { name = "${local.hms_alias}-readwrite" @@ -258,11 +258,11 @@ resource "kubernetes_deployment" "apiary_hms_readwrite" { } resources { - limits { + limits = { cpu = local.k8s_rw_cpu_limit memory = "${var.hms_rw_heapsize}Mi" } - requests { + requests = { cpu = local.k8s_rw_cpu memory = "${var.hms_rw_heapsize}Mi" } From 8610c39c5e7017ecfaa3f5ed5bc9bccf224cff8d Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:53:56 -0800 Subject: [PATCH 04/21] feat: update k8s provider version to "~> 2.7.0" --- version.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.tf b/version.tf index 1dd8002..dea5ffd 100644 --- a/version.tf +++ b/version.tf @@ -9,7 +9,7 @@ terraform { required_providers { kubernetes = { source = "hashicorp/kubernetes" - version = "~> 1.0" + version = "~> 2.7.0" } aws = { source = "hashicorp/aws" From 819bc4df4f993a6bc75cfed0cb758de7adf80da6 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:59:45 -0800 Subject: [PATCH 05/21] feat: update api attributes --- route53.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/route53.tf b/route53.tf index 587ef3a..a994b71 100644 --- a/route53.tf +++ b/route53.tf @@ -46,7 +46,7 @@ resource "aws_route53_record" "hms_readwrite" { zone_id = aws_route53_zone.apiary[0].id type = "CNAME" ttl = "300" - records = kubernetes_service.hms_readwrite[0].load_balancer_ingress.*.hostname + records = kubernetes_service.hms_readwrite[0].status.0.load_balancer.0.ingress.*.hostname } resource "aws_route53_record" "hms_readonly" { @@ -56,5 +56,5 @@ resource "aws_route53_record" "hms_readonly" { zone_id = aws_route53_zone.apiary[0].id type = "CNAME" ttl = "300" - records = kubernetes_service.hms_readonly[0].load_balancer_ingress.*.hostname + records = kubernetes_service.hms_readonly[0].status.0.load_balancer.0.ingress.*.hostname } From 4994e25780344672677f8cac98239d40e5737a69 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:12:07 -0800 Subject: [PATCH 06/21] feat: update map function --- db.tf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db.tf b/db.tf index 5060c9b..2cb1a9b 100644 --- a/db.tf +++ b/db.tf @@ -10,7 +10,7 @@ resource "aws_db_subnet_group" "apiarydbsg" { subnet_ids = var.private_subnets description = "Apiary DB Subnet Group" - tags = merge(map("Name", "Apiary DB Subnet Group"), var.apiary_tags) + tags = merge(tomap({"Name"="Apiary DB Subnet Group"}), var.apiary_tags) } resource "aws_security_group" "db_sg" { @@ -50,7 +50,7 @@ resource "aws_rds_cluster_parameter_group" "apiary_rds_param_group" { name = "${local.instance_alias}-param-group" family = var.rds_family # Needs to be kept in sync with aws_rds_cluster.apiary_cluster.engine and version description = "Apiary-specific Aurora parameters" - tags = merge(map("Name", "${local.instance_alias}-param-group"), var.apiary_tags) + tags = merge(tomap({"Name"="${local.instance_alias}-param-group"}), var.apiary_tags) parameter { name = "max_allowed_packet" @@ -123,9 +123,10 @@ resource "aws_secretsmanager_secret_version" "apiary_mysql_master_credentials" { count = var.external_database_host == "" ? 1 : 0 secret_id = aws_secretsmanager_secret.apiary_mysql_master_credentials[0].id secret_string = jsonencode( - map( - "username", var.db_master_username, - "password", random_string.db_master_password[0].result + tomap({ + "username"=var.db_master_username, + "password"=random_string.db_master_password[0].result + } ) ) } From ce0c2e0349265f94d4dfe6a3bba87fe2b3f44a2c Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:13:52 -0800 Subject: [PATCH 07/21] feat: update kubernetes_deployment to kubernetes_deployment_v1 --- k8s-readonly.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-readonly.tf b/k8s-readonly.tf index 89f3ea2..dcb0de0 100644 --- a/k8s-readonly.tf +++ b/k8s-readonly.tf @@ -253,7 +253,7 @@ resource "kubernetes_horizontal_pod_autoscaler" "hms_readonly" { scale_target_ref { api_version = "apps/v1" kind = "Deployment" - name = kubernetes_deployment.apiary_hms_readonly[0].metadata[0].name + name = kubernetes_deployment_v1.apiary_hms_readonly[0].metadata[0].name } } } From c76a617977d5c2fe7245012dc1aebabab8b63d7f Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:18:40 -0800 Subject: [PATCH 08/21] feat: update attribute --- k8s-readwrite.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-readwrite.tf b/k8s-readwrite.tf index f79e39a..5c34341 100644 --- a/k8s-readwrite.tf +++ b/k8s-readwrite.tf @@ -301,5 +301,5 @@ resource "kubernetes_service" "hms_readwrite" { data "aws_lb" "k8s_hms_rw_lb" { count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0 - name = split("-", split(".", kubernetes_service.hms_readwrite.0.load_balancer_ingress.0.hostname).0).0 + name = split("-", split(".", kubernetes_service.hms_readwrite.status.0.load_balancer.0.ingress.0.hostname).0).0 } From b66a0065e18b8a1a156014580d6071a4a0274726 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:19:08 -0800 Subject: [PATCH 09/21] feat: update attribute --- k8s-readonly.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-readonly.tf b/k8s-readonly.tf index dcb0de0..1d992a8 100644 --- a/k8s-readonly.tf +++ b/k8s-readonly.tf @@ -283,5 +283,5 @@ resource "kubernetes_service" "hms_readonly" { data "aws_lb" "k8s_hms_ro_lb" { count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0 - name = split("-", split(".", kubernetes_service.hms_readonly.0.load_balancer_ingress.0.hostname).0).0 + name = split("-", split(".", kubernetes_service.hms_readonly.status.0.load_balancer.0.ingress.0.hostname).0).0 } From 7463ea59cb0cf02c18360e313c72a25a7bbe5340 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:20:42 -0800 Subject: [PATCH 10/21] feat: update tag --- s3-other.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s3-other.tf b/s3-other.tf index d5db2e9..670b5c3 100644 --- a/s3-other.tf +++ b/s3-other.tf @@ -8,7 +8,7 @@ resource "aws_s3_bucket" "apiary_inventory_bucket" { count = var.s3_enable_inventory == true ? 1 : 0 bucket = local.s3_inventory_bucket acl = "private" - tags = merge(map("Name", "${local.s3_inventory_bucket}"), "${var.apiary_tags}") + tags = merge(tomap({"Name"="${local.s3_inventory_bucket}"}), "${var.apiary_tags}") policy = < Date: Tue, 14 Nov 2023 15:21:42 -0800 Subject: [PATCH 11/21] feat: update tag --- s3-other.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3-other.tf b/s3-other.tf index 670b5c3..400a3d0 100644 --- a/s3-other.tf +++ b/s3-other.tf @@ -217,7 +217,7 @@ resource "aws_s3_bucket_public_access_block" "apiary_access_logs_hive" { resource "aws_s3_bucket" "apiary_system" { bucket = local.apiary_system_bucket - tags = merge(map("Name", local.apiary_system_bucket), var.apiary_tags) + tags = merge(tomap({"Name"=local.apiary_system_bucket}), var.apiary_tags) policy = < Date: Tue, 14 Nov 2023 15:23:23 -0800 Subject: [PATCH 12/21] fix: readonly --- k8s-readonly.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-readonly.tf b/k8s-readonly.tf index 1d992a8..e4b4a2a 100644 --- a/k8s-readonly.tf +++ b/k8s-readonly.tf @@ -283,5 +283,5 @@ resource "kubernetes_service" "hms_readonly" { data "aws_lb" "k8s_hms_ro_lb" { count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0 - name = split("-", split(".", kubernetes_service.hms_readonly.status.0.load_balancer.0.ingress.0.hostname).0).0 + name = split("-", split(".", kubernetes_service.hms_readonly[0].status.0.load_balancer.0.ingress.0.hostname).0).0 } From 1822b5727f719ec21d65f35e87ce39c37c2dddbc Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:23:41 -0800 Subject: [PATCH 13/21] fix: readwrite --- k8s-readwrite.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-readwrite.tf b/k8s-readwrite.tf index 5c34341..14cce7f 100644 --- a/k8s-readwrite.tf +++ b/k8s-readwrite.tf @@ -301,5 +301,5 @@ resource "kubernetes_service" "hms_readwrite" { data "aws_lb" "k8s_hms_rw_lb" { count = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? 1 : 0 - name = split("-", split(".", kubernetes_service.hms_readwrite.status.0.load_balancer.0.ingress.0.hostname).0).0 + name = split("-", split(".", kubernetes_service.hms_readwrite[0].status.0.load_balancer.0.ingress.0.hostname).0).0 } From f76432aee6fae87abd23734c57a1fcd35e71f05a Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:24:32 -0800 Subject: [PATCH 14/21] fix: update tags --- s3.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3.tf b/s3.tf index 2dd220e..528e1f8 100644 --- a/s3.tf +++ b/s3.tf @@ -41,7 +41,7 @@ resource "aws_s3_bucket" "apiary_data_bucket" { acl = "private" request_payer = "BucketOwner" policy = local.bucket_policy_map[each.key] - tags = merge(map("Name", each.value["data_bucket"]), + tags = merge(tomap({"Name"=each.value["data_bucket"]}), var.apiary_tags, jsondecode(lookup(each.value, "tags", "{}"))) From 7001216b387376a2a54068901d9bd7a830cc87cf Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:28:08 -0800 Subject: [PATCH 15/21] feat: fix tolist --- db.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db.tf b/db.tf index 2cb1a9b..7b080d7 100644 --- a/db.tf +++ b/db.tf @@ -72,7 +72,7 @@ resource "aws_rds_cluster" "apiary_cluster" { preferred_backup_window = var.db_backup_window preferred_maintenance_window = var.db_maintenance_window db_subnet_group_name = aws_db_subnet_group.apiarydbsg[0].name - vpc_security_group_ids = compact(concat(list(aws_security_group.db_sg[0].id), var.apiary_rds_additional_sg)) + vpc_security_group_ids = compact(concat(tolist([aws_security_group.db_sg[0].id]), var.apiary_rds_additional_sg)) tags = var.apiary_tags final_snapshot_identifier = "${local.instance_alias}-cluster-final-${random_id.snapshot_id[0].hex}" iam_database_authentication_enabled = true From 42278dc2d98e02903cfc825f0ab960caef801139 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:29:17 -0800 Subject: [PATCH 16/21] fix: tomap --- s3-other.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3-other.tf b/s3-other.tf index 400a3d0..8e1a70f 100644 --- a/s3-other.tf +++ b/s3-other.tf @@ -167,7 +167,7 @@ resource "aws_s3_bucket_notification" "apiary_managed_logs_bucket" { resource "aws_s3_bucket" "apiary_access_logs_hive" { count = local.enable_apiary_s3_log_hive ? 1 : 0 bucket = local.apiary_s3_hive_logs_bucket - tags = merge(map("Name", local.apiary_s3_hive_logs_bucket), var.apiary_tags) + tags = merge(tomap({"Name"=local.apiary_s3_hive_logs_bucket}), var.apiary_tags) policy = < Date: Tue, 14 Nov 2023 15:30:29 -0800 Subject: [PATCH 17/21] fix: to map --- vpc-endpoint-service.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vpc-endpoint-service.tf b/vpc-endpoint-service.tf index 5796d5a..1977647 100644 --- a/vpc-endpoint-service.tf +++ b/vpc-endpoint-service.tf @@ -9,7 +9,7 @@ resource "aws_vpc_endpoint_service" "hms_readonly" { network_load_balancer_arns = compact(concat(aws_lb.apiary_hms_ro_lb.*.arn, data.aws_lb.k8s_hms_ro_lb.*.arn)) acceptance_required = false allowed_principals = formatlist("arn:aws:iam::%s:root", var.apiary_customer_accounts) - tags = merge(map("Name", "${local.instance_alias}-hms-readonly"), "${var.apiary_tags}") + tags = merge(tomap({"Name"="${local.instance_alias}-hms-readonly"}), "${var.apiary_tags}") } resource "aws_vpc_endpoint_connection_notification" "hms_readonly" { @@ -24,7 +24,7 @@ resource "aws_vpc_endpoint_service" "hms_readwrite" { network_load_balancer_arns = compact(concat(aws_lb.apiary_hms_rw_lb.*.arn, data.aws_lb.k8s_hms_rw_lb.*.arn)) acceptance_required = false allowed_principals = distinct(compact(concat(local.assume_allowed_principals, local.producer_allowed_principals))) - tags = merge(map("Name", "${local.instance_alias}-hms-readwrite"), "${var.apiary_tags}") + tags = merge(tomap({"Name"="${local.instance_alias}-hms-readwrite"}), "${var.apiary_tags}") } resource "aws_vpc_endpoint_connection_notification" "hms_readwrite" { From 1cdaeec50c9a0eeab7f84917d47190cb5b7a3335 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:10:05 -0800 Subject: [PATCH 18/21] feat: updata change log --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a10eaad..8959fd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [6.20.0] - 2023-11-15 +### Changed +- Changed `k8s` API to work with provider 2.x +- Changed Terraform `map` to `tomap` to make it work with newer TF provider. + ## [6.19.1] - 2023-08-25 ### Fixed - `customer_condition` to ignore trailing semicolon. From 3584da41db5600e61d96567aa5fa768af60b4bb0 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:27:20 -0800 Subject: [PATCH 19/21] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8959fd7..9c00cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [6.20.0] - 2023-11-15 ### Changed - Changed `k8s` API to work with provider 2.x -- Changed Terraform `map` to `tomap` to make it work with newer TF provider. +- Changed Terraform `map` to `tomap` to make it work with newer TF provider(The map function was deprecated in Terraform v0.12 and is no longer available). ## [6.19.1] - 2023-08-25 ### Fixed From c1c4781fadb0a1fbed87677a17bd93eb596c6413 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:28:19 -0800 Subject: [PATCH 20/21] feat: update release version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c00cb8..092d0ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [6.20.0] - 2023-11-15 +## [7.0.0] - 2023-11-16 ### Changed - Changed `k8s` API to work with provider 2.x - Changed Terraform `map` to `tomap` to make it work with newer TF provider(The map function was deprecated in Terraform v0.12 and is no longer available). From bf64a3c4725b03775454828c981befc62b536e31 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:43:51 -0800 Subject: [PATCH 21/21] feat: fix attribute name --- ouputs.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ouputs.tf b/ouputs.tf index 5a811df..98c5a8e 100644 --- a/ouputs.tf +++ b/ouputs.tf @@ -1,9 +1,9 @@ output "hms_readonly_load_balancers" { - value = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? kubernetes_service.hms_readonly[0].load_balancer_ingress.*.hostname : [] + value = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? kubernetes_service.hms_readonly[0].status.0.load_balancer.0.ingress.0.hostname : [] } output "hms_readwrite_load_balancers" { - value = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? kubernetes_service.hms_readwrite[0].load_balancer_ingress.*.hostname : [] + value = var.hms_instance_type == "k8s" && var.enable_vpc_endpoint_services ? kubernetes_service.hms_readwrite[0].status.0.load_balancer.0.ingress.0.hostname : [] } output "managed_database_host" {