Skip to content

Commit e63200a

Browse files
authored
feat: allow replication for DDB (#91)
1 parent a8141fd commit e63200a

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ See [the official document](https://www.terraform.io/docs/backends/types/s3.html
129129
|------|-------------|
130130
| <a name="output_dynamodb_table"></a> [dynamodb\_table](#output\_dynamodb\_table) | The DynamoDB table to manage lock states. |
131131
| <a name="output_kms_key"></a> [kms\_key](#output\_kms\_key) | The KMS customer master key to encrypt state buckets. |
132-
| <a name="output_kms_key_alias"></a> [kms\_key\_alias](#output\_kms\_key\_alias) | The alias of the KMS customer master key used to encrypt state buckets. |
132+
| <a name="output_kms_key_alias"></a> [kms\_key\_alias](#output\_kms\_key\_alias) | The alias of the KMS customer master key used to encrypt state bucket and dynamodb. |
133+
| <a name="output_kms_key_replica"></a> [kms\_key\_replica](#output\_kms\_key\_replica) | The KMS customer master key to encrypt replica bucket and dynamodb. |
133134
| <a name="output_replica_bucket"></a> [replica\_bucket](#output\_replica\_bucket) | The S3 bucket to replicate the state S3 bucket. |
134135
| <a name="output_state_bucket"></a> [state\_bucket](#output\_state\_bucket) | The S3 bucket to store the remote state file. |
135136
| <a name="output_terraform_iam_policy"></a> [terraform\_iam\_policy](#output\_terraform\_iam\_policy) | The IAM Policy to access remote state environment. |

dynamo.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,14 @@ resource "aws_dynamodb_table" "lock" {
2828
enabled = true
2929
}
3030

31+
dynamic "replica" {
32+
for_each = var.enable_replication == true ? [1] : []
33+
content {
34+
region_name = data.aws_region.replica[0].name
35+
kms_key_arn = var.dynamodb_enable_server_side_encryption ? aws_kms_key.replica[0].arn : null
36+
}
37+
}
38+
stream_enabled = var.dynamodb_enable_server_side_encryption ? true : null
39+
3140
tags = var.tags
3241
}

outputs.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ output "kms_key" {
44
}
55

66
output "kms_key_alias" {
7-
description = "The alias of the KMS customer master key used to encrypt state buckets."
7+
description = "The alias of the KMS customer master key used to encrypt state bucket and dynamodb."
88
value = aws_kms_key.this
99
}
1010

@@ -23,6 +23,11 @@ output "dynamodb_table" {
2323
value = aws_dynamodb_table.lock
2424
}
2525

26+
output "kms_key_replica" {
27+
description = "The KMS customer master key to encrypt replica bucket and dynamodb."
28+
value = try(aws_kms_key.replica[0], null)
29+
}
30+
2631
output "terraform_iam_policy" {
2732
description = "The IAM Policy to access remote state environment."
2833
value = var.terraform_iam_policy_create ? aws_iam_policy.terraform[0] : null

0 commit comments

Comments
 (0)