Skip to content

Commit

Permalink
Cloudposse master (#5)
Browse files Browse the repository at this point in the history
* Adding timeout for rds cluster resources and defaulting to TF default to 120m (cloudposse#64)

Co-authored-by: PePe (Jose) Amengual <[email protected]>

* Allow setting `copy_tags_to_snapshot` variable (cloudposse#62)

Allow copy_tags_to_snapshot to be set to true via terraform.

Signed-off-by: Jon Whitcraft <[email protected]>

Co-authored-by: Maxim Mironenko <[email protected]>

* Bugfix timeouts (cloudposse#65)

* Adding timeout for rds cluster resources and defaulting to TF default to 120m

* Fixing bug in timeout config

Co-authored-by: PePe (Jose) Amengual <[email protected]>

* Allow creation of a cluster without creation of a database (cloudposse#66)

* fix(cloudposse#63): instance_count should be independent of autoscaling_min_capacity (cloudposse#67)

Co-authored-by: Sumeet Shukla <[email protected]>

* Migrate to ChatOps (cloudposse#70)

* feat(enable_http_endpoint): added new enable_http_endpoint option for aurora serverless engine (cloudposse#69)

* feat(enable_http_endpoint): added new option
for aurora serverless

related to: cloudposse#54 cloudposse#51

* feat(enable_http_endpoint): corrected default value
in docs

related to: cloudposse#54 cloudposse#51

* feat: reverted back README.md changes

* feat: reverted back README.md changes

* feat: generated README.md

* Allow user to pass in cluster_identifier (cloudposse#72)

* cluster_identifier: Provide ability to supply your own cluster_identifier

Change-Id: I63ee15c74e2aa632e0c1cc11fc30ff9d013af4d2

* cluster_identifier: Sort out naming for final snapshot

Change-Id: I9f3b103c81b96662f35451d973640fc4d80b8236

* Updated README.md

Co-authored-by: Andy Hibbert <[email protected]>
Co-authored-by: actions-bot <[email protected]>

* 73: Add auto_minor_version_upgrade flag variable (cloudposse#74)

* 73: Add auto_minor_version_upgrade flag variable

Default to true as per provider.

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_instance#auto_minor_version_upgrade

* Updated README.md

Co-authored-by: actions-bot <[email protected]>

* [AUTOMATED] Update Version Pinning for Terraform to support 0.13 (cloudposse#75)

## What

1. Update Version Pinning for Terraform to support 0.13

## Why

1. This is a relatively minor update that the CloudPosse module already likely supports.
1. This allows module consumers to not individually update our Terraform module to support Terraform 0.13.

* [AUTOMATED] Update terraform-null-label versions to support Terraform 0.13 (cloudposse#76)

* Support terraform 0.13 (cloudposse#77)

* Update to `context.tf`. Add `primary` and `secondary` cluster resources (cloudposse#79)

* Update to `context.tf`

* Update to `context.tf`

* Update to `context.tf`

* Update to `context.tf`

* Fix outputs when `enabled=false`. Change Security Group rules from inline to resources (cloudposse#80)

* Add IAM role for enhanced monitoring (cloudposse#82)

* Update examples

* Add IAM role for enhanced monitoring

* Add percona xtrabackup import from S3 (cloudposse#84)

* Update main.tf

* Update variables.tf

* Updated README.md

* Update variables.tf

* Updated README.md

* Update variables.tf

* Updated README.md

* Update variables.tf

* Updated README.md

* Update main.tf

* Update main.tf

Co-authored-by: actions-bot <[email protected]>

* Fixes DNS prepending var.name to local.cluster_dns_name (cloudposse#88)

## what
* DNS was changing when it shouldn't have been, it was the value of:

```
${var.name}-${local.cluster_dns_name}
```

I think this may have changed in https://github.com/cloudposse/terraform-aws-route53-cluster-hostname/releases/tag/0.6.0

This changes the parameter to `dns_name` and upgrades the version to get a stable DNS record

## why

* Fix broken DNS

* Serverless: Aurora 2.07.1 MySQL 5.7 and encrypted_storage parameter fix (cloudposse#91)

* Aurora serverless is encrypted by default

Follow upstream documentation and don't set `storage_encrypted` at all.

* Include Aurora 2.07.1 MySQL  5.7 example

Also fix minor missing new item in 5.6 example.

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.serverless_2_07_01.html

* Add suport for cluster cloning (cloudposse#92)

* Fixing incompatibility with snashot_identifier

* using upstream names instead

* remove module with db_name

* remove module with db_name

* remove module with db_name

Co-authored-by: PePe Amengual <[email protected]>
Co-authored-by: PePe (Jose) Amengual <[email protected]>
Co-authored-by: Jon Whitcraft <[email protected]>
Co-authored-by: Maxim Mironenko <[email protected]>
Co-authored-by: Nuru <[email protected]>
Co-authored-by: Sumeet Shukla <[email protected]>
Co-authored-by: Sumeet Shukla <[email protected]>
Co-authored-by: Erik Osterman <[email protected]>
Co-authored-by: Mariusz Rajczakowski <[email protected]>
Co-authored-by: Andrew Hibbert <[email protected]>
Co-authored-by: Andy Hibbert <[email protected]>
Co-authored-by: actions-bot <[email protected]>
Co-authored-by: Karl <[email protected]>
Co-authored-by: Matt Gowie <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>
Co-authored-by: nitro <[email protected]>
Co-authored-by: Mikael Fridh <[email protected]>
  • Loading branch information
18 people authored Dec 9, 2020
1 parent ff4d940 commit 794879c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
28 changes: 14 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ resource "aws_security_group_rule" "egress" {

resource "aws_cloudwatch_log_group" "default" {
count = var.enabled && length(var.enabled_cloudwatch_logs_exports)>0 ? 1 : 0
name = "/aws/rds/cluster/${module.label.id}/postgresql"
name = "/aws/rds/cluster/${coalesce(join("", aws_rds_cluster.default.*.id), join("", aws_rds_cluster.secondary.*.id))}/postgresql"
retention_in_days = var.logs_retention_in_days
kms_key_id = var.kms_key_arn
}

resource "aws_rds_cluster" "primary" {
resource "aws_rds_cluster" "default" {
count = module.this.enabled && local.is_primary_cluster == true ? 1 : 0
cluster_identifier = var.cluster_identifier == "" ? module.this.id : var.cluster_identifier
database_name = var.db_name
Expand Down Expand Up @@ -111,14 +111,14 @@ resource "aws_rds_cluster" "primary" {
}
}

dynamic "restore_to_point_in_time" {
for_each = var.restore_to_point_in_time
content {
source_cluster_identifier = lookup(restore_to_point_in_time.value, "source_cluster_identifier", "120m")
restore_type = lookup(restore_to_point_in_time.value, "restore_type", "copy-on-write")
use_latest_restorable_time = lookup(restore_to_point_in_time.value, "use_latest_restorable_time", true)
}
}
// dynamic "restore_to_point_in_time" {
// for_each = var.restore_to_point_in_time
// content {
// source_cluster_identifier = lookup(restore_to_point_in_time.value, "source_cluster_identifier", "120m")
// restore_type = lookup(restore_to_point_in_time.value, "restore_type", "copy-on-write")
// use_latest_restorable_time = lookup(restore_to_point_in_time.value, "use_latest_restorable_time", true)
// }
// }

enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports
deletion_protection = var.deletion_protection
Expand Down Expand Up @@ -195,7 +195,7 @@ resource "aws_rds_cluster" "secondary" {
resource "aws_rds_cluster_instance" "default" {
count = local.cluster_instance_count
identifier = var.cluster_identifier == "" ? "${module.this.id}-${count.index + 1}" : "${var.cluster_identifier}-${count.index + 1}"
cluster_identifier = coalesce(join("", aws_rds_cluster.primary.*.id), join("", aws_rds_cluster.secondary.*.id))
cluster_identifier = coalesce(join("", aws_rds_cluster.default.*.id), join("", aws_rds_cluster.secondary.*.id))
instance_class = var.instance_type
db_subnet_group_name = join("", aws_db_subnet_group.default.*.name)
db_parameter_group_name = join("", aws_db_parameter_group.default.*.name)
Expand Down Expand Up @@ -268,7 +268,7 @@ module "dns_master" {
enabled = module.this.enabled && length(var.zone_id) > 0 ? true : false
dns_name = local.cluster_dns_name
zone_id = var.zone_id
records = coalescelist(aws_rds_cluster.primary.*.endpoint, aws_rds_cluster.secondary.*.endpoint, [""])
records = coalescelist(aws_rds_cluster.default.*.endpoint, aws_rds_cluster.secondary.*.endpoint, [""])

context = module.this.context
}
Expand All @@ -279,7 +279,7 @@ module "dns_replicas" {
enabled = module.this.enabled && length(var.zone_id) > 0 && var.engine_mode != "serverless" ? true : false
dns_name = local.reader_dns_name
zone_id = var.zone_id
records = coalescelist(aws_rds_cluster.primary.*.reader_endpoint, aws_rds_cluster.secondary.*.reader_endpoint, [""])
records = coalescelist(aws_rds_cluster.default.*.reader_endpoint, aws_rds_cluster.secondary.*.reader_endpoint, [""])

context = module.this.context
}
Expand All @@ -288,7 +288,7 @@ resource "aws_appautoscaling_target" "replicas" {
count = module.this.enabled && var.autoscaling_enabled ? 1 : 0
service_namespace = "rds"
scalable_dimension = "rds:cluster:ReadReplicaCount"
resource_id = "cluster:${coalesce(join("", aws_rds_cluster.primary.*.id), join("", aws_rds_cluster.secondary.*.id))}"
resource_id = "cluster:${coalesce(join("", aws_rds_cluster.default.*.id), join("", aws_rds_cluster.secondary.*.id))}"
min_capacity = var.autoscaling_min_capacity
max_capacity = var.autoscaling_max_capacity
}
Expand Down
14 changes: 7 additions & 7 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ output "database_name" {
}

output "master_username" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.master_username) : join("", aws_rds_cluster.secondary.*.master_username)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.master_username) : join("", aws_rds_cluster.secondary.*.master_username)
description = "Username for the master DB user"
}

output "cluster_identifier" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.cluster_identifier) : join("", aws_rds_cluster.secondary.*.cluster_identifier)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.cluster_identifier) : join("", aws_rds_cluster.secondary.*.cluster_identifier)
description = "Cluster Identifier"
}

output "arn" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.arn) : join("", aws_rds_cluster.secondary.*.arn)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.arn) : join("", aws_rds_cluster.secondary.*.arn)
description = "Amazon Resource Name (ARN) of the cluster"
}

output "endpoint" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.endpoint) : join("", aws_rds_cluster.secondary.*.endpoint)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.endpoint) : join("", aws_rds_cluster.secondary.*.endpoint)
description = "The DNS address of the RDS instance"
}

output "reader_endpoint" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.reader_endpoint) : join("", aws_rds_cluster.secondary.*.reader_endpoint)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.reader_endpoint) : join("", aws_rds_cluster.secondary.*.reader_endpoint)
description = "A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas"
}

Expand All @@ -44,12 +44,12 @@ output "dbi_resource_ids" {
}

output "cluster_resource_id" {
value = local.is_primary_cluster ? join("", aws_rds_cluster.primary.*.cluster_resource_id) : join("", aws_rds_cluster.secondary.*.cluster_resource_id)
value = local.is_primary_cluster ? join("", aws_rds_cluster.default.*.cluster_resource_id) : join("", aws_rds_cluster.secondary.*.cluster_resource_id)
description = "The region-unique, immutable identifie of the cluster"
}

output "cluster_security_groups" {
value = coalescelist(aws_rds_cluster.primary.*.vpc_security_group_ids, aws_rds_cluster.secondary.*.vpc_security_group_ids, [""])
value = coalescelist(aws_rds_cluster.default.*.vpc_security_group_ids, aws_rds_cluster.secondary.*.vpc_security_group_ids, [""])
description = "Default RDS cluster security groups"
}

Expand Down

0 comments on commit 794879c

Please sign in to comment.