From 14b4f5fb34bb479938ccfcef4d199e36d245b37a Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Thu, 7 Jul 2022 12:15:03 +0530 Subject: [PATCH 1/7] Migrate map() to {} map() is deprecated since terraform 0.12 Signed-off-by: baalajimaestro --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index ce5818f..a2bd2c7 100644 --- a/main.tf +++ b/main.tf @@ -174,7 +174,7 @@ resource "random_password" "password" { locals { cluster_identifier = length(var.cluster_identifier) == 0 ? format("%s-%s-rds-cluster", var.service_name, var.environment) : var.cluster_identifier - tags = merge(var.tags, map("Name", format("%s-%s-rds-cluster", var.service_name, var.environment))) + tags = merge(var.tags, {"Name" = format("%s-%s-rds-cluster", var.service_name, var.environment)}) master_password = var.master_password != "" ? var.master_password : random_password.password[0].result final_snapshot_identifier = length(var.final_snapshot_identifier) != 0 ? var.final_snapshot_identifier : format("%s-%s-snapshot", var.service_name, var.environment) } From 5b4752dcfb08f9cbaa92b7cec259dbe24f2baa81 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Thu, 7 Jul 2022 12:17:16 +0530 Subject: [PATCH 2/7] Move provider to a file of itself Signed-off-by: baalajimaestro --- provider.tf | 4 ++++ variables.tf | 5 +++++ versions.tf | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 provider.tf diff --git a/provider.tf b/provider.tf new file mode 100644 index 0000000..a7f47ed --- /dev/null +++ b/provider.tf @@ -0,0 +1,4 @@ +provider "aws" { + profile = var.aws_profile + region = var.aws_region +} diff --git a/variables.tf b/variables.tf index 294f3c7..c306353 100644 --- a/variables.tf +++ b/variables.tf @@ -13,6 +13,11 @@ variable "aws_region" { description = "AWS Region for develop infra" } +variable "aws_profile" { + type = string + description = "The AWS Profile" +} + variable "enable" { type = string default = true diff --git a/versions.tf b/versions.tf index 85f19bd..956b16c 100644 --- a/versions.tf +++ b/versions.tf @@ -1,4 +1,3 @@ -provider "aws" { region = var.aws_region } terraform { required_version = "~> 0.12" required_providers { From 0a6ac88c9b460ce91d2c33d3017a37993305e95c Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Thu, 7 Jul 2022 12:18:41 +0530 Subject: [PATCH 3/7] Bump up terraform and AWS requirements Terraform - 1.2 and AWS 4.0 Signed-off-by: baalajimaestro --- versions.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.tf b/versions.tf index 956b16c..3b63193 100644 --- a/versions.tf +++ b/versions.tf @@ -1,6 +1,6 @@ terraform { - required_version = "~> 0.12" + required_version = "~> 1.2" required_providers { - aws = "~> 2.0" + aws = "~> 4.0" } } From 8f27fde2e7dca6a24afaf222752c7a41c0fb79a8 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Thu, 7 Jul 2022 12:21:31 +0530 Subject: [PATCH 4/7] Update readme for bump in provider Signed-off-by: baalajimaestro --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b24f77..cd1db34 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ module "rds-cluster-aws-terraform" { | Name | Version | |------|---------| -| aws | ~> 2.0 | +| aws | ~> 4.0 | ## Inputs From 4e6f163d9e313947359859136db18e4731e73b5e Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 17 Jul 2022 22:26:26 +0530 Subject: [PATCH 5/7] Allow sensitive data to be exported for master_password Signed-off-by: baalajimaestro --- outputs.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/outputs.tf b/outputs.tf index c618d37..1a162a2 100644 --- a/outputs.tf +++ b/outputs.tf @@ -13,6 +13,7 @@ output "master_username" { output "master_password" { value = aws_rds_cluster.rds_cluster[0].master_password + sensitive = true } #output "hosted_zone_id" { From 04fdf0a37f98dcb6a72851172616ecdab7669165 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 17 Jul 2022 22:27:21 +0530 Subject: [PATCH 6/7] Dont use admin as the master account admin is a reserved account and cannot be used as master on rds Signed-off-by: baalajimaestro --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index c306353..a16c970 100644 --- a/variables.tf +++ b/variables.tf @@ -73,7 +73,7 @@ variable "database_name" { variable "master_username" { type = string - default = "admin" + default = "scadmin" description = "Username for the master DB user" } From 3d6e135ec4ca0f70949f97be7d425d37536bcd4a Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 17 Jul 2022 22:30:19 +0530 Subject: [PATCH 7/7] Rework the variables Most defaults are removed, considering how they are mandatory to be filled for the db to be created Signed-off-by: baalajimaestro --- variables.tf | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/variables.tf b/variables.tf index a16c970..14e5aa2 100644 --- a/variables.tf +++ b/variables.tf @@ -11,6 +11,7 @@ variable "environment" { variable "aws_region" { type = string description = "AWS Region for develop infra" + default = "us-east-1" } variable "aws_profile" { @@ -38,13 +39,11 @@ variable "cluster_identifier" { variable "engine" { type = string - default = "aurora" description = "The name of the database engine to be used for this DB cluster" } variable "engine_version" { type = string - default = "" description = "The database engine version" } @@ -73,7 +72,7 @@ variable "database_name" { variable "master_username" { type = string - default = "scadmin" + default = "sradmin" description = "Username for the master DB user" } @@ -255,8 +254,7 @@ variable "scaling_configuration" { } variable "vpc_id" { type = string - description = "" - default = "" + description = "VPC to launch the DB in" } variable "timeouts" { @@ -279,7 +277,6 @@ variable "subnet_group_name_prefix" { variable "subnet_ids" { type = list - default = [] description = "A list of VPC subnet IDs (db_subnet_group)" } @@ -393,7 +390,6 @@ variable "cidr_blocks_allowed" { variable "cluster_family" { type = string - default = "aurora5.6" description = "The family of the DB cluster parameter group" }