Skip to content

Commit

Permalink
fix: Fixed example of cross-region replica where KMS key was missing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
magreenbaum committed Aug 15, 2022
1 parent 8812527 commit 88418a7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
9 changes: 7 additions & 2 deletions examples/cross-region-replica-postgres/README.md
Expand Up @@ -24,12 +24,15 @@ Note that this example may create resources which cost money. Run `terraform des

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.6 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | ~> 1.0 |
| <a name="module_master"></a> [master](#module\_master) | ../../ | n/a |
| <a name="module_replica"></a> [replica](#module\_replica) | ../../ | n/a |
| <a name="module_security_group_region1"></a> [security\_group\_region1](#module\_security\_group\_region1) | terraform-aws-modules/security-group/aws | ~> 4.0 |
Expand All @@ -39,7 +42,9 @@ No providers.

## Resources

No resources.
| Name | Type |
|------|------|
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |

## Inputs

Expand Down
27 changes: 24 additions & 3 deletions examples/cross-region-replica-postgres/main.tf
Expand Up @@ -7,10 +7,13 @@ provider "aws" {
region = local.region2
}

data "aws_caller_identity" "current" {}

locals {
name = "replica-postgresql"
region1 = "eu-west-1"
region2 = "eu-central-1"
name = "replica-postgresql"
region1 = "eu-west-1"
region2 = "eu-central-1"
current_identity = data.aws_caller_identity.current.id
tags = {
Owner = "user"
Environment = "dev"
Expand Down Expand Up @@ -158,6 +161,23 @@ module "master" {
################################################################################
# Replica DB
################################################################################
module "kms" {
source = "terraform-aws-modules/kms/aws"
version = "~> 1.0"
description = "KMS key for cross region replica DB"

# Aliases
aliases = [local.name]
aliases_use_name_prefix = true

key_owners = [local.current_identity]

tags = local.tags

providers = {
aws = aws.region2
}
}

module "replica" {
source = "../../"
Expand All @@ -177,6 +197,7 @@ module "replica" {
family = local.family
major_engine_version = local.major_engine_version
instance_class = local.instance_class
kms_key_id = module.kms.key_arn

allocated_storage = local.allocated_storage
max_allocated_storage = local.max_allocated_storage
Expand Down

0 comments on commit 88418a7

Please sign in to comment.