From 5c079781b160e789ccdaa4f45dd9aa0ca4c3bf6d Mon Sep 17 00:00:00 2001 From: Abdul Wahid Date: Thu, 27 Jul 2023 20:05:12 +0100 Subject: [PATCH] Upgrade to 5.x compatibility + update examples/variables (#17) * Upgrade to 5.x compatibility + update examples/variables * lint fixes + add versions to examples --- .pre-commit-config.yaml | 6 +-- CHANGELOG.md | 17 +++++++- README.md | 23 +++++----- examples/aurora-mysql/.terraform.lock.hcl | 45 ++++++++++++++++++++ examples/aurora-mysql/kms.tf | 4 +- examples/aurora-mysql/main.tf | 19 +++------ examples/aurora-mysql/versions.tf | 20 +++++++++ examples/aurora-postgres/.terraform.lock.hcl | 41 ++++++++++++++++++ examples/aurora-postgres/main.tf | 19 ++++----- examples/aurora-postgres/versions.tf | 20 +++++++++ examples/global-aurora-mysql/main.tf | 17 -------- examples/global-aurora-mysql/versions.tf | 30 +++++++++++++ examples/serverless/main.tf | 7 ++- examples/serverless/versions.tf | 20 +++++++++ main.tf | 20 ++++----- outputs.tf | 26 +++++------ variables.tf | 22 ++++------ versions.tf | 16 ++++--- 18 files changed, 269 insertions(+), 103 deletions(-) create mode 100644 examples/aurora-mysql/.terraform.lock.hcl create mode 100644 examples/aurora-mysql/versions.tf create mode 100644 examples/aurora-postgres/.terraform.lock.hcl create mode 100644 examples/aurora-postgres/versions.tf create mode 100644 examples/global-aurora-mysql/versions.tf create mode 100644 examples/serverless/versions.tf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbdf31b..0c1d955 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=500'] @@ -17,8 +17,8 @@ repos: - id: detect-aws-credentials args: ['--allow-missing-credentials'] - id: trailing-whitespace -- repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.50.0 +- repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.81.0 hooks: - id: terraform_fmt - id: terraform_docs diff --git a/CHANGELOG.md b/CHANGELOG.md index 775bc9f..6eed406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Upgrade to 5.x compatibility + update examples/variables + + + +## [3.2.1] - 2021-07-07 + +- Add more cluster instance outputs ([#15](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/15)) + + + +## [3.2.0] - 2021-06-23 + +- Add s3_import option ([#14](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/14)) @@ -96,7 +109,9 @@ All notable changes to this project will be documented in this file. - Initial commit -[Unreleased]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/3.1.0...HEAD +[Unreleased]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/3.2.1...HEAD +[3.2.1]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/3.2.0...3.2.1 +[3.2.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/3.1.0...3.2.0 [3.1.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/3.0.0...3.1.0 [3.0.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.2.0...3.0.0 [2.2.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.1.2...2.2.0 diff --git a/README.md b/README.md index 04b90f8..f594f24 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ module "rds-aurora-mysql" { name_prefix = "example-aurora-mysql" engine = "aurora-mysql" - engine_version = "5.7.mysql_aurora.2.10.0" + engine_version = "8.0.mysql_aurora.3.03.1" deletion_protection = true vpc_id = module.vpc.vpc_id subnets = module.vpc.public_subnets replica_count = 2 - instance_type = "db.t3.medium" + instance_type = "db.t4g.medium" apply_immediately = true skip_final_snapshot = true @@ -71,7 +71,7 @@ module "rds-aurora-mysql" { ## Authors -Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](https://www.linkedin.com/in/marcincuber/). + Module managed by [uMotif](https://github.com/umotif-public/). ## Global Aurora Cluster @@ -88,16 +88,16 @@ In order to activate global cluster, set `enable_global_cluster = true` when usi | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 0.13.0 | +| [terraform](#requirement\_terraform) | >= 1.0.11 | | [aws](#requirement\_aws) | >= 3.15 | -| [random](#requirement\_random) | >= 2.3 | +| [random](#requirement\_random) | >= 3.1.1 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 3.15 | -| [random](#provider\_random) | >= 2.3 | +| [random](#provider\_random) | >= 3.1.1 | ## Modules @@ -135,7 +135,6 @@ No modules. | [allowed\_security\_groups](#input\_allowed\_security\_groups) | A list of Security Group ID's to allow access to. | `list(string)` | `[]` | no | | [apply\_immediately](#input\_apply\_immediately) | Determines whether or not any DB modifications are applied immediately, or during the maintenance window | `bool` | `false` | no | | [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Determines whether minor engine upgrades will be performed automatically in the maintenance window | `bool` | `true` | no | -| [aws\_partition](#input\_aws\_partition) | [Deprecated] A Partition is a group of AWS Region and Service objects. You can use a partition to determine what services are available in a region, or what regions a service is available in. | `string` | `"public"` | no | | [backtrack\_window](#input\_backtrack\_window) | The target backtrack window, in seconds. Only available for aurora engine currently. To disable backtracking, set this value to 0. Defaults to 0. Must be between 0 and 259200 (72 hours) | `number` | `0` | no | | [backup\_retention\_period](#input\_backup\_retention\_period) | How long to keep backups for (in days) | `number` | `7` | no | | [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | The identifier of the CA certificate for the DB instance. | `string` | `"rds-ca-2019"` | no | @@ -156,14 +155,14 @@ No modules. | [enabled\_cloudwatch\_logs\_exports](#input\_enabled\_cloudwatch\_logs\_exports) | List of object which define log types to export to AWS Cloudwatch. See in examples. | `list(any)` | `[]` | no | | [engine](#input\_engine) | Aurora database engine type, currently aurora, aurora-mysql or aurora-postgresql | `string` | `"aurora"` | no | | [engine\_mode](#input\_engine\_mode) | The database engine mode. Valid values: global, parallelquery, provisioned, serverless. | `string` | `"provisioned"` | no | -| [engine\_parameter\_family](#input\_engine\_parameter\_family) | The database engine paramater group family | `string` | `"aurora-mysql5.7"` | no | -| [engine\_version](#input\_engine\_version) | Aurora database engine version. | `string` | `"5.7.mysql_aurora.2.09.0"` | no | +| [engine\_parameter\_family](#input\_engine\_parameter\_family) | The database engine paramater group family | `string` | `"aurora-mysql8.0"` | no | +| [engine\_version](#input\_engine\_version) | Aurora database engine version. | `string` | `"8.0.mysql_aurora.3.03.1"` | no | | [final\_snapshot\_identifier\_prefix](#input\_final\_snapshot\_identifier\_prefix) | The prefix name to use when creating a final snapshot on cluster destroy, appends a random 8 digits to name to ensure it's unique too. | `string` | `"final"` | no | | [global\_cluster\_identifier](#input\_global\_cluster\_identifier) | The global cluster identifier specified on aws\_rds\_global\_cluster | `string` | `""` | no | | [iam\_database\_authentication\_enabled](#input\_iam\_database\_authentication\_enabled) | Specifies whether IAM Database authentication should be enabled or not. Not all versions and instances are supported. Refer to the AWS documentation to see which versions are supported. | `bool` | `true` | no | | [iam\_roles](#input\_iam\_roles) | A List of ARNs for the IAM roles to associate to the RDS Cluster. | `list(string)` | `[]` | no | | [instance\_type](#input\_instance\_type) | Instance type to use | `string` | n/a | yes | -| [instances\_parameters](#input\_instances\_parameters) | Individual settings for instances. | `list` | `[]` | no | +| [instances\_parameters](#input\_instances\_parameters) | Individual settings for instances. | `list(string)` | `[]` | no | | [kms\_key\_id](#input\_kms\_key\_id) | The ARN for the KMS encryption key if one is set to the cluster. | `string` | `null` | no | | [monitoring\_interval](#input\_monitoring\_interval) | The interval (seconds) between points when Enhanced Monitoring metrics are collected. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60. | `number` | `0` | no | | [monitoring\_role\_arn](#input\_monitoring\_role\_arn) | IAM role for RDS to send enhanced monitoring metrics to CloudWatch | `string` | `null` | no | @@ -187,14 +186,14 @@ No modules. | [replica\_scale\_max](#input\_replica\_scale\_max) | Maximum number of replicas to allow scaling for | `number` | `0` | no | | [replica\_scale\_min](#input\_replica\_scale\_min) | Minimum number of replicas to allow scaling for | `number` | `2` | no | | [replica\_scale\_out\_cooldown](#input\_replica\_scale\_out\_cooldown) | Cooldown in seconds before allowing further scaling operations after a scale out | `number` | `300` | no | -| [replication\_source\_identifier](#input\_replication\_source\_identifier) | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. | `any` | `null` | no | +| [replication\_source\_identifier](#input\_replication\_source\_identifier) | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. | `string` | `null` | no | | [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | Restore to point in time configuration. See docs for arguments https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#restore_to_point_in_time-argument-reference | `map(string)` | `{}` | no | | [s3\_import](#input\_s3\_import) | Restore from a Percona XtraBackup stored in S3 bucket. Only Aurora MySQL is supported. | `map(string)` | `null` | no | | [scaling\_configuration](#input\_scaling\_configuration) | Map of nested attributes with scaling properties. Only valid when engine\_mode is set to `serverless` | `map(string)` | `{}` | no | | [security\_group\_description](#input\_security\_group\_description) | The description of the security group. If value is set to empty string it will contain cluster name in the description. | `string` | `""` | no | | [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Should a final snapshot be created on cluster destroy | `bool` | `false` | no | | [snapshot\_identifier](#input\_snapshot\_identifier) | DB snapshot to create this database from | `string` | `null` | no | -| [source\_region](#input\_source\_region) | The source region for an encrypted replica DB cluster. | `any` | `null` | no | +| [source\_region](#input\_source\_region) | The source region for an encrypted replica DB cluster. | `string` | `null` | no | | [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the underlying storage layer should be encrypted | `bool` | `true` | no | | [subnets](#input\_subnets) | List of subnet IDs to use | `list(string)` | `[]` | no | | [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no | diff --git a/examples/aurora-mysql/.terraform.lock.hcl b/examples/aurora-mysql/.terraform.lock.hcl new file mode 100644 index 0000000..defc8fc --- /dev/null +++ b/examples/aurora-mysql/.terraform.lock.hcl @@ -0,0 +1,45 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.9.0" + constraints = ">= 3.15.0, >= 3.53.0, >= 3.55.0" + hashes = [ + "h1:TjctPnxYpg1RZaU1dGW8BSvdmf0t0jsNGU1rEmNIXns=", + "zh:032424d4686ce2ff7c5a4a738491635616afbf6e06b3e7e6a754baa031d1265d", + "zh:1e530b4020544ec94e1fe7b1e4296640eb12cf1bf4f79cd6429ff2c4e6fffaf3", + "zh:24d2eee57a4c78039959dd9bb6dff2b75ed0483d44929550c067c3488307dc62", + "zh:3ad6d736722059664e790a358eacf0e0e60973ec44e70142fb503275de2116c1", + "zh:3f34d81acf86c61ddd271e9c4b8215765037463c3fe3c7aea1dc32a509020cfb", + "zh:65a04aa615fc320059a0871702c83b6be10bce2064056096b46faffe768a698e", + "zh:7fb56c3ce1fe77983627e2931e7c7b73152180c4dfb03e793413d0137c85d6b2", + "zh:90c94cb9d7352468bcd5ba21a56099fe087a072b1936d86f47d54c2a012b708a", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a109c5f01ed48852fe17847fa8a116dfdb81500794a9cf7e5ef92ea6dec20431", + "zh:a27c5396077a36ac2801d4c1c1132201a9225a65bba0e3b3aded9cc18f2c38ff", + "zh:a86ad796ccb0f2cb8f0ca069c774dbf74964edd3282529726816c72e22164b3c", + "zh:bda8afc64091a2a72e0cc38fde937b2163b1b072a5c41310d255901207571afd", + "zh:d22473894cd7e94b7a971793dd07309569f82913a10e4bd6c22e04f362f03bb9", + "zh:f4dbb6d13511290a5274f5b202e6d9997643f86e4c48e8c5e3c204121082851a", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.5.1" + constraints = ">= 3.1.1" + hashes = [ + "h1:IL9mSatmwov+e0+++YX2V6uel+dV6bn+fC/cnGDK3Ck=", + "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64", + "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d", + "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831", + "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3", + "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b", + "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2", + "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865", + "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03", + "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602", + "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014", + ] +} diff --git a/examples/aurora-mysql/kms.tf b/examples/aurora-mysql/kms.tf index bfccb45..2d0d697 100644 --- a/examples/aurora-mysql/kms.tf +++ b/examples/aurora-mysql/kms.tf @@ -82,7 +82,7 @@ data "aws_iam_policy_document" "cloudwatch" { ############# module "kms" { source = "umotif-public/kms/aws" - version = "~> 1.0" + version = "~> 2.0" alias_name = "rds-kms-test-key" deletion_window_in_days = 7 @@ -96,7 +96,7 @@ module "kms" { module "kms-cloudwatch" { source = "umotif-public/kms/aws" - version = "~> 1.0" + version = "~> 2.0" alias_name = "cloudwatch-kms-test-key" deletion_window_in_days = 7 diff --git a/examples/aurora-mysql/main.tf b/examples/aurora-mysql/main.tf index 8d9d350..a9c54f2 100644 --- a/examples/aurora-mysql/main.tf +++ b/examples/aurora-mysql/main.tf @@ -1,10 +1,3 @@ -provider "aws" { - region = "eu-west-1" -} - -data "aws_caller_identity" "current" {} -data "aws_region" "current" {} - ##### # VPC and subnets ##### @@ -12,8 +5,11 @@ data "aws_vpc" "default" { default = true } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id +data "aws_subnets" "all" { + filter { + name = "vpc-id" + values = [data.aws_vpc.default.id] + } } ############# @@ -25,16 +21,15 @@ module "aurora" { name_prefix = "example-aurora-mysql" database_name = "databaseName" engine = "aurora-mysql" - engine_version = "5.7.mysql_aurora.2.09.0" deletion_protection = false vpc_id = data.aws_vpc.default.id - subnets = data.aws_subnet_ids.all.ids + subnets = data.aws_subnets.all.ids kms_key_id = module.kms.key_arn replica_count = 1 - instance_type = "db.t3.medium" + instance_type = "db.t4g.medium" apply_immediately = true allow_major_version_upgrade = true skip_final_snapshot = true diff --git a/examples/aurora-mysql/versions.tf b/examples/aurora-mysql/versions.tf new file mode 100644 index 0000000..d1637c7 --- /dev/null +++ b/examples/aurora-mysql/versions.tf @@ -0,0 +1,20 @@ +provider "aws" { + region = "eu-west-1" +} + +terraform { + required_version = ">= 1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5" + } + + random = { + source = "hashicorp/random" + version = "~> 3" + } + } +} + diff --git a/examples/aurora-postgres/.terraform.lock.hcl b/examples/aurora-postgres/.terraform.lock.hcl new file mode 100644 index 0000000..9ea33a0 --- /dev/null +++ b/examples/aurora-postgres/.terraform.lock.hcl @@ -0,0 +1,41 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "3.55.0" + constraints = ">= 3.15.0, 3.55.0" + hashes = [ + "h1:zK8ot+kDa1EQdmUySWNxgnMJB47oC3m2tOehV56Bjco=", + "zh:1795562df65e9e5a604c90fac17ab1a706bc398b38271a11bc43565d45532595", + "zh:266fd71ace988b5fecd72dae5f2f503e953a4d2ea51d8d490d22d1218b1407dc", + "zh:4b2daf1038352fb33df40a2bf9033f66383bb1f6509df70da08f86f4539df9f3", + "zh:59fa40d453baa15cee845fd62d8c807fc4d5204a5560ee7e54ebeef3a3143404", + "zh:5ad9f515354c654d53849d1193ee56e335b3b9cf8e8cbfa98479114e87089cc3", + "zh:69c3ebd945ce747e0b30315656bc8b4aec2f2486013c2a78d04890bff96d137d", + "zh:6bdb22a77b4d85b6d9f2403bce23d6c3c932dadd7c7541395cbbd51ec101842e", + "zh:7d5ba001be98432d6a1d385679a720cf0d6e6c0b1ee7d45384d2d6213e262b21", + "zh:ce4b85f470605c5cd24f8acfe05c6546d962a32ecf69a61034f0884c2e79fbcf", + "zh:d0b20e4e9e877279520162b7979e9cb8aa961cf06fb37d9f3e4ac7023c177545", + "zh:e029951f18e9dadd8929dddc752a5b354a4c9956b8ec1b67f4db7bc641199d22", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.1.1" + constraints = ">= 3.1.1, 3.1.1" + hashes = [ + "h1:o6mw4IX7BNxtZrTP0cVYxc/5xsTB0LcpQhEHkOyFoXI=", + "zh:04dbe3a562a5da087aca7729332dc4bdba763e71a7a9fcf2b71d38454af8975d", + "zh:23ad79fbd96be6271560cb78855b51129845a1a52edff19f6725f99851e36367", + "zh:34678e44716d76bfad398506757680b3285bf8b2704e0637fcec9c3f3b659f85", + "zh:46c64dfa7c7c48576240cda9a022e84e4a4bd049d22bcb8e5a72b9ceebf24838", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:7b6a9d785c5d1fbd18d3f9f7130ce8a9f3b95ec3e14ba0f1a5ae557f50b2b58a", + "zh:be00333ae3bbb520d205d8dcf7ddb84fad60cbe0104b6f45bb1fa8d37ad1fbfb", + "zh:cce05ea51cb86ca5cc4bd11a6f9d7c0463cdf74bc45bccbdcbc2b3a6c6465248", + "zh:d5d065af722ad73874f952c0a0d75a35e7c58bceba153b2411e869ad41ff0aa8", + "zh:e8e7abadccca7f484f4e8bb4d2639ba3e89efa94f1d456eb5f173f7053127d63", + "zh:f6b9d9947026ea4e7bb9a2e7c4f15a57dbf26d7b3799df24405a3e7bc0d9ea00", + "zh:ff0cfd9c52c724aef6ffda20285b7fb77b6b044f39308a95dc4f993993802bb4", + ] +} diff --git a/examples/aurora-postgres/main.tf b/examples/aurora-postgres/main.tf index 4c5ae5f..2f33d8f 100644 --- a/examples/aurora-postgres/main.tf +++ b/examples/aurora-postgres/main.tf @@ -1,7 +1,3 @@ -provider "aws" { - region = "eu-west-1" -} - ##### # VPC and subnets ##### @@ -9,8 +5,11 @@ data "aws_vpc" "default" { default = true } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id +data "aws_subnets" "all" { + filter { + name = "vpc-id" + values = [data.aws_vpc.default.id] + } } ############# @@ -22,8 +21,8 @@ module "aurora-postgresql" { name_prefix = "example-aurora-postgresql" engine = "aurora-postgresql" - engine_version = "11.8" - engine_parameter_family = "aurora-postgresql11" + engine_version = "15.3" + engine_parameter_family = "aurora-postgresql15" apply_immediately = true allow_major_version_upgrade = true @@ -38,10 +37,10 @@ module "aurora-postgresql" { ] vpc_id = data.aws_vpc.default.id - subnets = data.aws_subnet_ids.all.ids + subnets = data.aws_subnets.all.ids replica_count = 1 - instance_type = "db.t3.medium" + instance_type = "db.t4g.medium" allowed_cidr_blocks = ["10.10.0.0/24", "10.20.0.0/24", "10.30.0.0/24"] diff --git a/examples/aurora-postgres/versions.tf b/examples/aurora-postgres/versions.tf new file mode 100644 index 0000000..d1637c7 --- /dev/null +++ b/examples/aurora-postgres/versions.tf @@ -0,0 +1,20 @@ +provider "aws" { + region = "eu-west-1" +} + +terraform { + required_version = ">= 1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5" + } + + random = { + source = "hashicorp/random" + version = "~> 3" + } + } +} + diff --git a/examples/global-aurora-mysql/main.tf b/examples/global-aurora-mysql/main.tf index f434006..73f323c 100644 --- a/examples/global-aurora-mysql/main.tf +++ b/examples/global-aurora-mysql/main.tf @@ -1,22 +1,5 @@ -provider "aws" { - region = "eu-west-1" - version = ">= 3.14" -} - -provider "aws" { - alias = "primary" - region = "eu-west-1" - version = ">= 3.14" -} - -provider "aws" { - alias = "secondary" - region = "eu-west-2" - version = ">= 3.14" -} data "aws_caller_identity" "current" {} -data "aws_region" "current" {} variable "engine_version" { type = string diff --git a/examples/global-aurora-mysql/versions.tf b/examples/global-aurora-mysql/versions.tf new file mode 100644 index 0000000..d1f6d9c --- /dev/null +++ b/examples/global-aurora-mysql/versions.tf @@ -0,0 +1,30 @@ +provider "aws" { + region = "eu-west-1" +} + +provider "aws" { + alias = "primary" + region = "eu-west-1" +} + +provider "aws" { + alias = "secondary" + region = "eu-west-2" +} + +terraform { + required_version = ">= 1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "3.55" + } + + random = { + source = "hashicorp/random" + version = "3.1.1" + } + } +} + diff --git a/examples/serverless/main.tf b/examples/serverless/main.tf index 6e75654..798c3d9 100644 --- a/examples/serverless/main.tf +++ b/examples/serverless/main.tf @@ -21,16 +21,15 @@ module "aurora-serverless" { name_prefix = "example-aurora-serverless" - engine = "aurora" - engine_mode = "serverless" - engine_parameter_family = "aurora5.6" + engine = "aurora" + engine_mode = "serverless" replica_count = 0 vpc_id = data.aws_vpc.default.id subnets = data.aws_subnet_ids.all.ids - instance_type = "db.t3.medium" + instance_type = "db.t4g.medium" apply_immediately = true skip_final_snapshot = true storage_encrypted = true diff --git a/examples/serverless/versions.tf b/examples/serverless/versions.tf new file mode 100644 index 0000000..3e39a33 --- /dev/null +++ b/examples/serverless/versions.tf @@ -0,0 +1,20 @@ +provider "aws" { + region = "eu-west-1" +} + +terraform { + required_version = ">= 1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.55" + } + + random = { + source = "hashicorp/random" + version = ">= 3.1.1" + } + } +} + diff --git a/main.tf b/main.tf index d4a37cb..e63a0fb 100644 --- a/main.tf +++ b/main.tf @@ -30,7 +30,7 @@ resource "aws_security_group_rule" "main_egress" { to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] - security_group_id = join("", aws_security_group.main.*.id) + security_group_id = aws_security_group.main[0].id } resource "aws_security_group_rule" "main_default_ingress" { @@ -43,7 +43,7 @@ resource "aws_security_group_rule" "main_default_ingress" { to_port = var.enable_global_cluster ? aws_rds_cluster.global[0].port : aws_rds_cluster.main[0].port protocol = "tcp" source_security_group_id = element(var.allowed_security_groups, count.index) - security_group_id = join("", aws_security_group.main.*.id) + security_group_id = aws_security_group.main[0].id } resource "aws_security_group_rule" "main_cidr_ingress" { @@ -56,7 +56,7 @@ resource "aws_security_group_rule" "main_cidr_ingress" { to_port = var.enable_global_cluster ? aws_rds_cluster.global[0].port : aws_rds_cluster.main[0].port protocol = "tcp" cidr_blocks = var.allowed_cidr_blocks - security_group_id = join("", aws_security_group.main.*.id) + security_group_id = aws_security_group.main[0].id } ##### @@ -127,8 +127,8 @@ resource "aws_rds_cluster" "main" { apply_immediately = var.apply_immediately port = var.port == "" ? var.engine == "aurora-postgresql" ? "5432" : "3306" : var.port - db_subnet_group_name = var.db_subnet_group_name == "" ? join("", aws_db_subnet_group.main.*.name) : var.db_subnet_group_name - vpc_security_group_ids = compact(concat(aws_security_group.main.*.id, var.vpc_security_group_ids)) + db_subnet_group_name = var.db_subnet_group_name == "" ? aws_db_subnet_group.main[0].name : var.db_subnet_group_name + vpc_security_group_ids = compact(concat(aws_security_group.main[0].id, var.vpc_security_group_ids)) storage_encrypted = var.storage_encrypted db_cluster_parameter_group_name = var.create_parameter_group ? aws_rds_cluster_parameter_group.main[0].id : var.db_cluster_parameter_group_name @@ -221,8 +221,8 @@ resource "aws_rds_cluster" "global" { apply_immediately = var.apply_immediately port = var.port == "" ? var.engine == "aurora-postgresql" ? "5432" : "3306" : var.port - db_subnet_group_name = var.db_subnet_group_name == "" ? join("", aws_db_subnet_group.main.*.name) : var.db_subnet_group_name - vpc_security_group_ids = compact(concat(aws_security_group.main.*.id, var.vpc_security_group_ids)) + db_subnet_group_name = var.db_subnet_group_name == "" ? aws_db_subnet_group.main[0].name : var.db_subnet_group_name + vpc_security_group_ids = compact(concat(aws_security_group.main[0].id, var.vpc_security_group_ids)) storage_encrypted = var.storage_encrypted db_cluster_parameter_group_name = var.create_parameter_group ? aws_rds_cluster_parameter_group.main[0].id : var.db_cluster_parameter_group_name @@ -292,13 +292,13 @@ resource "aws_rds_cluster_instance" "main" { publicly_accessible = var.publicly_accessible - db_subnet_group_name = var.db_subnet_group_name == "" ? join("", aws_db_subnet_group.main.*.name) : var.db_subnet_group_name + db_subnet_group_name = var.db_subnet_group_name == "" ? aws_db_subnet_group.main[0].name : var.db_subnet_group_name db_parameter_group_name = var.create_parameter_group ? aws_db_parameter_group.main[0].id : var.db_parameter_group_name preferred_maintenance_window = var.preferred_instance_maintenance_window apply_immediately = var.apply_immediately - monitoring_role_arn = var.create_monitoring_role ? join("", aws_iam_role.rds_enhanced_monitoring.*.arn) : var.monitoring_role_arn + monitoring_role_arn = var.create_monitoring_role ? aws_iam_role.rds_enhanced_monitoring[0].arn : var.monitoring_role_arn monitoring_interval = var.monitoring_interval auto_minor_version_upgrade = var.auto_minor_version_upgrade performance_insights_enabled = var.performance_insights_enabled @@ -397,7 +397,7 @@ EOF resource "aws_iam_role_policy_attachment" "rds_enhanced_monitoring" { count = var.create_monitoring_role && var.monitoring_interval > 0 ? 1 : 0 - role = join("", aws_iam_role.rds_enhanced_monitoring.*.name) + role = aws_iam_role.rds_enhanced_monitoring[0].name policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" } diff --git a/outputs.tf b/outputs.tf index d435c1c..fb97429 100644 --- a/outputs.tf +++ b/outputs.tf @@ -3,43 +3,43 @@ ##### output "rds_cluster_arn" { description = "The ID of the aurora cluster" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.arn) : join("", aws_rds_cluster.main.*.arn) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].arn : aws_rds_cluster.main[0].arn } output "rds_cluster_id" { description = "The ID of the cluster" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.id) : join("", aws_rds_cluster.main.*.id) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].id : aws_rds_cluster.main[0].id } output "rds_cluster_resource_id" { description = "The Resource ID of the cluster" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.cluster_resource_id) : join("", aws_rds_cluster.main.*.cluster_resource_id) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].cluster_resource_id : aws_rds_cluster.main[0].cluster_resource_id } output "rds_cluster_endpoint" { description = "The cluster endpoint" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.endpoint) : join("", aws_rds_cluster.main.*.endpoint) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].endpoint : aws_rds_cluster.main[0].endpoint } output "rds_cluster_reader_endpoint" { description = "The cluster reader endpoint" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.reader_endpoint) : join("", aws_rds_cluster.main.*.reader_endpoint) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].reader_endpoint : aws_rds_cluster.main[0].reader_endpoint } output "rds_cluster_master_password" { description = "The master password" - value = var.enable_global_cluster ? aws_rds_cluster.global.*.master_password : aws_rds_cluster.main.*.master_password + value = var.enable_global_cluster ? aws_rds_cluster.global[0].master_password : aws_rds_cluster.main[0].master_password sensitive = true } output "rds_cluster_port" { description = "The port" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.port) : join("", aws_rds_cluster.main.*.port) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].port : aws_rds_cluster.main[0].port } output "rds_cluster_master_username" { description = "The master username" - value = var.enable_global_cluster ? join("", aws_rds_cluster.global.*.master_username) : join("", aws_rds_cluster.main.*.master_username) + value = var.enable_global_cluster ? aws_rds_cluster.global[0].master_username : aws_rds_cluster.main[0].master_username } ##### @@ -47,26 +47,26 @@ output "rds_cluster_master_username" { ##### output "rds_cluster_instance_endpoints" { description = "A list of all cluster instance endpoints" - value = aws_rds_cluster_instance.main.*.endpoint + value = aws_rds_cluster_instance.main[*].endpoint } output "rds_cluster_instance_arns" { description = "A list of all cluster instance ARNs" - value = aws_rds_cluster_instance.main.*.arn + value = aws_rds_cluster_instance.main[*].arn } output "rds_cluster_instance_ids" { description = "A list of all cluster instance ids" - value = aws_rds_cluster_instance.main.*.id + value = aws_rds_cluster_instance.main[*].id } output "rds_cluster_instance_dbi_resource_ids" { description = "A list of all the region-unique, immutable identifiers for the DB instances" - value = aws_rds_cluster_instance.main.*.dbi_resource_id + value = aws_rds_cluster_instance.main[*].dbi_resource_id } output "security_group_id" { description = "The security group ID of the cluster" - value = join("", aws_security_group.main.*.id) + value = aws_security_group.main[0].id } diff --git a/variables.tf b/variables.tf index 0b62622..8f25796 100644 --- a/variables.tf +++ b/variables.tf @@ -24,6 +24,7 @@ variable "subnets" { variable "replica_count" { description = "Number of reader nodes to create. If `replica_scale_enable` is `true`, the value of `replica_scale_min` is used instead." default = 1 + type = number } variable "allowed_security_groups" { @@ -177,12 +178,13 @@ variable "engine" { variable "engine_version" { description = "Aurora database engine version." type = string - default = "5.7.mysql_aurora.2.09.0" + default = "8.0.mysql_aurora.3.03.1" } variable "engine_parameter_family" { description = "The database engine paramater group family" - default = "aurora-mysql5.7" + default = "aurora-mysql8.0" + type = string } variable "enable_http_endpoint" { @@ -278,11 +280,13 @@ variable "engine_mode" { variable "replication_source_identifier" { description = "ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica." default = null + type = string } variable "source_region" { description = "The source region for an encrypted replica DB cluster." default = null + type = string } variable "vpc_security_group_ids" { @@ -300,6 +304,7 @@ variable "db_subnet_group_name" { variable "predefined_metric_type" { description = "The metric type to scale on. Valid values are RDSReaderAverageCPUUtilization and RDSReaderAverageDatabaseConnections." default = "RDSReaderAverageCPUUtilization" + type = string } variable "backtrack_window" { @@ -335,6 +340,7 @@ variable "ca_cert_identifier" { variable "instances_parameters" { description = "Individual settings for instances." default = [] + type = list(string) } variable "preferred_cluster_maintenance_window" { @@ -410,18 +416,6 @@ variable "restore_to_point_in_time" { default = {} } -variable "aws_partition" { - type = string - default = "public" - - description = "[Deprecated] A Partition is a group of AWS Region and Service objects. You can use a partition to determine what services are available in a region, or what regions a service is available in." - - validation { - condition = contains(["public", "china"], var.aws_partition) - error_message = "Argument \"aws_partition\" must be either \"public\" or \"china\"." - } -} - variable "s3_import" { description = "Restore from a Percona XtraBackup stored in S3 bucket. Only Aurora MySQL is supported." type = map(string) diff --git a/versions.tf b/versions.tf index f637b2e..8cdf1ba 100644 --- a/versions.tf +++ b/versions.tf @@ -1,9 +1,15 @@ terraform { - required_version = ">= 0.13.0" + required_version = ">= 1.0.11" required_providers { - aws = ">= 3.15" - random = ">= 2.3" - } -} + aws = { + source = "hashicorp/aws" + version = ">= 3.15" + } + random = { + source = "hashicorp/random" + version = ">= 3.1.1" + } + } +} \ No newline at end of file