diff --git a/CHANGELOG.md b/CHANGELOG.md index 34993d9..81ac323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.5 (TBD) + +### Features +- Refactored Amazon RDS Aurora (MySQL and PostgreSQL) module variables + ## 1.0.4 (2024-07-25) ### Features diff --git a/examples/onboard-aws-rds-aurora-mysql-kinesis/main.tf b/examples/onboard-aws-rds-aurora-mysql-kinesis/main.tf index a3f47fe..6c05a75 100644 --- a/examples/onboard-aws-rds-aurora-mysql-kinesis/main.tf +++ b/examples/onboard-aws-rds-aurora-mysql-kinesis/main.tf @@ -65,10 +65,9 @@ module "aws-aurora-mysql-kinesis" { aws_kinesis_region = local.aws_region cluster_apply_immediately = local.apply_immediately - cluster_db_master_password = local.master_password - cluster_db_master_username = local.master_user - cluster_id = "tf-aurora-mysql-kinesis-cluster" - cluster_final_snapshot = true + cluster_master_password = local.master_password + cluster_master_username = local.master_user + cluster_identifier = "tf-aurora-mysql-kinesis-cluster" instance_apply_immediately = local.apply_immediately instance_identifier = "tf-aurora-mysql-kinesis-instance" diff --git a/examples/onboard-aws-rds-aurora-mysql-slowquery/main.tf b/examples/onboard-aws-rds-aurora-mysql-slowquery/main.tf index 0689c75..59884b1 100644 --- a/examples/onboard-aws-rds-aurora-mysql-slowquery/main.tf +++ b/examples/onboard-aws-rds-aurora-mysql-slowquery/main.tf @@ -83,9 +83,9 @@ module "aws-aurora-mysql-slowquery" { } ] - cluster_cluster_id = "aurora-mysql-cluster" - cluster_db_master_username = "admin" - cluster_db_master_password = "mypassword" + cluster_identifier = "aurora-mysql-cluster" + cluster_master_username = "admin" + cluster_master_password = "mypassword" cluster_db_subnet_group_name = local.subnet_group_name cluster_vpc_security_group_ids = local.vpc_security_group_ids diff --git a/examples/onboard-aws-rds-aurora-mysql/main.tf b/examples/onboard-aws-rds-aurora-mysql/main.tf index 5c475de..3c60271 100644 --- a/examples/onboard-aws-rds-aurora-mysql/main.tf +++ b/examples/onboard-aws-rds-aurora-mysql/main.tf @@ -57,9 +57,9 @@ module "aws-aurora-mysql" { cluster_parameter_group_name = "aurora-mysql-cpg-tf" - cluster_cluster_id = "aurora-mysql-cluster" - cluster_db_master_username = "admin" - cluster_db_master_password = "mypassword" + cluster_identifier = "aurora-mysql-cluster" + cluster_master_username = "admin" + cluster_master_password = "mypassword" cluster_db_subnet_group_name = local.subnet_group_name cluster_vpc_security_group_ids = local.vpc_security_group_ids diff --git a/examples/onboard-aws-rds-aurora-postgresql-kinesis/main.tf b/examples/onboard-aws-rds-aurora-postgresql-kinesis/main.tf index 2b5aa28..4bc008b 100644 --- a/examples/onboard-aws-rds-aurora-postgresql-kinesis/main.tf +++ b/examples/onboard-aws-rds-aurora-postgresql-kinesis/main.tf @@ -64,11 +64,11 @@ module "aws-aurora-postgresql-kinesis-1" { aws_kinesis_gateway_id = local.gateway_id aws_kinesis_region = local.aws_region - cluster_apply_immediately = true - cluster_db_engine_version = "16" - cluster_db_master_password = local.master_password - cluster_db_master_username = local.master_user - cluster_id = "tf-aurora-postgresql-kinesis-cluster" + cluster_apply_immediately = true + cluster_engine_version = "16" + cluster_identifier = "tf-aurora-postgresql-kinesis-cluster" + cluster_master_password = local.master_password + cluster_master_username = local.master_user instance_apply_immediately = true instance_class = "db.r5.large" @@ -93,11 +93,11 @@ module "aws-aurora-postgresql-kinesis-2" { aws_kinesis_gateway_id = local.gateway_id aws_kinesis_region = local.aws_region - cluster_apply_immediately = true - cluster_db_engine_version = "16" - cluster_db_master_password = local.master_password - cluster_db_master_username = local.master_user - cluster_id = "tf-aurora-postgresql-kinesis-cluster" + cluster_apply_immediately = true + cluster_engine_version = "16" + cluster_identifier = "tf-aurora-postgresql-kinesis-cluster" + cluster_master_password = local.master_password + cluster_master_username = local.master_user instance_apply_immediately = true instance_class = "db.r5.large" diff --git a/examples/onboard-aws-rds-aurora-postgresql/main.tf b/examples/onboard-aws-rds-aurora-postgresql/main.tf index b64729d..c9a8a61 100644 --- a/examples/onboard-aws-rds-aurora-postgresql/main.tf +++ b/examples/onboard-aws-rds-aurora-postgresql/main.tf @@ -87,12 +87,11 @@ module "aurora-postgresql-1" { aws_log_group_gateway_id = local.gateway_id aws_log_group_region = local.aws_region - cluster_db_engine_version = "16.1" - cluster_db_master_password = local.master_password - cluster_db_master_username = local.master_user cluster_db_subnet_group_name = local.subnet_group_name - cluster_final_snapshot = true - cluster_id = "tf-aurora-postgresql-cluster" + cluster_engine_version = "16.1" + cluster_identifier = "tf-aurora-postgresql-cluster" + cluster_master_password = local.master_password + cluster_master_username = local.master_user cluster_parameter_group_name = "tf-aurora-postgresql-instance-pg" cluster_vpc_security_group_ids = local.vpc_security_groups @@ -118,12 +117,11 @@ module "aurora-postgresql-2" { aws_log_group_gateway_id = local.gateway_id aws_log_group_region = local.aws_region - cluster_db_engine_version = "16.1" - cluster_db_master_password = local.master_password - cluster_db_master_username = local.master_user cluster_db_subnet_group_name = local.subnet_group_name - cluster_final_snapshot = true - cluster_id = "tf-aurora-postgresql-cluster" + cluster_engine_version = "16.1" + cluster_identifier = "tf-aurora-postgresql-cluster" + cluster_master_password = local.master_password + cluster_master_username = local.master_user cluster_parameter_group_name = "tf-aurora-postgresql-instance-pg" cluster_vpc_security_group_ids = local.vpc_security_groups diff --git a/modules/aws-rds-cluster/main.tf b/modules/aws-rds-cluster/main.tf index c675f3e..acda5bf 100644 --- a/modules/aws-rds-cluster/main.tf +++ b/modules/aws-rds-cluster/main.tf @@ -1,17 +1,17 @@ resource "aws_rds_cluster" "this" { apply_immediately = var.apply_immediately - backup_retention_period = var.backup_retention - cluster_identifier = var.cluster_id - enabled_cloudwatch_logs_exports = var.db_enabled_cloudwatch_logs_exports - engine = var.db_engine - engine_version = var.db_engine_version - master_password = var.db_master_password - master_username = var.db_master_username - port = var.db_port + backup_retention_period = var.backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = var.db_cluster_parameter_group_name db_subnet_group_name = var.db_subnet_group_name - skip_final_snapshot = var.final_snapshot - preferred_maintenance_window = var.maintenance_schedule - db_cluster_parameter_group_name = var.parameter_group_name + enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports + engine = var.engine + engine_version = var.engine_version + master_password = var.master_password + master_username = var.master_username network_type = var.network_type + port = var.port + preferred_maintenance_window = var.preferred_maintenance_window + skip_final_snapshot = var.skip_final_snapshot vpc_security_group_ids = var.vpc_security_group_ids } diff --git a/modules/aws-rds-cluster/variables.tf b/modules/aws-rds-cluster/variables.tf index b636e83..e8a301b 100644 --- a/modules/aws-rds-cluster/variables.tf +++ b/modules/aws-rds-cluster/variables.tf @@ -4,82 +4,83 @@ variable "apply_immediately" { default = null } -variable "backup_retention" { +variable "backup_retention_period" { description = "Days to retain backups for, Default is 1 day." type = number default = null } -variable "cluster_id" { - description = "The name of the RDS cluster" +variable "cluster_identifier" { + description = "The cluster identifier." type = string } -variable "db_enabled_cloudwatch_logs_exports" { - description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." - type = list(any) +variable "db_cluster_parameter_group_name" { + description = "A cluster parameter group to associate with the cluster." + type = string default = null } -variable "db_engine" { - description = "Cluster engine e.g., aurora-mysql" +variable "db_subnet_group_name" { + description = "DB subnet group to associate with this DB cluster. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." type = string default = null } -variable "db_engine_version" { - description = "Database engine version, e.g., 8.0.mysql_aurora.3.05.1" - type = string + +variable "enabled_cloudwatch_logs_exports" { + description = "Set of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, error, general, slowquery, postgresql (PostgreSQL)." + type = list(string) default = null } -variable "db_master_password" { - description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" +variable "engine" { + description = "Name of the database engine to be used for this DB cluster. Valid Values: aurora-mysql, aurora-postgresql, mysql, postgres. (Note that mysql and postgres are Multi-AZ RDS clusters)." type = string + default = null } -variable "db_master_username" { - description = "Username for the master DB user, must not use rdsadmin as that is reserved." +variable "engine_version" { + description = "Database engine version, e.g., 8.0.mysql_aurora.3.05.1" type = string + default = null } -variable "db_port" { - description = "Port on which the DB accepts connections." - type = number - default = null +variable "master_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string } -variable "db_subnet_group_name" { - description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." +variable "master_username" { + description = "Username for the master DB user, must not use rdsadmin as that is reserved." type = string - default = null } -variable "final_snapshot" { - description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" - type = bool +variable "network_type" { + description = " Network type of the cluster. Valid values: IPV4, DUAL" + type = string default = null } -variable "maintenance_schedule" { - description = "Weekly time range during which system maintenance can occur, in (UTC)." - type = string +variable "port" { + description = "Port on which the DB accepts connections." + type = number default = null } -variable "network_type" { - description = " Network type of the cluster. Valid values: IPV4, DUAL" +variable "preferred_maintenance_window" { + description = "Weekly time range during which system maintenance can occur, in (UTC) e.g., wed:04:00-wed:04:30." type = string default = null } -variable "parameter_group_name" { - description = "Cluster parameter group associated with the cluster" - type = string +variable "skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" + type = bool default = null } variable "vpc_security_group_ids" { - description = "List of VPC security groups to associate." + description = "List of VPC security groups to associate with the cluster." type = list(any) default = null } diff --git a/modules/onboard-aws-rds-aurora-mysql-kinesis/main.tf b/modules/onboard-aws-rds-aurora-mysql-kinesis/main.tf index f3def54..2109bbf 100644 --- a/modules/onboard-aws-rds-aurora-mysql-kinesis/main.tf +++ b/modules/onboard-aws-rds-aurora-mysql-kinesis/main.tf @@ -1,21 +1,21 @@ module "aurora-mysql-cluster" { source = "../aws-rds-cluster" - apply_immediately = var.cluster_apply_immediately - backup_retention = var.cluster_backup_retention - cluster_id = var.cluster_id - db_enabled_cloudwatch_logs_exports = var.cluster_db_enabled_cloudwatch_logs_exports - db_engine = "aurora-mysql" - db_engine_version = var.cluster_db_engine_version - db_master_password = var.cluster_db_master_password - db_master_username = var.cluster_db_master_username - db_port = var.cluster_db_port - db_subnet_group_name = var.cluster_db_subnet_group_name - final_snapshot = var.cluster_final_snapshot - maintenance_schedule = var.cluster_maintenance_schedule - network_type = var.cluster_network_type - parameter_group_name = var.cluster_parameter_group_name - vpc_security_group_ids = var.cluster_vpc_security_group_ids + apply_immediately = var.cluster_apply_immediately + backup_retention_period = var.cluster_backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = var.cluster_parameter_group_name + db_subnet_group_name = var.cluster_db_subnet_group_name + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine = "aurora-mysql" + engine_version = var.cluster_engine_version + master_password = var.cluster_master_password + master_username = var.cluster_master_username + network_type = var.cluster_network_type + port = var.cluster_port + preferred_maintenance_window = var.cluster_preferred_maintenance_window + skip_final_snapshot = var.cluster_skip_final_snapshot + vpc_security_group_ids = var.cluster_vpc_security_group_ids } module "aurora-mysql-instance" { diff --git a/modules/onboard-aws-rds-aurora-mysql-kinesis/variables.tf b/modules/onboard-aws-rds-aurora-mysql-kinesis/variables.tf index 4060872..badd062 100644 --- a/modules/onboard-aws-rds-aurora-mysql-kinesis/variables.tf +++ b/modules/onboard-aws-rds-aurora-mysql-kinesis/variables.tf @@ -47,41 +47,25 @@ variable "aws_kinesis_region" { default = null } -variable "cluster_db_enabled_cloudwatch_logs_exports" { - description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." - type = list(any) - default = null -} - -variable "cluster_db_engine_version" { - description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" - type = string - default = null -} - -variable "cluster_id" { - description = "The name of the Aurora MySQL cluster" - type = string +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" + type = bool + default = true } -variable "cluster_backup_retention" { +variable "cluster_backup_retention_period" { description = "Days to retain backups for, Default is 1 day." type = number - default = null + default = 1 } -variable "cluster_db_master_username" { - description = "Username for the master DB user, must not use rdsadmin as that is reserved." - type = string -} - -variable "cluster_db_master_password" { - description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" +variable "cluster_identifier" { + description = "The name of the Aurora MySQL cluster" type = string } -variable "cluster_network_type" { - description = " Network type of the cluster. Valid values: IPV4, DUAL" +variable "cluster_parameter_group_name" { + description = "Cluster parameter group associated with the cluster" type = string default = null } @@ -92,44 +76,66 @@ variable "cluster_db_subnet_group_name" { default = null } -variable "cluster_vpc_security_group_ids" { - description = "List of VPC security groups to associate." +variable "cluster_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." type = list(any) default = null } -variable "cluster_maintenance_schedule" { - description = "Weekly time range during which system maintenance can occur, in (UTC)." +variable "cluster_engine_version" { + description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" type = string default = null } -variable "cluster_final_snapshot" { - description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" - type = bool +variable "cluster_master_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" + type = string +} + +variable "cluster_master_username" { + description = "Username for the master DB user, must not use rdsadmin as that is reserved." + type = string + validation { + condition = ( + var.cluster_master_username != "rdsadmin" + ) + error_message = "The aurora cluster master username must not be either \"rdsadmin\". Please select another value." + } +} + +variable "cluster_network_type" { + description = " Network type of the cluster. Valid values: IPV4, DUAL" + type = string default = null } -variable "cluster_db_port" { +variable "cluster_port" { description = "Port on which the DB accepts connections." type = number default = null } -variable "cluster_apply_immediately" { - description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" - type = bool +variable "cluster_preferred_maintenance_window" { + description = "Weekly time range during which system maintenance can occur, in (UTC)." + type = string default = null } -variable "cluster_parameter_group_name" { - description = "Cluster parameter group associated with the cluster" - type = string +variable "cluster_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" + type = bool + default = true +} + +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(any) default = null } variable "instance_identifier" { - description = "The name of the aurora mysql cluster instance" + description = "The name of the Aurora MySQL cluster instance" type = string } @@ -225,4 +231,3 @@ variable "stream_mode" { error_message = "Invalid value, select either 'sync' or 'async'." } } - diff --git a/modules/onboard-aws-rds-aurora-mysql-slowquery/main.tf b/modules/onboard-aws-rds-aurora-mysql-slowquery/main.tf index f1c60b7..6f8179c 100644 --- a/modules/onboard-aws-rds-aurora-mysql-slowquery/main.tf +++ b/modules/onboard-aws-rds-aurora-mysql-slowquery/main.tf @@ -12,21 +12,21 @@ module "aurora-mysql-cluster" { depends_on = [module.aurora-mysql-cluster-parameter-group, module.aurora-mysql-log-group] source = "../aws-rds-cluster" - cluster_id = var.cluster_cluster_id - db_engine = var.cluster_db_engine - db_engine_version = var.cluster_db_engine_version - db_port = var.cluster_db_port - backup_retention = var.cluster_backup_retention - maintenance_schedule = var.cluster_maintenance_schedule - final_snapshot = var.cluster_final_snapshot - db_master_username = var.cluster_db_master_username - db_master_password = var.cluster_db_master_password - network_type = var.cluster_network_type - db_subnet_group_name = var.cluster_db_subnet_group_name - vpc_security_group_ids = var.cluster_vpc_security_group_ids - db_enabled_cloudwatch_logs_exports = var.cluster_db_enabled_cloudwatch_logs_exports - parameter_group_name = module.aurora-mysql-cluster-parameter-group.this.name - apply_immediately = var.cluster_apply_immediately + apply_immediately = var.cluster_apply_immediately + backup_retention_period = var.cluster_backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = module.aurora-mysql-cluster-parameter-group.this.name + db_subnet_group_name = var.cluster_db_subnet_group_name + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine = "aurora-mysql" + engine_version = var.cluster_engine_version + master_password = var.cluster_master_password + master_username = var.cluster_master_username + network_type = var.cluster_network_type + port = var.cluster_port + preferred_maintenance_window = var.cluster_preferred_maintenance_window + skip_final_snapshot = var.cluster_skip_final_snapshot + vpc_security_group_ids = var.cluster_vpc_security_group_ids } module "aurora-mysql-instances" { @@ -40,21 +40,21 @@ module "aurora-mysql-instances" { db_instance_class = var.instance_db_instance_class identifier = var.instance_identifier minor_version_upgrade = var.instance_minor_version_upgrade - maintenance_schedule = var.cluster_maintenance_schedule + maintenance_schedule = var.cluster_preferred_maintenance_window publicly_accessible = var.instance_publicly_accessible } module "aurora-mysql-log-group" { source = "../aws-cloudwatch-log-group" - name = "/aws/rds/cluster/${var.cluster_cluster_id}/audit" + name = "/aws/rds/cluster/${var.cluster_identifier}/audit" retention_in_days = var.log_group_retention_in_days } module "aurora-mysql-log-group-slowquery" { source = "../aws-cloudwatch-log-group" - name = "/aws/rds/cluster/${var.cluster_cluster_id}/slowquery" + name = "/aws/rds/cluster/${var.cluster_identifier}/slowquery" retention_in_days = var.log_group_retention_in_days } diff --git a/modules/onboard-aws-rds-aurora-mysql-slowquery/variables.tf b/modules/onboard-aws-rds-aurora-mysql-slowquery/variables.tf index 8930ca3..3208fa6 100644 --- a/modules/onboard-aws-rds-aurora-mysql-slowquery/variables.tf +++ b/modules/onboard-aws-rds-aurora-mysql-slowquery/variables.tf @@ -60,88 +60,90 @@ variable "cluster_parameter_group_tags" { } # Aurora MySQL Cluster variables -variable "cluster_db_enabled_cloudwatch_logs_exports" { - description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." - type = list(any) - default = ["audit", "slowquery"] +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" + type = bool + default = true } -variable "cluster_db_engine" { - description = "Cluster engine i.e, aurora-mysql" - type = string - default = "aurora-mysql" +variable "cluster_backup_retention_period" { + description = "Days to retain backups for, Default is 1 day." + type = number + default = 1 } -variable "cluster_db_engine_version" { - description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" +variable "cluster_identifier" { + description = "The name of the Aurora MySQL cluster" type = string - default = "8.0.mysql_aurora.3.04.1" } -variable "cluster_cluster_id" { - description = "The name of the aurora mysql cluster" +variable "cluster_db_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." type = string + default = null } -variable "cluster_backup_retention" { - description = "Days to retain backups for, Default is 1 day." - type = number - default = 1 +variable "cluster_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." + type = list(any) + default = ["audit", "slowquery"] } -variable "cluster_db_master_username" { - description = "Username for the master DB user, must not use rdsadmin as that is reserved." +variable "cluster_engine_version" { + description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" type = string + default = "8.0.mysql_aurora.3.04.1" } -variable "cluster_db_master_password" { +variable "cluster_master_password" { description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" type = string } -variable "cluster_network_type" { - description = " Network type of the cluster. Valid values: IPV4, DUAL" +variable "cluster_master_username" { + description = "Username for the master DB user, must not use rdsadmin as that is reserved." type = string - default = "IPV4" + validation { + condition = ( + var.cluster_master_username != "rdsadmin" + ) + error_message = "The aurora cluster master username must not be either \"rdsadmin\". Please select another value." + } } -variable "cluster_db_subnet_group_name" { - description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." +variable "cluster_network_type" { + description = " Network type of the cluster. Valid values: IPV4, DUAL" type = string - default = null + default = "IPV4" } -variable "cluster_vpc_security_group_ids" { - description = "List of VPC security groups to associate." - type = list(any) - default = null +variable "cluster_port" { + description = "Port on which the DB accepts connections." + type = number + default = 3306 } -variable "cluster_maintenance_schedule" { +variable "cluster_preferred_maintenance_window" { description = "Weekly time range during which system maintenance can occur, in (UTC)." type = string default = "sun:18:00-sun:21:00" } -variable "cluster_final_snapshot" { +variable "cluster_skip_final_snapshot" { description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" type = bool default = true } -variable "cluster_db_port" { - description = "Port on which the DB accepts connections." - type = number - default = 3306 -} -variable "cluster_apply_immediately" { - description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" - type = bool - default = true + +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(any) + default = null } # Aurora MySQL Instance variables variable "instance_identifier" { - description = "The name of the aurora mysql cluster instance" + description = "The name of the Aurora MySQL cluster instance" type = string } diff --git a/modules/onboard-aws-rds-aurora-mysql/main.tf b/modules/onboard-aws-rds-aurora-mysql/main.tf index af57602..7f7cf6e 100644 --- a/modules/onboard-aws-rds-aurora-mysql/main.tf +++ b/modules/onboard-aws-rds-aurora-mysql/main.tf @@ -12,21 +12,21 @@ module "aurora-mysql-cluster" { depends_on = [module.aurora-mysql-cluster-parameter-group, module.aurora-mysql-log-group] source = "../aws-rds-cluster" - cluster_id = var.cluster_cluster_id - db_engine = "aurora-mysql" - db_engine_version = var.cluster_db_engine_version - db_port = var.cluster_db_port - backup_retention = var.cluster_backup_retention - maintenance_schedule = var.cluster_maintenance_schedule - final_snapshot = var.cluster_final_snapshot - db_master_username = var.cluster_db_master_username - db_master_password = var.cluster_db_master_password - network_type = var.cluster_network_type - db_subnet_group_name = var.cluster_db_subnet_group_name - vpc_security_group_ids = var.cluster_vpc_security_group_ids - db_enabled_cloudwatch_logs_exports = var.cluster_db_enabled_cloudwatch_logs_exports - parameter_group_name = module.aurora-mysql-cluster-parameter-group.this.name - apply_immediately = var.cluster_apply_immediately + apply_immediately = var.cluster_apply_immediately + backup_retention_period = var.cluster_backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = module.aurora-mysql-cluster-parameter-group.this.name + db_subnet_group_name = var.cluster_db_subnet_group_name + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine = "aurora-mysql" + engine_version = var.cluster_engine_version + master_password = var.cluster_master_password + master_username = var.cluster_master_username + network_type = var.cluster_network_type + port = var.cluster_port + preferred_maintenance_window = var.cluster_preferred_maintenance_window + skip_final_snapshot = var.cluster_skip_final_snapshot + vpc_security_group_ids = var.cluster_vpc_security_group_ids } module "aurora-mysql-instances" { @@ -39,7 +39,7 @@ module "aurora-mysql-instances" { db_instance_class = var.instance_db_instance_class db_subnet_group_name = module.aurora-mysql-cluster.this.db_subnet_group_name identifier = var.instance_identifier - maintenance_schedule = var.cluster_maintenance_schedule + maintenance_schedule = var.cluster_preferred_maintenance_window minor_version_upgrade = var.instance_minor_version_upgrade publicly_accessible = var.instance_publicly_accessible } @@ -47,7 +47,7 @@ module "aurora-mysql-instances" { module "aurora-mysql-log-group" { source = "../aws-cloudwatch-log-group" - name = "/aws/rds/cluster/${var.cluster_cluster_id}/audit" + name = "/aws/rds/cluster/${var.cluster_identifier}/audit" retention_in_days = var.log_group_retention_in_days } diff --git a/modules/onboard-aws-rds-aurora-mysql/variables.tf b/modules/onboard-aws-rds-aurora-mysql/variables.tf index df5dc67..60bc4f2 100644 --- a/modules/onboard-aws-rds-aurora-mysql/variables.tf +++ b/modules/onboard-aws-rds-aurora-mysql/variables.tf @@ -48,85 +48,85 @@ variable "cluster_parameter_group_tags" { } # Aurora MySQL Cluster variables -variable "cluster_db_enabled_cloudwatch_logs_exports" { - description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." - type = list(any) - default = ["audit"] +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" + type = bool + default = true } -variable "cluster_db_engine" { - description = "Cluster engine i.e, aurora-mysql" - type = string - default = "aurora-mysql" +variable "cluster_backup_retention_period" { + description = "Days to retain backups for, Default is 1 day." + type = number + default = 1 } -variable "cluster_db_engine_version" { - description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" +variable "cluster_identifier" { + description = "The name of the Aurora MySQL cluster" type = string - default = "8.0.mysql_aurora.3.04.1" } -variable "cluster_cluster_id" { - description = "The name of the aurora mysql cluster" +variable "cluster_db_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." type = string + default = null } -variable "cluster_backup_retention" { - description = "Days to retain backups for, Default is 1 day." - type = number - default = 1 +variable "cluster_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." + type = list(any) + default = ["audit"] } -variable "cluster_db_master_username" { - description = "Username for the master DB user, must not use rdsadmin as that is reserved." +variable "cluster_engine_version" { + description = "Database engine version, i.e. 8.0.mysql_aurora.3.05.1" type = string + default = "8.0.mysql_aurora.3.04.1" } -variable "cluster_db_master_password" { - description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" +variable "cluster_master_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." type = string } -variable "cluster_network_type" { - description = " Network type of the cluster. Valid values: IPV4, DUAL" +variable "cluster_master_username" { + description = "Username for the master DB user, must not use rdsadmin as that is reserved." type = string - default = "IPV4" + validation { + condition = ( + var.cluster_master_username != "rdsadmin" + ) + error_message = "The aurora cluster master username must not be either \"rdsadmin\". Please select another value." + } } -variable "cluster_db_subnet_group_name" { - description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." +variable "cluster_network_type" { + description = " Network type of the cluster. Valid values: IPV4, DUAL" type = string - default = null + default = "IPV4" } -variable "cluster_vpc_security_group_ids" { - description = "List of VPC security groups to associate." - type = list(any) - default = null +variable "cluster_port" { + description = "Port on which the DB accepts connections." + type = number + default = 3306 } -variable "cluster_maintenance_schedule" { +variable "cluster_preferred_maintenance_window" { description = "Weekly time range during which system maintenance can occur, in (UTC)." type = string default = "sun:18:00-sun:21:00" } -variable "cluster_final_snapshot" { +variable "cluster_skip_final_snapshot" { description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" type = bool default = true } -variable "cluster_db_port" { - description = "Port on which the DB accepts connections." - type = number - default = 3306 -} - -variable "cluster_apply_immediately" { - description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" - type = bool - default = true +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(any) + default = null } # Aurora MySQL Instance variables diff --git a/modules/onboard-aws-rds-aurora-postgresql-kinesis/main.tf b/modules/onboard-aws-rds-aurora-postgresql-kinesis/main.tf index 2878a38..2b9f3cd 100644 --- a/modules/onboard-aws-rds-aurora-postgresql-kinesis/main.tf +++ b/modules/onboard-aws-rds-aurora-postgresql-kinesis/main.tf @@ -1,21 +1,21 @@ module "aurora-postgresql-cluster" { source = "../aws-rds-cluster" - apply_immediately = var.cluster_apply_immediately - backup_retention = var.cluster_backup_retention - cluster_id = var.cluster_id - db_enabled_cloudwatch_logs_exports = var.cluster_db_enabled_cloudwatch_logs_exports - db_engine = "aurora-postgresql" - db_engine_version = var.cluster_db_engine_version - db_master_password = var.cluster_db_master_password - db_master_username = var.cluster_db_master_username - db_port = var.cluster_db_port - db_subnet_group_name = var.cluster_db_subnet_group_name - final_snapshot = var.cluster_final_snapshot - maintenance_schedule = var.cluster_maintenance_schedule - network_type = var.cluster_network_type - parameter_group_name = var.cluster_parameter_group_name - vpc_security_group_ids = var.cluster_vpc_security_group_ids + apply_immediately = var.cluster_apply_immediately + backup_retention_period = var.cluster_backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = var.cluster_parameter_group_name + db_subnet_group_name = var.cluster_db_subnet_group_name + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine = "aurora-postgresql" + engine_version = var.cluster_engine_version + master_password = var.cluster_master_password + master_username = var.cluster_master_username + network_type = var.cluster_network_type + port = var.cluster_port + preferred_maintenance_window = var.cluster_preferred_maintenance_window + skip_final_snapshot = var.cluster_skip_final_snapshot + vpc_security_group_ids = var.cluster_vpc_security_group_ids } module "aurora-postgresql-instance" { diff --git a/modules/onboard-aws-rds-aurora-postgresql-kinesis/variables.tf b/modules/onboard-aws-rds-aurora-postgresql-kinesis/variables.tf index fa076ed..2b5f6ea 100644 --- a/modules/onboard-aws-rds-aurora-postgresql-kinesis/variables.tf +++ b/modules/onboard-aws-rds-aurora-postgresql-kinesis/variables.tf @@ -57,96 +57,96 @@ variable "aws_kinesis_region" { default = null } -variable "cluster_db_enabled_cloudwatch_logs_exports" { +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" + type = bool + default = null +} + +variable "cluster_backup_retention_period" { + description = "Days to retain backups for, Default is 1 day." + type = number + default = null +} + +variable "cluster_identifier" { + description = "The name of the Aurora PostgreSQL cluster" + type = string +} + +variable "cluster_parameter_group_name" { + description = "Cluster parameter group associated with the cluster" + type = string + default = null +} + +variable "cluster_db_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string + default = null +} + +variable "cluster_enabled_cloudwatch_logs_exports" { description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." type = list(any) default = null } -variable "cluster_db_engine_version" { +variable "cluster_engine_version" { description = "Database engine version, e.g., 16.1" type = string default = "16.1" } -variable "cluster_id" { - description = "The name of the Aurora PostgreSQL cluster" +variable "cluster_master_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." type = string } -variable "cluster_backup_retention" { - description = "Days to retain backups for, Default is 1 day." - type = number - default = null -} - -variable "cluster_db_master_username" { +variable "cluster_master_username" { description = "Username for the master DB user." type = string validation { condition = ( - var.cluster_db_master_username != "rdsadmin" && - var.cluster_db_master_username != "admin" + var.cluster_master_username != "rdsadmin" && + var.cluster_master_username != "admin" ) error_message = "The aurora cluster master username must not be either \"rdsadmin\" or \"admin\". Please select another value." } } -variable "cluster_db_master_password" { - description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" - type = string -} - variable "cluster_network_type" { description = " Network type of the cluster. Valid values: IPV4, DUAL" type = string default = null } -variable "cluster_db_subnet_group_name" { - description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." - type = string - default = null -} - -variable "cluster_vpc_security_group_ids" { - description = "List of VPC security groups to associate." - type = list(any) +variable "cluster_port" { + description = "Port on which the DB accepts connections." + type = number default = null } -variable "cluster_maintenance_schedule" { +variable "cluster_preferred_maintenance_window" { description = "Weekly time range during which system maintenance can occur, in (UTC)." type = string default = null } -variable "cluster_final_snapshot" { +variable "cluster_skip_final_snapshot" { description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" type = bool - default = null -} - -variable "cluster_db_port" { - description = "Port on which the DB accepts connections." - type = number - default = null -} - -variable "cluster_apply_immediately" { - description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" - type = bool - default = null + default = true } -variable "cluster_parameter_group_name" { - description = "Cluster parameter group associated with the cluster" - type = string +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(any) default = null } variable "instance_identifier" { - description = "The name of the aurora cluster instance" + description = "The name of the Aurora PostgreSQL cluster instance" type = string } diff --git a/modules/onboard-aws-rds-aurora-postgresql/main.tf b/modules/onboard-aws-rds-aurora-postgresql/main.tf index fc282ff..fa67863 100644 --- a/modules/onboard-aws-rds-aurora-postgresql/main.tf +++ b/modules/onboard-aws-rds-aurora-postgresql/main.tf @@ -12,21 +12,21 @@ module "aurora-postgresql-cluster" { depends_on = [module.aurora-postgresql-log-group] source = "../aws-rds-cluster" - apply_immediately = var.cluster_apply_immediately - backup_retention = var.cluster_backup_retention - cluster_id = var.cluster_id - db_enabled_cloudwatch_logs_exports = var.cluster_db_enabled_cloudwatch_logs_exports - db_engine = "aurora-postgresql" - db_engine_version = var.cluster_db_engine_version - db_master_password = var.cluster_db_master_password - db_master_username = var.cluster_db_master_username - db_port = var.cluster_db_port - db_subnet_group_name = var.cluster_db_subnet_group_name - final_snapshot = var.cluster_final_snapshot - maintenance_schedule = var.cluster_maintenance_schedule - network_type = var.cluster_network_type - parameter_group_name = module.aurora-postgresql-cluster-parameter-group.this.name - vpc_security_group_ids = var.cluster_vpc_security_group_ids + apply_immediately = var.cluster_apply_immediately + backup_retention_period = var.cluster_backup_retention_period + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = module.aurora-postgresql-cluster-parameter-group.this.name + db_subnet_group_name = var.cluster_db_subnet_group_name + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine = "aurora-postgresql" + engine_version = var.cluster_engine_version + master_password = var.cluster_master_password + master_username = var.cluster_master_username + network_type = var.cluster_network_type + port = var.cluster_port + preferred_maintenance_window = var.cluster_preferred_maintenance_window + skip_final_snapshot = var.cluster_skip_final_snapshot + vpc_security_group_ids = var.cluster_vpc_security_group_ids } module "aurora-postgresql-instance" { @@ -46,7 +46,7 @@ module "aurora-postgresql-instance" { module "aurora-postgresql-log-group" { source = "../aws-cloudwatch-log-group" - name = "/aws/rds/cluster/${var.cluster_id}/postgresql" + name = "/aws/rds/cluster/${var.cluster_identifier}/postgresql" retention_in_days = var.log_group_retention_in_days } diff --git a/modules/onboard-aws-rds-aurora-postgresql/variables.tf b/modules/onboard-aws-rds-aurora-postgresql/variables.tf index 89872ab..5414565 100644 --- a/modules/onboard-aws-rds-aurora-postgresql/variables.tf +++ b/modules/onboard-aws-rds-aurora-postgresql/variables.tf @@ -56,85 +56,85 @@ variable "aws_log_group_region" { type = string } -variable "cluster_db_enabled_cloudwatch_logs_exports" { +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" + type = bool + default = null +} + +variable "cluster_backup_retention_period" { + description = "Days to retain backups for, Default is 1 day." + type = number + default = null +} + +variable "cluster_identifier" { + description = "The name of the RDS cluster" + type = string +} + +variable "cluster_db_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string + default = null +} + +variable "cluster_enabled_cloudwatch_logs_exports" { description = "Set of log types to enable for exporting to CloudWatch logs. Valid values: audit, error, general, slowquery." type = list(any) default = ["postgresql"] } -variable "cluster_db_engine_version" { +variable "cluster_engine_version" { description = "Database engine version, e.g., 16.1" type = string default = "16.1" } -variable "cluster_id" { - description = "The name of the RDS cluster" +variable "cluster_master_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." type = string } -variable "cluster_backup_retention" { - description = "Days to retain backups for, Default is 1 day." - type = number - default = null -} - -variable "cluster_db_master_username" { +variable "cluster_master_username" { description = "Username for the master DB user." type = string validation { condition = ( - var.cluster_db_master_username != "rdsadmin" && - var.cluster_db_master_username != "admin" + var.cluster_master_username != "rdsadmin" && + var.cluster_master_username != "admin" ) error_message = "The aurora cluster master username must not be either \"rdsadmin\" or \"admin\". Please select another value." } } -variable "cluster_db_master_password" { - description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Cannot be set if manage_master_user_password is set to true" - type = string -} - variable "cluster_network_type" { description = " Network type of the cluster. Valid values: IPV4, DUAL" type = string default = null } -variable "cluster_db_subnet_group_name" { - description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." - type = string - default = null -} - -variable "cluster_vpc_security_group_ids" { - description = "List of VPC security groups to associate." - type = list(any) +variable "cluster_port" { + description = "Port on which the DB accepts connections." + type = number default = null } -variable "cluster_maintenance_schedule" { +variable "cluster_preferred_maintenance_window" { description = "Weekly time range during which system maintenance can occur, in (UTC)." type = string default = null } -variable "cluster_final_snapshot" { +variable "cluster_skip_final_snapshot" { description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier. Default is false" type = bool default = true } -variable "cluster_db_port" { - description = "Port on which the DB accepts connections." - type = number - default = null -} - -variable "cluster_apply_immediately" { - description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is true" - type = bool +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(any) default = null } @@ -200,7 +200,7 @@ variable "cluster_parameter_group_tags" { } variable "instance_identifier" { - description = "The name of the aurora cluster instance" + description = "The name of the Aurora PostgreSQL cluster instance" type = string }