Skip to content

Commit 9ac6703

Browse files
committed
chore: Update examples to align with current practices
1 parent 9462b7e commit 9ac6703

File tree

26 files changed

+274
-343
lines changed

26 files changed

+274
-343
lines changed

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module "cluster" {
2323
2424
name = "test-aurora-db-postgres96"
2525
engine = "aurora-postgresql"
26-
engine_version = "11.12"
26+
engine_version = "14.5"
2727
instance_class = "db.r6g.large"
2828
instances = {
2929
one = {}
@@ -32,19 +32,21 @@ module "cluster" {
3232
}
3333
}
3434
35-
vpc_id = "vpc-12345678"
36-
subnets = ["subnet-12345678", "subnet-87654321"]
37-
38-
allowed_security_groups = ["sg-12345678"]
39-
allowed_cidr_blocks = ["10.20.0.0/20"]
35+
vpc_id = "vpc-12345678"
36+
db_subnet_group_name = "db-subnet-group"
37+
security_group_rules = {
38+
ex1_ingress = {
39+
cidr_blocks = ["10.20.0.0/20"]
40+
}
41+
ex1_ingress = {
42+
source_security_group_id = "sg-12345678"
43+
}
44+
}
4045
4146
storage_encrypted = true
4247
apply_immediately = true
4348
monitoring_interval = 10
4449
45-
db_parameter_group_name = "default"
46-
db_cluster_parameter_group_name = "default"
47-
4850
enabled_cloudwatch_logs_exports = ["postgresql"]
4951
5052
tags = {
@@ -224,7 +226,7 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
224226

225227
| Name | Version |
226228
|------|---------|
227-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
229+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
228230
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.30 |
229231
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.2 |
230232

@@ -255,9 +257,7 @@ No modules.
255257
| [aws_rds_cluster_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | resource |
256258
| [aws_rds_cluster_role_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_role_association) | resource |
257259
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
258-
| [aws_security_group_rule.cidr_ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
259-
| [aws_security_group_rule.default_ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
260-
| [aws_security_group_rule.egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
260+
| [aws_security_group_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
261261
| [random_id.snapshot_identifier](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
262262
| [random_password.master_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
263263
| [aws_iam_policy_document.monitoring_rds_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -269,8 +269,6 @@ No modules.
269269
|------|-------------|------|---------|:--------:|
270270
| <a name="input_allocated_storage"></a> [allocated\_storage](#input\_allocated\_storage) | The amount of storage in gibibytes (GiB) to allocate to each DB instance in the Multi-AZ DB cluster. (This setting is required to create a Multi-AZ DB cluster) | `number` | `null` | no |
271271
| <a name="input_allow_major_version_upgrade"></a> [allow\_major\_version\_upgrade](#input\_allow\_major\_version\_upgrade) | Enable to allow major engine version upgrades when changing engine versions. Defaults to `false` | `bool` | `false` | no |
272-
| <a name="input_allowed_cidr_blocks"></a> [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | A list of CIDR blocks which are allowed to access the database | `list(string)` | `[]` | no |
273-
| <a name="input_allowed_security_groups"></a> [allowed\_security\_groups](#input\_allowed\_security\_groups) | A list of Security Group ID's to allow access to | `list(string)` | `[]` | no |
274272
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is `false` | `bool` | `null` | no |
275273
| <a name="input_auto_minor_version_upgrade"></a> [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Default `true` | `bool` | `null` | no |
276274
| <a name="input_autoscaling_enabled"></a> [autoscaling\_enabled](#input\_autoscaling\_enabled) | Determines whether autoscaling of the cluster read replicas is enabled | `bool` | `false` | no |
@@ -293,7 +291,7 @@ No modules.
293291
| <a name="input_create_cluster"></a> [create\_cluster](#input\_create\_cluster) | Whether cluster should be created (affects nearly all resources) | `bool` | `true` | no |
294292
| <a name="input_create_db_cluster_parameter_group"></a> [create\_db\_cluster\_parameter\_group](#input\_create\_db\_cluster\_parameter\_group) | Determines whether a cluster parameter should be created or use existing | `bool` | `false` | no |
295293
| <a name="input_create_db_parameter_group"></a> [create\_db\_parameter\_group](#input\_create\_db\_parameter\_group) | Determines whether a DB parameter should be created or use existing | `bool` | `false` | no |
296-
| <a name="input_create_db_subnet_group"></a> [create\_db\_subnet\_group](#input\_create\_db\_subnet\_group) | Determines whether to create the database subnet group or use existing | `bool` | `true` | no |
294+
| <a name="input_create_db_subnet_group"></a> [create\_db\_subnet\_group](#input\_create\_db\_subnet\_group) | Determines whether to create the database subnet group or use existing | `bool` | `false` | no |
297295
| <a name="input_create_monitoring_role"></a> [create\_monitoring\_role](#input\_create\_monitoring\_role) | Determines whether to create the IAM role for RDS enhanced monitoring | `bool` | `true` | no |
298296
| <a name="input_create_random_password"></a> [create\_random\_password](#input\_create\_random\_password) | Determines whether to create random password for RDS primary cluster | `bool` | `true` | no |
299297
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines whether to create security group for RDS cluster | `bool` | `true` | no |
@@ -351,17 +349,17 @@ No modules.
351349
| <a name="input_predefined_metric_type"></a> [predefined\_metric\_type](#input\_predefined\_metric\_type) | The metric type to scale on. Valid values are `RDSReaderAverageCPUUtilization` and `RDSReaderAverageDatabaseConnections` | `string` | `"RDSReaderAverageCPUUtilization"` | no |
352350
| <a name="input_preferred_backup_window"></a> [preferred\_backup\_window](#input\_preferred\_backup\_window) | The daily time range during which automated backups are created if automated backups are enabled using the `backup_retention_period` parameter. Time in UTC | `string` | `"02:00-03:00"` | no |
353351
| <a name="input_preferred_maintenance_window"></a> [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range during which system maintenance can occur, in (UTC) | `string` | `"sun:05:00-sun:06:00"` | no |
354-
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | Determines whether instances are publicly accessible. Default false | `bool` | `null` | no |
352+
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | Determines whether instances are publicly accessible. Default `false` | `bool` | `null` | no |
355353
| <a name="input_putin_khuylo"></a> [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no |
356354
| <a name="input_random_password_length"></a> [random\_password\_length](#input\_random\_password\_length) | Length of random password to create. Defaults to `10` | `number` | `10` | no |
357355
| <a name="input_replication_source_identifier"></a> [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 |
358356
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | Map of nested attributes for cloning Aurora cluster | `map(string)` | `{}` | no |
359357
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Configuration map used to restore from a Percona Xtrabackup in S3 (only MySQL is supported) | `map(string)` | `{}` | no |
360358
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | Map of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | `map(string)` | `{}` | no |
361359
| <a name="input_security_group_description"></a> [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` | `null` | no |
362-
| <a name="input_security_group_egress_rules"></a> [security\_group\_egress\_rules](#input\_security\_group\_egress\_rules) | A map of security group egress rule definitions to add to the security group created | `map(any)` | `{}` | no |
360+
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | Map of security group rules to add to the cluster security group created | `any` | `{}` | no |
363361
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Additional tags for the security group | `map(string)` | `{}` | no |
364-
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`name`) is used as a prefix | `bool` | `true` | no |
362+
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`var.name`) is used as a prefix | `bool` | `true` | no |
365363
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | Map of nested attributes with serverless v2 scaling properties. Only valid when `engine_mode` is set to `provisioned` | `map(string)` | `{}` | no |
366364
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final snapshot is created before the cluster is deleted. If true is specified, no snapshot is created | `bool` | `false` | no |
367365
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot | `string` | `null` | no |
@@ -371,7 +369,7 @@ No modules.
371369
| <a name="input_subnets"></a> [subnets](#input\_subnets) | List of subnet IDs used by database subnet group created | `list(string)` | `[]` | no |
372370
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
373371
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC where to create security group | `string` | `""` | no |
374-
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of VPC security groups to associate to the cluster in addition to the SG we create in this module | `list(string)` | `[]` | no |
372+
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of VPC security groups to associate to the cluster in addition to the security group created | `list(string)` | `[]` | no |
375373

376374
## Outputs
377375

examples/autoscaling/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des
1919

2020
| Name | Version |
2121
|------|---------|
22-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
2323
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.30 |
2424

2525
## Providers
@@ -40,8 +40,7 @@ Note that this example may create resources which cost money. Run `terraform des
4040

4141
| Name | Type |
4242
|------|------|
43-
| [aws_db_parameter_group.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | resource |
44-
| [aws_rds_cluster_parameter_group.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | resource |
43+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
4544

4645
## Inputs
4746

examples/autoscaling/main.tf

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ provider "aws" {
22
region = local.region
33
}
44

5+
data "aws_availability_zones" "available" {}
6+
57
locals {
6-
name = "ex-${replace(basename(path.cwd), "_", "-")}"
8+
name = "ex-${basename(path.cwd)}"
79
region = "eu-west-1"
810

11+
vpc_cidr = "10.0.0.0/16"
12+
azs = slice(data.aws_availability_zones.available.names, 0, 3)
13+
914
tags = {
1015
Example = local.name
1116
GithubRepo = "terraform-aws-rds-aurora"
@@ -22,15 +27,17 @@ module "aurora" {
2227

2328
name = local.name
2429
engine = "aurora-postgresql"
25-
engine_version = "11.12"
30+
engine_version = "14.5"
2631
instance_class = "db.r6g.large"
2732
instances = { 1 = {} }
2833

29-
vpc_id = module.vpc.vpc_id
30-
db_subnet_group_name = module.vpc.database_subnet_group_name
31-
create_db_subnet_group = false
32-
create_security_group = true
33-
allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks
34+
vpc_id = module.vpc.vpc_id
35+
db_subnet_group_name = module.vpc.database_subnet_group_name
36+
security_group_rules = {
37+
vpc_ingress = {
38+
cidr_blocks = module.vpc.private_subnets_cidr_blocks
39+
}
40+
}
3441

3542
autoscaling_enabled = true
3643
autoscaling_min_capacity = 1
@@ -46,27 +53,11 @@ module "aurora" {
4653
apply_immediately = true
4754
skip_final_snapshot = true
4855

49-
db_parameter_group_name = aws_db_parameter_group.example.id
50-
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example.id
5156
enabled_cloudwatch_logs_exports = ["postgresql"]
5257

5358
tags = local.tags
5459
}
5560

56-
resource "aws_db_parameter_group" "example" {
57-
name_prefix = "${local.name}-aurora-db-postgres11-parameter-group"
58-
family = "aurora-postgresql11"
59-
description = "${local.name}-aurora-db-postgres11-parameter-group"
60-
tags = local.tags
61-
}
62-
63-
resource "aws_rds_cluster_parameter_group" "example" {
64-
name_prefix = "${local.name}-aurora-postgres11-cluster-parameter-group"
65-
family = "aurora-postgresql11"
66-
description = "${local.name}-aurora-postgres11-cluster-parameter-group"
67-
tags = local.tags
68-
}
69-
7061
module "disabled_aurora" {
7162
source = "../../"
7263

@@ -82,16 +73,16 @@ module "vpc" {
8273
version = "~> 3.0"
8374

8475
name = local.name
85-
cidr = "10.99.0.0/18"
76+
cidr = local.vpc_cidr
77+
78+
azs = local.azs
79+
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
80+
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 3)]
81+
database_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 6)]
8682

8783
enable_dns_support = true
8884
enable_dns_hostnames = true
8985

90-
azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
91-
public_subnets = ["10.99.0.0/24", "10.99.1.0/24", "10.99.2.0/24"]
92-
private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
93-
database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"]
94-
9586
enable_nat_gateway = false # Disabled NAT to be able to run this example quicker
9687

9788
tags = local.tags

examples/autoscaling/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

examples/global-cluster/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des
1919

2020
| Name | Version |
2121
|------|---------|
22-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
2323
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.30 |
2424

2525
## Providers
@@ -45,6 +45,8 @@ Note that this example may create resources which cost money. Run `terraform des
4545
| [aws_kms_key.primary](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
4646
| [aws_kms_key.secondary](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
4747
| [aws_rds_global_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_global_cluster) | resource |
48+
| [aws_availability_zones.primary](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
49+
| [aws_availability_zones.secondary](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
4850
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
4951
| [aws_iam_policy_document.rds](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5052

0 commit comments

Comments
 (0)