diff --git a/.gitignore b/.gitignore index 397af32..317fbb4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ override.tf.json # Ignore CLI configuration files .terraformrc terraform.rc + +# S3 import example +backup diff --git a/README.md b/README.md index fd05f6e..4211b57 100644 --- a/README.md +++ b/README.md @@ -22,28 +22,28 @@ module "db" { source = "terraform-aws-modules/rds-aurora/aws" version = "~> 3.0" - name = "test-aurora-db-postgres96" + name = "test-aurora-db-postgres96" + engine = "aurora-postgresql" + engine_version = "11.9" + instance_type = "db.r5.large" - engine = "aurora-postgresql" - engine_version = "9.6.9" + vpc_id = "vpc-12345678" + subnets = ["subnet-12345678", "subnet-87654321"] - vpc_id = "vpc-12345678" - subnets = ["subnet-12345678", "subnet-87654321"] + replica_count = 1 + allowed_security_groups = ["sg-12345678"] + allowed_cidr_blocks = ["10.20.0.0/20"] - replica_count = 1 - allowed_security_groups = ["sg-12345678"] - allowed_cidr_blocks = ["10.20.0.0/20"] - instance_type = "db.r4.large" - storage_encrypted = true - apply_immediately = true - monitoring_interval = 10 + storage_encrypted = true + apply_immediately = true + monitoring_interval = 10 db_parameter_group_name = "default" db_cluster_parameter_group_name = "default" - enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] + enabled_cloudwatch_logs_exports = ["postgresql"] - tags = { + tags = { Environment = "dev" Terraform = "true" } @@ -67,11 +67,12 @@ module "db" { ## Examples -- [PostgreSQL](examples/postgresql): A simple example with VPC and PostgreSQL cluster. -- [MySQL](examples/mysql): A simple example with VPC and MySQL cluster. -- [Serverless](examples/serverless): Serverless PostgreSQL cluster. -- [Advanced](examples/advanced): A PostgreSQL cluster with enhanced monitoring and autoscaling enabled. -- [Custom Instance Settings](examples/custom_instance_settings): A PostgreSQL cluster with custom instance settings. +- [Autoscaling](examples/autoscaling): A PostgreSQL cluster with enhanced monitoring and autoscaling enabled +- [Custom Instance Settings](examples/custom_instance_settings): A PostgreSQL cluster with multiple replics configured using custom settings +- [MySQL](examples/mysql): A simple MySQL cluster +- [PostgreSQL](examples/postgresql): A simple PostgreSQL cluster +- [S3 Import](examples/s3_import): A MySQL cluster created from a Percona Xtrabackup stored in S3 +- [Serverless](examples/serverless): Serverless PostgreSQL and MySQL clusters ## Documentation @@ -82,7 +83,7 @@ Terraform documentation is generated automatically using [pre-commit hooks](http | Name | Version | |------|---------| -| terraform | >= 0.12.6 | +| terraform | >= 0.12.26 | | aws | >= 3.8 | | random | >= 2.2 | diff --git a/examples/advanced/main.tf b/examples/advanced/main.tf deleted file mode 100644 index 7d189f8..0000000 --- a/examples/advanced/main.tf +++ /dev/null @@ -1,69 +0,0 @@ -provider "aws" { - region = "us-east-1" -} - -###################################### -# Data sources to get VPC and subnets -###################################### -data "aws_vpc" "default" { - default = true -} - -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id -} - -############# -# RDS Aurora -############# -module "aurora" { - source = "../../" - name = "aurora-example" - engine = "aurora-postgresql" - engine_version = "10.4" - subnets = data.aws_subnet_ids.all.ids - vpc_id = data.aws_vpc.default.id - replica_count = 1 - replica_scale_enabled = true - replica_scale_min = 1 - replica_scale_max = 5 - monitoring_interval = 60 - instance_type = "db.r4.large" - instance_type_replica = "db.t3.large" - apply_immediately = true - skip_final_snapshot = true - db_parameter_group_name = aws_db_parameter_group.aurora_db_postgres96_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_postgres96_parameter_group.id - # enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] -} - -resource "aws_db_parameter_group" "aurora_db_postgres96_parameter_group" { - name = "test-aurora-db-postgres10-parameter-group" - family = "aurora-postgresql10" - description = "test-aurora-db-postgres10-parameter-group" -} - -resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres96_parameter_group" { - name = "test-aurora-postgres10-cluster-parameter-group" - family = "aurora-postgresql10" - description = "test-aurora-postgres10-cluster-parameter-group" -} - -############################ -# Example of security group -############################ -resource "aws_security_group" "app_servers" { - name = "app-servers" - description = "For application servers" - vpc_id = data.aws_vpc.default.id -} - -resource "aws_security_group_rule" "allow_access" { - type = "ingress" - from_port = module.aurora.this_rds_cluster_port - to_port = module.aurora.this_rds_cluster_port - protocol = "tcp" - source_security_group_id = aws_security_group.app_servers.id - security_group_id = module.aurora.this_security_group_id -} - diff --git a/examples/advanced/versions.tf b/examples/advanced/versions.tf deleted file mode 100644 index 23fd6a3..0000000 --- a/examples/advanced/versions.tf +++ /dev/null @@ -1,7 +0,0 @@ -terraform { - required_version = ">= 0.12.6" - - required_providers { - aws = ">= 3.8" - } -} diff --git a/examples/autoscaling/README.md b/examples/autoscaling/README.md new file mode 100644 index 0000000..02e47bf --- /dev/null +++ b/examples/autoscaling/README.md @@ -0,0 +1,65 @@ +# Autoscaling Example + +Configuration in this directory creates an Aurora cluster with autoscaling enabled. + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. + + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12.26 | +| aws | >= 3.8 | + +## Providers + +| Name | Version | +|------|---------| +| aws | >= 3.8 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| aurora | ../../ | | +| disabled_aurora | ../../ | | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | + +## Resources + +| Name | +|------| +| [aws_db_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | +| [aws_rds_cluster_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | + +## Inputs + +No input. + +## Outputs + +| Name | Description | +|------|-------------| +| this\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| this\_rds\_cluster\_endpoint | The cluster endpoint | +| this\_rds\_cluster\_id | The ID of the cluster | +| this\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| this\_rds\_cluster\_instance\_ids | A list of all cluster instance ids | +| this\_rds\_cluster\_master\_password | The master password | +| this\_rds\_cluster\_master\_username | The master username | +| this\_rds\_cluster\_port | The port | +| this\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| this\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| this\_security\_group\_id | The security group ID of the cluster | + diff --git a/examples/autoscaling/main.tf b/examples/autoscaling/main.tf new file mode 100644 index 0000000..ce1a4de --- /dev/null +++ b/examples/autoscaling/main.tf @@ -0,0 +1,86 @@ +provider "aws" { + region = local.region +} + +locals { + name = "advanced" + region = "eu-west-1" + tags = { + Owner = "user" + Environment = "dev" + } +} + +################################################################################ +# Supporting Resources +################################################################################ + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 2" + + name = local.name + cidr = "10.99.0.0/18" + + azs = ["${local.region}a", "${local.region}b", "${local.region}c"] + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] + + tags = local.tags +} + +################################################################################ +# RDS Aurora Module +################################################################################ + +module "aurora" { + source = "../../" + + name = local.name + engine = "aurora-postgresql" + engine_version = "11.9" + instance_type = "db.r5.large" + instance_type_replica = "db.t3.large" + + vpc_id = module.vpc.vpc_id + db_subnet_group_name = module.vpc.database_subnet_group_name + create_security_group = true + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks + + replica_count = 1 + replica_scale_enabled = true + replica_scale_min = 1 + replica_scale_max = 5 + + monitoring_interval = 60 + + apply_immediately = true + skip_final_snapshot = true + + db_parameter_group_name = aws_db_parameter_group.example.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id + enabled_cloudwatch_logs_exports = ["postgresql"] + + tags = local.tags +} + +resource "aws_db_parameter_group" "example" { + name_prefix = "${local.name}-aurora-db-postgres11-parameter-group" + family = "aurora-postgresql11" + description = "${local.name}-aurora-db-postgres11-parameter-group" + tags = local.tags +} + +resource "aws_rds_cluster_parameter_group" "example" { + name_prefix = "${local.name}-aurora-postgres11-cluster-parameter-group" + family = "aurora-postgresql11" + description = "${local.name}-aurora-postgres11-cluster-parameter-group" + tags = local.tags +} + +module "disabled_aurora" { + source = "../../" + + create_cluster = false +} diff --git a/examples/advanced/outputs.tf b/examples/autoscaling/outputs.tf similarity index 100% rename from examples/advanced/outputs.tf rename to examples/autoscaling/outputs.tf diff --git a/examples/advanced/variables.tf b/examples/autoscaling/variables.tf similarity index 100% rename from examples/advanced/variables.tf rename to examples/autoscaling/variables.tf diff --git a/examples/autoscaling/versions.tf b/examples/autoscaling/versions.tf new file mode 100644 index 0000000..b5267ef --- /dev/null +++ b/examples/autoscaling/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 0.12.26" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } + } +} diff --git a/examples/custom_instance_settings/README.md b/examples/custom_instance_settings/README.md new file mode 100644 index 0000000..7d83073 --- /dev/null +++ b/examples/custom_instance_settings/README.md @@ -0,0 +1,63 @@ +# Custom Instance Settings Example + +Configuration in this directory creates an Aurora cluster with multiple replicas configured through custom settings. + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. + + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12.26 | +| aws | >= 3.8 | + +## Providers + +| Name | Version | +|------|---------| +| aws | >= 3.8 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| aurora | ../../ | | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | + +## Resources + +| Name | +|------| +| [aws_db_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | +| [aws_rds_cluster_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | + +## Inputs + +No input. + +## Outputs + +| Name | Description | +|------|-------------| +| this\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| this\_rds\_cluster\_endpoint | The cluster endpoint | +| this\_rds\_cluster\_id | The ID of the cluster | +| this\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| this\_rds\_cluster\_master\_password | The master password | +| this\_rds\_cluster\_master\_username | The master username | +| this\_rds\_cluster\_port | The port | +| this\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| this\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| this\_security\_group\_id | The security group ID of the cluster | + diff --git a/examples/custom_instance_settings/main.tf b/examples/custom_instance_settings/main.tf index bce831c..c515911 100644 --- a/examples/custom_instance_settings/main.tf +++ b/examples/custom_instance_settings/main.tf @@ -1,36 +1,64 @@ provider "aws" { - region = "us-east-1" + region = local.region } -###################################### -# Data sources to get VPC and subnets -###################################### -data "aws_vpc" "default" { - default = true +locals { + name = "custom-instance-settings" + region = "eu-west-1" + tags = { + Owner = "user" + Environment = "dev" + } } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id +################################################################################ +# Supporting Resources +################################################################################ + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 2" + + name = local.name + cidr = "10.99.0.0/18" + + azs = ["${local.region}a", "${local.region}b", "${local.region}c"] + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] + + enable_dns_hostnames = true + enable_dns_support = true + + tags = local.tags } -############# -# RDS Aurora -############# +################################################################################ +# RDS Aurora Module +################################################################################ + module "aurora" { - source = "../../" - name = "aurora-example-postgresql" - engine = "aurora-postgresql" - engine_version = "11.6" - subnets = data.aws_subnet_ids.all.ids - vpc_id = data.aws_vpc.default.id - replica_count = 3 - instance_type = "db.r5.large" - apply_immediately = true - skip_final_snapshot = true - db_parameter_group_name = aws_db_parameter_group.aurora_db_postgres11_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_postgres11_parameter_group.id - # enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] + source = "../../" + + name = local.name + engine = "aurora-postgresql" + engine_version = "11.9" + instance_type = "db.r5.large" + + vpc_id = module.vpc.vpc_id + db_subnet_group_name = module.vpc.database_subnet_group_name + create_security_group = true security_group_description = "" + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks + + replica_count = 3 + + apply_immediately = true + skip_final_snapshot = true + + db_parameter_group_name = aws_db_parameter_group.example.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id + enabled_cloudwatch_logs_exports = ["postgresql"] instances_parameters = [ # List index should be equal to `replica_count` @@ -48,34 +76,20 @@ module "aurora" { instance_promotion_tier = 15 } ] -} -resource "aws_db_parameter_group" "aurora_db_postgres11_parameter_group" { - name = "test-aurora-db-postgres11-parameter-group" - family = "aurora-postgresql11" - description = "test-aurora-db-postgres11-parameter-group" + tags = local.tags } -resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres11_parameter_group" { - name = "test-aurora-postgres11-cluster-parameter-group" +resource "aws_db_parameter_group" "example" { + name = "${local.name}-aurora-db-postgres11-parameter-group" family = "aurora-postgresql11" - description = "test-aurora-postgres11-cluster-parameter-group" -} - -############################ -# Example of security group -############################ -resource "aws_security_group" "app_servers" { - name_prefix = "app-servers-" - description = "For application servers" - vpc_id = data.aws_vpc.default.id + description = "${local.name}-aurora-db-postgres11-parameter-group" + tags = local.tags } -resource "aws_security_group_rule" "allow_access" { - type = "ingress" - from_port = module.aurora.this_rds_cluster_port - to_port = module.aurora.this_rds_cluster_port - protocol = "tcp" - source_security_group_id = aws_security_group.app_servers.id - security_group_id = module.aurora.this_security_group_id +resource "aws_rds_cluster_parameter_group" "example" { + name = "${local.name}-aurora-postgres11-cluster-parameter-group" + family = "aurora-postgresql11" + description = "${local.name}-aurora-postgres11-cluster-parameter-group" + tags = local.tags } diff --git a/examples/custom_instance_settings/versions.tf b/examples/custom_instance_settings/versions.tf index 23fd6a3..b5267ef 100644 --- a/examples/custom_instance_settings/versions.tf +++ b/examples/custom_instance_settings/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { - aws = ">= 3.8" + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } } } diff --git a/examples/mysql/README.md b/examples/mysql/README.md new file mode 100644 index 0000000..67e854d --- /dev/null +++ b/examples/mysql/README.md @@ -0,0 +1,67 @@ +# MySQL Example + +Configuration in this directory creates a MySQL Aurora cluster. + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. + + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12.26 | +| aws | >= 3.8 | +| random | >= 2.2 | + +## Providers + +| Name | Version | +|------|---------| +| aws | >= 3.8 | +| random | >= 2.2 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| aurora | ../../ | | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | + +## Resources + +| Name | +|------| +| [aws_db_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | +| [aws_rds_cluster_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | +| [random_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | + +## Inputs + +No input. + +## Outputs + +| Name | Description | +|------|-------------| +| this\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| this\_rds\_cluster\_endpoint | The cluster endpoint | +| this\_rds\_cluster\_id | The ID of the cluster | +| this\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| this\_rds\_cluster\_instance\_ids | A list of all cluster instance ids | +| this\_rds\_cluster\_master\_password | The master password | +| this\_rds\_cluster\_master\_username | The master username | +| this\_rds\_cluster\_port | The port | +| this\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| this\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| this\_security\_group\_id | The security group ID of the cluster | + diff --git a/examples/mysql/main.tf b/examples/mysql/main.tf index 08cbd66..b741d7b 100644 --- a/examples/mysql/main.tf +++ b/examples/mysql/main.tf @@ -1,101 +1,82 @@ provider "aws" { - region = "us-east-1" + region = local.region } -###################################### -# Data sources to get VPC and subnets -###################################### -data "aws_vpc" "default" { - default = true +locals { + name = "mysql" + region = "eu-west-1" + tags = { + Owner = "user" + Environment = "dev" + } } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id +################################################################################ +# Supporting Resources +################################################################################ + +resource "random_password" "master" { + length = 10 } -############# -# RDS Aurora -############# -module "aurora" { - source = "../../" - name = "aurora-example-mysql" - engine = "aurora-mysql" - engine_version = "5.7.12" - subnets = data.aws_subnet_ids.all.ids - vpc_id = data.aws_vpc.default.id - replica_count = 0 - instance_type = "db.t2.medium" - password = random_password.master.result - create_random_password = false - apply_immediately = true - skip_final_snapshot = true - db_parameter_group_name = aws_db_parameter_group.aurora_db_57_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_57_cluster_parameter_group.id - iam_database_authentication_enabled = true - enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] - allowed_cidr_blocks = ["10.20.0.0/20", "20.20.0.0/20"] +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 2" - create_security_group = true -} + name = local.name + cidr = "10.99.0.0/18" -resource "aws_db_parameter_group" "aurora_db_57_parameter_group" { - name = "test-aurora-db-57-parameter-group" - family = "aurora-mysql5.7" - description = "test-aurora-db-57-parameter-group" -} + azs = ["${local.region}a", "${local.region}b", "${local.region}c"] + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] -resource "aws_rds_cluster_parameter_group" "aurora_57_cluster_parameter_group" { - name = "test-aurora-57-cluster-parameter-group" - family = "aurora-mysql5.7" - description = "test-aurora-57-cluster-parameter-group" + tags = local.tags } -############################ -# Example of security group -############################ -resource "aws_security_group" "app_servers" { - name_prefix = "app-servers-" - description = "For application servers" - vpc_id = data.aws_vpc.default.id -} +################################################################################ +# RDS Aurora Module +################################################################################ -resource "aws_security_group_rule" "allow_access" { - type = "ingress" - from_port = module.aurora.this_rds_cluster_port - to_port = module.aurora.this_rds_cluster_port - protocol = "tcp" - source_security_group_id = aws_security_group.app_servers.id - security_group_id = module.aurora.this_security_group_id -} +module "aurora" { + source = "../../" -# IAM Policy for use with iam_database_authentication_enabled = true -resource "aws_iam_policy" "aurora_mysql_policy_iam_auth" { - name = "test-aurora-db-57-policy-iam-auth" - - policy = < +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12.26 | +| aws | >= 3.8 | +| random | >= 2.2 | + +## Providers + +| Name | Version | +|------|---------| +| aws | >= 3.8 | +| random | >= 2.2 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| aurora | ../../ | | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | + +## Resources + +| Name | +|------| +| [aws_db_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | +| [aws_rds_cluster_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | +| [random_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | + +## Inputs + +No input. + +## Outputs + +| Name | Description | +|------|-------------| +| this\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| this\_rds\_cluster\_endpoint | The cluster endpoint | +| this\_rds\_cluster\_id | The ID of the cluster | +| this\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| this\_rds\_cluster\_instance\_ids | A list of all cluster instance ids | +| this\_rds\_cluster\_master\_password | The master password | +| this\_rds\_cluster\_master\_username | The master username | +| this\_rds\_cluster\_port | The port | +| this\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| this\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| this\_security\_group\_id | The security group ID of the cluster | + diff --git a/examples/postgresql/main.tf b/examples/postgresql/main.tf index f7a89e7..10a5c40 100644 --- a/examples/postgresql/main.tf +++ b/examples/postgresql/main.tf @@ -1,65 +1,82 @@ provider "aws" { - region = "us-east-1" + region = local.region } -###################################### -# Data sources to get VPC and subnets -###################################### -data "aws_vpc" "default" { - default = true +locals { + name = "postgresql" + region = "eu-west-1" + tags = { + Owner = "user" + Environment = "dev" + } } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id -} +################################################################################ +# Supporting Resources +################################################################################ -############# -# RDS Aurora -############# -module "aurora" { - source = "../../" - name = "aurora-example-postgresql" - engine = "aurora-postgresql" - engine_version = "11.6" - subnets = data.aws_subnet_ids.all.ids - vpc_id = data.aws_vpc.default.id - replica_count = 2 - instance_type = "db.r4.large" - instance_type_replica = "db.t3.medium" - apply_immediately = true - skip_final_snapshot = true - db_parameter_group_name = aws_db_parameter_group.aurora_db_postgres11_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_postgres11_parameter_group.id - # enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] - security_group_description = "" +resource "random_password" "master" { + length = 10 } -resource "aws_db_parameter_group" "aurora_db_postgres11_parameter_group" { - name = "test-aurora-db-postgres11-parameter-group" - family = "aurora-postgresql11" - description = "test-aurora-db-postgres11-parameter-group" +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 2" + + name = local.name + cidr = "10.99.0.0/18" + + azs = ["${local.region}a", "${local.region}b", "${local.region}c"] + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] + + tags = local.tags } -resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres11_parameter_group" { - name = "test-aurora-postgres11-cluster-parameter-group" - family = "aurora-postgresql11" - description = "test-aurora-postgres11-cluster-parameter-group" +################################################################################ +# RDS Aurora Module +################################################################################ + +module "aurora" { + source = "../../" + + name = local.name + engine = "aurora-postgresql" + engine_version = "11.9" + instance_type = "db.r5.large" + instance_type_replica = "db.t3.medium" + + vpc_id = module.vpc.vpc_id + db_subnet_group_name = module.vpc.database_subnet_group_name + create_security_group = true + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks + + replica_count = 2 + iam_database_authentication_enabled = true + password = random_password.master.result + create_random_password = false + + apply_immediately = true + skip_final_snapshot = true + + db_parameter_group_name = aws_db_parameter_group.example.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id + enabled_cloudwatch_logs_exports = ["postgresql"] + + tags = local.tags } -############################ -# Example of security group -############################ -resource "aws_security_group" "app_servers" { - name_prefix = "app-servers-" - description = "For application servers" - vpc_id = data.aws_vpc.default.id +resource "aws_db_parameter_group" "example" { + name = "${local.name}-aurora-db-postgres11-parameter-group" + family = "aurora-postgresql11" + description = "${local.name}-aurora-db-postgres11-parameter-group" + tags = local.tags } -resource "aws_security_group_rule" "allow_access" { - type = "ingress" - from_port = module.aurora.this_rds_cluster_port - to_port = module.aurora.this_rds_cluster_port - protocol = "tcp" - source_security_group_id = aws_security_group.app_servers.id - security_group_id = module.aurora.this_security_group_id +resource "aws_rds_cluster_parameter_group" "example" { + name = "${local.name}-aurora-postgres11-cluster-parameter-group" + family = "aurora-postgresql11" + description = "${local.name}-aurora-postgres11-cluster-parameter-group" + tags = local.tags } diff --git a/examples/postgresql/versions.tf b/examples/postgresql/versions.tf index 23fd6a3..309ada5 100644 --- a/examples/postgresql/versions.tf +++ b/examples/postgresql/versions.tf @@ -1,7 +1,15 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { - aws = ">= 3.8" + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } + + random = { + source = "hashicorp/random" + version = ">= 2.2" + } } } diff --git a/examples/s3_import/README.md b/examples/s3_import/README.md index 51802a1..f22c611 100644 --- a/examples/s3_import/README.md +++ b/examples/s3_import/README.md @@ -64,8 +64,8 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Source | Version | |------|--------|---------| | aurora | ../../ | | -| import_s3_bucket | terraform-aws-modules/s3-bucket/aws | ~> 1.20 | -| vpc | terraform-aws-modules/vpc/aws | ~> 2.77 | +| import_s3_bucket | terraform-aws-modules/s3-bucket/aws | ~> 1 | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | ## Resources diff --git a/examples/s3_import/backup.zip b/examples/s3_import/backup.zip index 2efa659..8cb737f 100644 Binary files a/examples/s3_import/backup.zip and b/examples/s3_import/backup.zip differ diff --git a/examples/s3_import/main.tf b/examples/s3_import/main.tf index 72458de..7d29140 100644 --- a/examples/s3_import/main.tf +++ b/examples/s3_import/main.tf @@ -25,19 +25,15 @@ resource "random_pet" "this" { module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "~> 2.77" + version = "~> 2" name = local.name - cidr = "10.0.0.0/18" + cidr = "10.99.0.0/18" azs = ["${local.region}a", "${local.region}b", "${local.region}c"] - public_subnets = ["10.0.0.0/24", "10.0.1.0/24", "10.0.2.0/24"] - private_subnets = ["10.0.3.0/24", "10.0.4.0/24", "10.0.5.0/24"] - database_subnets = ["10.0.7.0/24", "10.0.8.0/24", "10.0.9.0/24"] - - create_database_subnet_group = true - enable_nat_gateway = true - single_nat_gateway = true + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] enable_dns_hostnames = true enable_dns_support = true @@ -48,7 +44,7 @@ module "vpc" { module "import_s3_bucket" { source = "terraform-aws-modules/s3-bucket/aws" - version = "~> 1.20" + version = "~> 1" bucket = "${local.name}-${random_pet.this.id}" acl = "private" @@ -122,17 +118,20 @@ resource "aws_iam_role_policy" "s3_import" { module "aurora" { source = "../../" - name = local.name - + name = local.name engine = "aurora-mysql" engine_version = "5.7.12" - instance_type = "db.t3.large" - replica_count = 0 + instance_type = "db.r5.large" + + vpc_id = module.vpc.vpc_id + db_subnet_group_name = module.vpc.database_subnet_group_name + create_security_group = true + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks - username = "s3_import_user" + replica_count = 1 + iam_database_authentication_enabled = true password = random_password.master.result create_random_password = false - iam_database_authentication_enabled = true # S3 import https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.LoadFromS3.html s3_import = { @@ -141,29 +140,26 @@ module "aurora" { ingestion_role = aws_iam_role.s3_import.arn } - vpc_id = module.vpc.vpc_id - subnets = module.vpc.database_subnets - create_security_group = true - allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks + apply_immediately = true + skip_final_snapshot = true - apply_immediately = true - skip_final_snapshot = true - db_subnet_group_name = local.name - db_parameter_group_name = aws_db_parameter_group.aurora_db_57_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_57_cluster_parameter_group.id + db_parameter_group_name = aws_db_parameter_group.example.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"] tags = local.tags } -resource "aws_db_parameter_group" "aurora_db_57_parameter_group" { +resource "aws_db_parameter_group" "example" { name = "${local.name}-aurora-db-57-parameter-group" family = "aurora-mysql5.7" description = "${local.name}-aurora-db-57-parameter-group" + tags = local.tags } -resource "aws_rds_cluster_parameter_group" "aurora_57_cluster_parameter_group" { +resource "aws_rds_cluster_parameter_group" "example" { name = "${local.name}-aurora-57-cluster-parameter-group" family = "aurora-mysql5.7" description = "${local.name}-aurora-57-cluster-parameter-group" + tags = local.tags } diff --git a/examples/s3_import/versions.tf b/examples/s3_import/versions.tf index 49f3e58..309ada5 100644 --- a/examples/s3_import/versions.tf +++ b/examples/s3_import/versions.tf @@ -2,7 +2,14 @@ terraform { required_version = ">= 0.12.26" required_providers { - aws = ">= 3.8" - random = ">= 2.2" + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } + + random = { + source = "hashicorp/random" + version = ">= 2.2" + } } } diff --git a/examples/serverless/README.md b/examples/serverless/README.md index 97fffec..5569014 100644 --- a/examples/serverless/README.md +++ b/examples/serverless/README.md @@ -1,5 +1,76 @@ -# AWS RDS Aurora Terraform Serverless Example +# Serverless Example -## Usage of Serverless PostgreSQL or MySQL 5.6 +Configuration in this directory creates Aurora serverless clusters for both PostgreSQL and MySQL. -Uncomment blocks marked with `# PostgreSQL` or `# MySQL` inside of [`main.tf`](main.tf). +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. + + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 0.12.26 | +| aws | >= 3.8 | + +## Providers + +| Name | Version | +|------|---------| +| aws | >= 3.8 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| aurora_mysql | ../../ | | +| aurora_postgresql | ../../ | | +| vpc | terraform-aws-modules/vpc/aws | ~> 2 | + +## Resources + +| Name | +|------| +| [aws_db_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | +| [aws_rds_cluster_parameter_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | + +## Inputs + +No input. + +## Outputs + +| Name | Description | +|------|-------------| +| mysql\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| mysql\_rds\_cluster\_endpoint | The cluster endpoint | +| mysql\_rds\_cluster\_id | The ID of the cluster | +| mysql\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| mysql\_rds\_cluster\_instance\_ids | A list of all cluster instance ids | +| mysql\_rds\_cluster\_master\_password | The master password | +| mysql\_rds\_cluster\_master\_username | The master username | +| mysql\_rds\_cluster\_port | The port | +| mysql\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| mysql\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| mysql\_security\_group\_id | The security group ID of the cluster | +| postgresql\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation | +| postgresql\_rds\_cluster\_endpoint | The cluster endpoint | +| postgresql\_rds\_cluster\_id | The ID of the cluster | +| postgresql\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints | +| postgresql\_rds\_cluster\_instance\_ids | A list of all cluster instance ids | +| postgresql\_rds\_cluster\_master\_password | The master password | +| postgresql\_rds\_cluster\_master\_username | The master username | +| postgresql\_rds\_cluster\_port | The port | +| postgresql\_rds\_cluster\_reader\_endpoint | The cluster reader endpoint | +| postgresql\_rds\_cluster\_resource\_id | The Resource ID of the cluster | +| postgresql\_security\_group\_id | The security group ID of the cluster | + diff --git a/examples/serverless/main.tf b/examples/serverless/main.tf index 8c797cd..01989c9 100644 --- a/examples/serverless/main.tf +++ b/examples/serverless/main.tf @@ -1,53 +1,64 @@ provider "aws" { - region = "us-east-1" + region = local.region } -###################################### -# Data sources to get VPC and subnets -###################################### -data "aws_vpc" "default" { - default = true +locals { + name = "serverless" + region = "eu-west-1" + tags = { + Owner = "user" + Environment = "dev" + } } -data "aws_subnet_ids" "all" { - vpc_id = data.aws_vpc.default.id +################################################################################ +# Supporting Resources +################################################################################ + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 2" + + name = local.name + cidr = "10.99.0.0/18" + + azs = ["${local.region}a", "${local.region}b", "${local.region}c"] + public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"] + private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"] + database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"] + + tags = local.tags } -############# -# RDS Aurora -############# -module "aurora" { +################################################################################ +# RDS Aurora Module - PostgreSQL +################################################################################ + +module "aurora_postgresql" { source = "../../" - name = "aurora" - # PostgreSQL - engine = "aurora-postgresql" + name = "${local.name}-postgresql" + engine = "aurora-postgresql" + engine_mode = "serverless" + engine_version = null + storage_encrypted = true - # MySQL - # engine = "aurora" + vpc_id = module.vpc.vpc_id + subnets = module.vpc.database_subnets + create_security_group = true + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks - engine_mode = "serverless" - engine_version = null replica_scale_enabled = false replica_count = 0 - backtrack_window = 10 # ignored in serverless - - subnets = data.aws_subnet_ids.all.ids - vpc_id = data.aws_vpc.default.id monitoring_interval = 60 - skip_final_snapshot = true - instance_type = "db.r4.large" # ignored for serverless - apply_immediately = true - storage_encrypted = true - # PostgreSQL - db_parameter_group_name = aws_db_parameter_group.aurora_db_postgresql10_parameter_group.id - db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_postgresql10_parameter_group.id + apply_immediately = true + skip_final_snapshot = true - # MySQL - # db_parameter_group_name = aws_db_parameter_group.aurora_db_aurora56_parameter_group.id - # db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_cluster_aurora56_parameter_group.id + db_parameter_group_name = aws_db_parameter_group.example_postgresql.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example_postgresql.id + # enabled_cloudwatch_logs_exports = # NOT SUPPORTED scaling_configuration = { auto_pause = true @@ -58,47 +69,69 @@ module "aurora" { } } -# PostgreSQL -resource "aws_db_parameter_group" "aurora_db_postgresql10_parameter_group" { - name = "test-postgresql10-parameter-group" +resource "aws_db_parameter_group" "example_postgresql" { + name = "${local.name}-aurora-db-postgres-parameter-group" family = "aurora-postgresql10" - description = "test-postgresql10-parameter-group" + description = "${local.name}-aurora-db-postgres-parameter-group" + tags = local.tags } -resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgresql10_parameter_group" { - name = "test-postgresql10-cluster-parameter-group" +resource "aws_rds_cluster_parameter_group" "example_postgresql" { + name = "${local.name}-aurora-postgres-cluster-parameter-group" family = "aurora-postgresql10" - description = "test-postgresql10-cluster-parameter-group" + description = "${local.name}-aurora-postgres-cluster-parameter-group" + tags = local.tags } -# MySQL -#resource "aws_db_parameter_group" "aurora_db_aurora56_parameter_group" { -# name = "test-aurora56-parameter-group" -# family = "aurora5.6" -# description = "test-aurora56-parameter-group" -#} -# -#resource "aws_rds_cluster_parameter_group" "aurora_cluster_aurora56_parameter_group" { -# name = "test-aurora56-cluster-parameter-group" -# family = "aurora5.6" -# description = "test-aurora56-cluster-parameter-group" -#} - -############################ -# Example of security group -############################ -resource "aws_security_group" "app_servers" { - name = "app-servers" - description = "For application servers" - vpc_id = data.aws_vpc.default.id +################################################################################ +# RDS Aurora Module - MySQL +################################################################################ + +module "aurora_mysql" { + source = "../../" + + name = "${local.name}-mysql" + engine = "aurora-mysql" + engine_mode = "serverless" + engine_version = null + storage_encrypted = true + + vpc_id = module.vpc.vpc_id + subnets = module.vpc.database_subnets + create_security_group = true + allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks + + replica_scale_enabled = false + replica_count = 0 + + monitoring_interval = 60 + + apply_immediately = true + skip_final_snapshot = true + + db_parameter_group_name = aws_db_parameter_group.example_mysql.id + db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example_mysql.id + # enabled_cloudwatch_logs_exports = # NOT SUPPORTED + + scaling_configuration = { + auto_pause = true + min_capacity = 2 + max_capacity = 16 + seconds_until_auto_pause = 300 + timeout_action = "ForceApplyCapacityChange" + } } -resource "aws_security_group_rule" "allow_access" { - type = "ingress" - from_port = module.aurora.this_rds_cluster_port - to_port = module.aurora.this_rds_cluster_port - protocol = "tcp" - source_security_group_id = aws_security_group.app_servers.id - security_group_id = module.aurora.this_security_group_id +resource "aws_db_parameter_group" "example_mysql" { + name = "${local.name}-aurora-db-mysql-parameter-group" + family = "aurora-mysql5.7" + description = "${local.name}-aurora-db-mysql-parameter-group" + tags = local.tags } +resource "aws_rds_cluster_parameter_group" "example_mysql" { + name = "${local.name}-aurora-mysql-cluster-parameter-group" + family = "aurora-mysql5.7" + description = "${local.name}-aurora-mysql-cluster-parameter-group" + tags = local.tags +} diff --git a/examples/serverless/outputs.tf b/examples/serverless/outputs.tf index fb6cb04..a24d5bb 100644 --- a/examples/serverless/outputs.tf +++ b/examples/serverless/outputs.tf @@ -1,58 +1,125 @@ +################################################################################ +# RDS Aurora Module - PostgreSQL +################################################################################ + +# aws_rds_cluster +output "postgresql_rds_cluster_id" { + description = "The ID of the cluster" + value = module.aurora_postgresql.this_rds_cluster_id +} + +output "postgresql_rds_cluster_resource_id" { + description = "The Resource ID of the cluster" + value = module.aurora_postgresql.this_rds_cluster_resource_id +} + +output "postgresql_rds_cluster_endpoint" { + description = "The cluster endpoint" + value = module.aurora_postgresql.this_rds_cluster_endpoint +} + +output "postgresql_rds_cluster_reader_endpoint" { + description = "The cluster reader endpoint" + value = module.aurora_postgresql.this_rds_cluster_reader_endpoint +} + +output "postgresql_rds_cluster_database_name" { + description = "Name for an automatically created database on cluster creation" + value = module.aurora_postgresql.this_rds_cluster_database_name +} + +output "postgresql_rds_cluster_master_password" { + description = "The master password" + value = module.aurora_postgresql.this_rds_cluster_master_password + sensitive = true +} + +output "postgresql_rds_cluster_port" { + description = "The port" + value = module.aurora_postgresql.this_rds_cluster_port +} + +output "postgresql_rds_cluster_master_username" { + description = "The master username" + value = module.aurora_postgresql.this_rds_cluster_master_username +} + +# aws_rds_cluster_instance +output "postgresql_rds_cluster_instance_endpoints" { + description = "A list of all cluster instance endpoints" + value = module.aurora_postgresql.this_rds_cluster_instance_endpoints +} + +output "postgresql_rds_cluster_instance_ids" { + description = "A list of all cluster instance ids" + value = module.aurora_postgresql.this_rds_cluster_instance_ids +} + +# aws_security_group +output "postgresql_security_group_id" { + description = "The security group ID of the cluster" + value = module.aurora_postgresql.this_security_group_id +} + +################################################################################ +# RDS Aurora Module - MySQL +################################################################################ + # aws_rds_cluster -output "this_rds_cluster_id" { +output "mysql_rds_cluster_id" { description = "The ID of the cluster" - value = module.aurora.this_rds_cluster_id + value = module.aurora_mysql.this_rds_cluster_id } -output "this_rds_cluster_resource_id" { +output "mysql_rds_cluster_resource_id" { description = "The Resource ID of the cluster" - value = module.aurora.this_rds_cluster_resource_id + value = module.aurora_mysql.this_rds_cluster_resource_id } -output "this_rds_cluster_endpoint" { +output "mysql_rds_cluster_endpoint" { description = "The cluster endpoint" - value = module.aurora.this_rds_cluster_endpoint + value = module.aurora_mysql.this_rds_cluster_endpoint } -output "this_rds_cluster_reader_endpoint" { +output "mysql_rds_cluster_reader_endpoint" { description = "The cluster reader endpoint" - value = module.aurora.this_rds_cluster_reader_endpoint + value = module.aurora_mysql.this_rds_cluster_reader_endpoint } -output "this_rds_cluster_database_name" { +output "mysql_rds_cluster_database_name" { description = "Name for an automatically created database on cluster creation" - value = module.aurora.this_rds_cluster_database_name + value = module.aurora_mysql.this_rds_cluster_database_name } -output "this_rds_cluster_master_password" { +output "mysql_rds_cluster_master_password" { description = "The master password" - value = module.aurora.this_rds_cluster_master_password + value = module.aurora_mysql.this_rds_cluster_master_password sensitive = true } -output "this_rds_cluster_port" { +output "mysql_rds_cluster_port" { description = "The port" - value = module.aurora.this_rds_cluster_port + value = module.aurora_mysql.this_rds_cluster_port } -output "this_rds_cluster_master_username" { +output "mysql_rds_cluster_master_username" { description = "The master username" - value = module.aurora.this_rds_cluster_master_username + value = module.aurora_mysql.this_rds_cluster_master_username } # aws_rds_cluster_instance -output "this_rds_cluster_instance_endpoints" { +output "mysql_rds_cluster_instance_endpoints" { description = "A list of all cluster instance endpoints" - value = module.aurora.this_rds_cluster_instance_endpoints + value = module.aurora_mysql.this_rds_cluster_instance_endpoints } -output "this_rds_cluster_instance_ids" { +output "mysql_rds_cluster_instance_ids" { description = "A list of all cluster instance ids" - value = module.aurora.this_rds_cluster_instance_ids + value = module.aurora_mysql.this_rds_cluster_instance_ids } # aws_security_group -output "this_security_group_id" { +output "mysql_security_group_id" { description = "The security group ID of the cluster" - value = module.aurora.this_security_group_id + value = module.aurora_mysql.this_security_group_id } diff --git a/examples/serverless/versions.tf b/examples/serverless/versions.tf index 23fd6a3..b5267ef 100644 --- a/examples/serverless/versions.tf +++ b/examples/serverless/versions.tf @@ -1,7 +1,10 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { - aws = ">= 3.8" + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } } } diff --git a/main.tf b/main.tf index 6a39316..6a8d0f6 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,7 @@ locals { port = var.port == "" ? var.engine == "aurora-postgresql" ? "5432" : "3306" : var.port - master_password = var.create_cluster && var.create_random_password && var.is_primary_cluster ? random_password.master_password[0].result : var.password db_subnet_group_name = var.db_subnet_group_name == "" ? join("", aws_db_subnet_group.this.*.name) : var.db_subnet_group_name + master_password = var.create_cluster && var.create_random_password && var.is_primary_cluster ? random_password.master_password[0].result : var.password backtrack_window = (var.engine == "aurora-mysql" || var.engine == "aurora") && var.engine_mode != "serverless" ? var.backtrack_window : 0 rds_enhanced_monitoring_arn = var.create_monitoring_role ? join("", aws_iam_role.rds_enhanced_monitoring.*.arn) : var.monitoring_role_arn diff --git a/versions.tf b/versions.tf index d5bd958..309ada5 100644 --- a/versions.tf +++ b/versions.tf @@ -1,8 +1,15 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 0.12.26" required_providers { - aws = ">= 3.8" - random = ">= 2.2" + aws = { + source = "hashicorp/aws" + version = ">= 3.8" + } + + random = { + source = "hashicorp/random" + version = ">= 2.2" + } } }