Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update examples with terraform-aws-kms module #3

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/complete-oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Note that this example may create resources which cost money. Run `terraform des

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

## Modules

Expand All @@ -35,14 +35,15 @@ Note that this example may create resources which cost money. Run `terraform des
| <a name="module_db"></a> [db](#module\_db) | ../../ | n/a |
| <a name="module_db_automated_backups_replication"></a> [db\_automated\_backups\_replication](#module\_db\_automated\_backups\_replication) | ../../modules/db_instance_automated_backups_replication | n/a |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | n/a |
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | ~> 1.0 |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources

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

## Inputs

Expand Down
29 changes: 22 additions & 7 deletions examples/complete-oracle/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ provider "aws" {
region = local.region
}

data "aws_caller_identity" "current" {}

locals {
name = "complete-oracle"
region = "eu-west-1"
region2 = "eu-central-1"
name = "complete-oracle"
region = "eu-west-1"
region2 = "eu-central-1"
current_identity = data.aws_caller_identity.current.arn
tags = {
Owner = "user"
Environment = "dev"
Expand Down Expand Up @@ -121,17 +124,29 @@ provider "aws" {
region = local.region2
}

resource "aws_kms_key" "default" {
description = "Encryption key for cross region automated backups"
module "kms" {
source = "terraform-aws-modules/kms/aws"
version = "~> 1.0"
description = "KMS key for cross region automated backups replication"

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

key_owners = [local.current_identity]

tags = local.tags

provider = aws.region2
providers = {
aws = aws.region2
}
}

module "db_automated_backups_replication" {
source = "../../modules/db_instance_automated_backups_replication"

source_db_instance_arn = module.db.db_instance_arn
kms_key_arn = aws_kms_key.default.arn
kms_key_arn = module.kms.key_arn

providers = {
aws = aws.region2
Expand Down
5 changes: 3 additions & 2 deletions examples/complete-postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Note that this example may create resources which cost money. Run `terraform des

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

## Modules

Expand All @@ -36,14 +36,15 @@ Note that this example may create resources which cost money. Run `terraform des
| <a name="module_db_automated_backups_replication"></a> [db\_automated\_backups\_replication](#module\_db\_automated\_backups\_replication) | ../../modules/db_instance_automated_backups_replication | n/a |
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | n/a |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | n/a |
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | ~> 1.0 |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources

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

## Inputs

Expand Down
29 changes: 22 additions & 7 deletions examples/complete-postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ provider "aws" {
region = local.region
}

data "aws_caller_identity" "current" {}

locals {
name = "complete-postgresql"
region = "eu-west-1"
region2 = "eu-central-1"
name = "complete-postgresql"
region = "eu-west-1"
region2 = "eu-central-1"
current_identity = data.aws_caller_identity.current.arn
tags = {
Owner = "user"
Environment = "dev"
Expand Down Expand Up @@ -175,17 +178,29 @@ provider "aws" {
region = local.region2
}

resource "aws_kms_key" "default" {
description = "Encryption key for cross region automated backups"
module "kms" {
source = "terraform-aws-modules/kms/aws"
version = "~> 1.0"
description = "KMS key for cross region automated backups replication"

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

key_owners = [local.current_identity]

tags = local.tags

provider = aws.region2
providers = {
aws = aws.region2
}
}

module "db_automated_backups_replication" {
source = "../../modules/db_instance_automated_backups_replication"

source_db_instance_arn = module.db.db_instance_arn
kms_key_arn = aws_kms_key.default.arn
kms_key_arn = module.kms.key_arn

providers = {
aws = aws.region2
Expand Down