From fd74df494469851d5c460a578d5c28fc0a649c5a Mon Sep 17 00:00:00 2001 From: Marcin Cuber Date: Mon, 8 Mar 2021 10:02:46 +0000 Subject: [PATCH] Add support for China partition (#11) --- .pre-commit-config.yaml | 4 ++-- CHANGELOG.md | 53 +++++++++++++++++++++++++++++++++++++++-- README.md | 11 +++++---- main.tf | 2 +- variables.tf | 14 ++++++++++- versions.tf | 2 +- 6 files changed, 74 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c6d2a3..ac1acdf 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: v3.3.0 + rev: v3.4.0 hooks: - id: check-added-large-files args: ['--maxkb=500'] @@ -18,7 +18,7 @@ repos: args: ['--allow-missing-credentials'] - id: trailing-whitespace - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.45.0 + rev: v1.47.0 hooks: - id: terraform_fmt - id: terraform_docs diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e2aa8..e262ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,49 @@ All notable changes to this project will be documented in this file. ## [Unreleased] -- Add licecycle to ignore changes for engine_version +- Update README.md + + + +## [2.2.0] - 2020-12-02 + +- Feature/upgrades ([#10](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/10)) + + + +## [2.1.2] - 2020-11-10 + +- Fix audit log group creation ([#9](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/9)) + + + +## [2.1.1] - 2020-11-10 + +- Fix rds_cluster_instance_endpoints output ([#8](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/8)) + + + +## [2.1.0] - 2020-11-09 + +- Add support for global clusters ([#7](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/7)) + + + +## [2.0.1] - 2020-10-13 + +- Update main.tf ([#6](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/6)) + + + +## [2.0.0] - 2020-09-29 + +- Add support for parameter groups and variables ([#5](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/5)) + + + +## [1.2.2] - 2020-08-27 + +- Fix/cluster instance lifecycle ([#4](https://github.com/umotif-public/terraform-aws-rds-aurora/issues/4)) @@ -42,7 +84,14 @@ 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/1.2.1...HEAD +[Unreleased]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.2.0...HEAD +[2.2.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.1.2...2.2.0 +[2.1.2]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.1.1...2.1.2 +[2.1.1]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.1.0...2.1.1 +[2.1.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.0.1...2.1.0 +[2.0.1]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/2.0.0...2.0.1 +[2.0.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/1.2.2...2.0.0 +[1.2.2]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/1.2.1...1.2.2 [1.2.1]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/1.2.0...1.2.1 [1.2.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/1.1.0...1.2.0 [1.1.0]: https://github.com/umotif-public/terraform-aws-rds-aurora/compare/1.0.1...1.1.0 diff --git a/README.md b/README.md index 48a56cd..555b099 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,18 @@ Terraform module which creates AWS RDS Aurora resources. It supports MySQL, Post ## Terraform versions -Terraform 0.12. Pin module version to `~> v2.0`. Submit pull-requests to `master` branch. +Terraform 0.13. Pin module version to `~> v3.0`. Submit pull-requests to `master` branch. ## Usage ```hcl module "rds-aurora-mysql" { source = "umotif-public/rds-aurora/aws" - version = "~> 2.0.0" + version = "~> 3.0.0" name_prefix = "example-aurora-mysql" engine = "aurora-mysql" - engine_version = "5.7.mysql_aurora.2.09.0" + engine_version = "5.7.mysql_aurora.2.09.2" deletion_protection = true vpc_id = module.vpc.vpc_id @@ -92,7 +92,7 @@ In order to activate global cluster, set `enable_global_cluster = true` when usi | Name | Version | |------|---------| -| terraform | >= 0.12.6 | +| terraform | >= 0.13.0 | | aws | >= 3.15 | | random | >= 2.3 | @@ -112,6 +112,7 @@ In order to activate global cluster, set `enable_global_cluster = true` when usi | allowed\_security\_groups | A list of Security Group ID's to allow access to. | `list(string)` | `[]` | no | | apply\_immediately | Determines whether or not any DB modifications are applied immediately, or during the maintenance window | `bool` | `false` | no | | auto\_minor\_version\_upgrade | Determines whether minor engine upgrades will be performed automatically in the maintenance window | `bool` | `true` | no | +| aws\_partition | 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 | 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 | How long to keep backups for (in days) | `number` | `7` | no | | ca\_cert\_identifier | The identifier of the CA certificate for the DB instance. | `string` | `"rds-ca-2019"` | no | @@ -129,7 +130,7 @@ In order to activate global cluster, set `enable_global_cluster = true` when usi | deletion\_protection | If the DB instance should have deletion protection enabled | `bool` | `false` | no | | enable\_global\_cluster | Set this variable to `true` if DB Cluster is going to be part of a Global Cluster. | `bool` | `false` | no | | enable\_http\_endpoint | Whether or not to enable the Data API for a serverless Aurora database engine. | `bool` | `false` | no | -| enabled\_cloudwatch\_logs\_exports | List of object which define log types to export to AWS Cloudwatch. See in examples. | `list` | `[]` | no | +| enabled\_cloudwatch\_logs\_exports | List of object which define log types to export to AWS Cloudwatch. See in examples. | `list(any)` | `[]` | no | | engine | Aurora database engine type, currently aurora, aurora-mysql or aurora-postgresql | `string` | `"aurora"` | no | | engine\_mode | The database engine mode. Valid values: global, parallelquery, provisioned, serverless. | `string` | `"provisioned"` | no | | engine\_parameter\_family | The database engine paramater group family | `string` | `"aurora-mysql5.7"` | no | diff --git a/main.tf b/main.tf index 1ffebad..0083d5a 100644 --- a/main.tf +++ b/main.tf @@ -375,7 +375,7 @@ 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) - policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" + policy_arn = var.aws_partition == "china" ? "arn:aws-cn:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" : "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" } resource "aws_cloudwatch_log_group" "audit_log_group" { diff --git a/variables.tf b/variables.tf index feb0677..0876c4b 100644 --- a/variables.tf +++ b/variables.tf @@ -259,7 +259,7 @@ variable "iam_database_authentication_enabled" { variable "enabled_cloudwatch_logs_exports" { description = "List of object which define log types to export to AWS Cloudwatch. See in examples." - type = list + type = list(any) default = [] } @@ -409,3 +409,15 @@ variable "restore_to_point_in_time" { type = map(string) default = {} } + +variable "aws_partition" { + type = string + default = "public" + + description = "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\"." + } +} diff --git a/versions.tf b/versions.tf index 6fcd0de..f637b2e 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.13.0" required_providers { aws = ">= 3.15"