File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
examples/cross-region-replica-postgres Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -24,12 +24,15 @@ Note that this example may create resources which cost money. Run `terraform des
24
24
25
25
## Providers
26
26
27
- No providers.
27
+ | Name | Version |
28
+ | ------| ---------|
29
+ | <a name =" provider_aws " ></a > [ aws] ( #provider\_ aws ) | >= 4.6 |
28
30
29
31
## Modules
30
32
31
33
| Name | Source | Version |
32
34
| ------| --------| ---------|
35
+ | <a name =" module_kms " ></a > [ kms] ( #module\_ kms ) | terraform-aws-modules/kms/aws | ~ > 1.0 |
33
36
| <a name =" module_master " ></a > [ master] ( #module\_ master ) | ../../ | n/a |
34
37
| <a name =" module_replica " ></a > [ replica] ( #module\_ replica ) | ../../ | n/a |
35
38
| <a name =" module_security_group_region1 " ></a > [ security\_ group\_ region1] ( #module\_ security\_ group\_ region1 ) | terraform-aws-modules/security-group/aws | ~ > 4.0 |
@@ -39,7 +42,9 @@ No providers.
39
42
40
43
## Resources
41
44
42
- No resources.
45
+ | Name | Type |
46
+ | ------| ------|
47
+ | [ aws_caller_identity.current] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity ) | data source |
43
48
44
49
## Inputs
45
50
Original file line number Diff line number Diff line change @@ -7,10 +7,13 @@ provider "aws" {
7
7
region = local. region2
8
8
}
9
9
10
+ data "aws_caller_identity" "current" {}
11
+
10
12
locals {
11
- name = " replica-postgresql"
12
- region1 = " eu-west-1"
13
- region2 = " eu-central-1"
13
+ name = " replica-postgresql"
14
+ region1 = " eu-west-1"
15
+ region2 = " eu-central-1"
16
+ current_identity = data. aws_caller_identity . current . id
14
17
tags = {
15
18
Owner = " user"
16
19
Environment = " dev"
@@ -158,6 +161,23 @@ module "master" {
158
161
# ###############################################################################
159
162
# Replica DB
160
163
# ###############################################################################
164
+ module "kms" {
165
+ source = " terraform-aws-modules/kms/aws"
166
+ version = " ~> 1.0"
167
+ description = " KMS key for cross region replica DB"
168
+
169
+ # Aliases
170
+ aliases = [local . name ]
171
+ aliases_use_name_prefix = true
172
+
173
+ key_owners = [local . current_identity ]
174
+
175
+ tags = local. tags
176
+
177
+ providers = {
178
+ aws = aws.region2
179
+ }
180
+ }
161
181
162
182
module "replica" {
163
183
source = " ../../"
@@ -177,6 +197,7 @@ module "replica" {
177
197
family = local. family
178
198
major_engine_version = local. major_engine_version
179
199
instance_class = local. instance_class
200
+ kms_key_id = module. kms . key_arn
180
201
181
202
allocated_storage = local. allocated_storage
182
203
max_allocated_storage = local. max_allocated_storage
You can’t perform that action at this time.
0 commit comments