diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 71da442..02bf72e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
- rev: v1.103.0
+ rev: v1.104.0
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
diff --git a/README.md b/README.md
index e889485..41e553f 100644
--- a/README.md
+++ b/README.md
@@ -147,8 +147,12 @@ No modules.
|------|-------------|
| [dynamodb\_table\_arn](#output\_dynamodb\_table\_arn) | ARN of the DynamoDB table |
| [dynamodb\_table\_id](#output\_dynamodb\_table\_id) | ID of the DynamoDB table |
-| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream. Only available when var.stream\_enabled is true |
-| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream\_enabled is true |
+| [dynamodb\_table\_replica\_arns](#output\_dynamodb\_table\_replica\_arns) | Map of the Table replicas ARNs |
+| [dynamodb\_table\_replica\_stream\_arns](#output\_dynamodb\_table\_replica\_stream\_arns) | Map of the Table replicas stream ARNs |
+| [dynamodb\_table\_replica\_stream\_labels](#output\_dynamodb\_table\_replica\_stream\_labels) | Map of the timestamps of the Table replicas stream |
+| [dynamodb\_table\_replicas](#output\_dynamodb\_table\_replicas) | Map of Table replicas by region |
+| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream |
+| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream |
## Authors
diff --git a/examples/autoscaling/README.md b/examples/autoscaling/README.md
index fd62ba1..377d4f5 100644
--- a/examples/autoscaling/README.md
+++ b/examples/autoscaling/README.md
@@ -52,6 +52,10 @@ No inputs.
|------|-------------|
| [dynamodb\_table\_arn](#output\_dynamodb\_table\_arn) | ARN of the DynamoDB table |
| [dynamodb\_table\_id](#output\_dynamodb\_table\_id) | ID of the DynamoDB table |
-| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream. Only available when var.stream\_enabled is true |
-| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream\_enabled is true |
+| [dynamodb\_table\_replica\_arns](#output\_dynamodb\_table\_replica\_arns) | Map of the Table replicas ARNs |
+| [dynamodb\_table\_replica\_stream\_arns](#output\_dynamodb\_table\_replica\_stream\_arns) | Map of the Table replicas stream ARNs |
+| [dynamodb\_table\_replica\_stream\_labels](#output\_dynamodb\_table\_replica\_stream\_labels) | Map of the timestamps of the Table replicas stream |
+| [dynamodb\_table\_replicas](#output\_dynamodb\_table\_replicas) | Map of Table replicas by region |
+| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream |
+| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream |
diff --git a/examples/autoscaling/outputs.tf b/examples/autoscaling/outputs.tf
index e21f490..a2687fc 100644
--- a/examples/autoscaling/outputs.tf
+++ b/examples/autoscaling/outputs.tf
@@ -9,11 +9,31 @@ output "dynamodb_table_id" {
}
output "dynamodb_table_stream_arn" {
- description = "The ARN of the Table Stream. Only available when var.stream_enabled is true"
+ description = "The ARN of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_arn
}
output "dynamodb_table_stream_label" {
- description = "A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true"
+ description = "A timestamp, in ISO 8601 format of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_label
}
+
+output "dynamodb_table_replicas" {
+ description = "Map of Table replicas by region"
+ value = module.dynamodb_table.dynamodb_table_replicas
+}
+
+output "dynamodb_table_replica_arns" {
+ description = "Map of the Table replicas ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_arns
+}
+
+output "dynamodb_table_replica_stream_arns" {
+ description = "Map of the Table replicas stream ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_arns
+}
+
+output "dynamodb_table_replica_stream_labels" {
+ description = "Map of the timestamps of the Table replicas stream"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_labels
+}
diff --git a/examples/basic/README.md b/examples/basic/README.md
index 062dca3..35f125f 100644
--- a/examples/basic/README.md
+++ b/examples/basic/README.md
@@ -52,6 +52,10 @@ No inputs.
|------|-------------|
| [dynamodb\_table\_arn](#output\_dynamodb\_table\_arn) | ARN of the DynamoDB table |
| [dynamodb\_table\_id](#output\_dynamodb\_table\_id) | ID of the DynamoDB table |
-| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream. Only available when var.stream\_enabled is true |
-| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream\_enabled is true |
+| [dynamodb\_table\_replica\_arns](#output\_dynamodb\_table\_replica\_arns) | Map of the Table replicas ARNs |
+| [dynamodb\_table\_replica\_stream\_arns](#output\_dynamodb\_table\_replica\_stream\_arns) | Map of the Table replicas stream ARNs |
+| [dynamodb\_table\_replica\_stream\_labels](#output\_dynamodb\_table\_replica\_stream\_labels) | Map of the timestamps of the Table replicas stream |
+| [dynamodb\_table\_replicas](#output\_dynamodb\_table\_replicas) | Map of Table replicas by region |
+| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream |
+| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream |
diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf
index e21f490..a2687fc 100644
--- a/examples/basic/outputs.tf
+++ b/examples/basic/outputs.tf
@@ -9,11 +9,31 @@ output "dynamodb_table_id" {
}
output "dynamodb_table_stream_arn" {
- description = "The ARN of the Table Stream. Only available when var.stream_enabled is true"
+ description = "The ARN of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_arn
}
output "dynamodb_table_stream_label" {
- description = "A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true"
+ description = "A timestamp, in ISO 8601 format of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_label
}
+
+output "dynamodb_table_replicas" {
+ description = "Map of Table replicas by region"
+ value = module.dynamodb_table.dynamodb_table_replicas
+}
+
+output "dynamodb_table_replica_arns" {
+ description = "Map of the Table replicas ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_arns
+}
+
+output "dynamodb_table_replica_stream_arns" {
+ description = "Map of the Table replicas stream ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_arns
+}
+
+output "dynamodb_table_replica_stream_labels" {
+ description = "Map of the timestamps of the Table replicas stream"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_labels
+}
diff --git a/examples/global-tables/README.md b/examples/global-tables/README.md
index 4898f72..ec3c601 100644
--- a/examples/global-tables/README.md
+++ b/examples/global-tables/README.md
@@ -28,7 +28,6 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 6.22 |
-| [aws.euwest2](#provider\_aws.euwest2) | >= 6.22 |
| [random](#provider\_random) | >= 2.0 |
## Modules
@@ -55,6 +54,10 @@ No inputs.
|------|-------------|
| [dynamodb\_table\_arn](#output\_dynamodb\_table\_arn) | ARN of the DynamoDB table |
| [dynamodb\_table\_id](#output\_dynamodb\_table\_id) | ID of the DynamoDB table |
-| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream. Only available when var.stream\_enabled is true |
-| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream\_enabled is true |
+| [dynamodb\_table\_replica\_arns](#output\_dynamodb\_table\_replica\_arns) | Map of the Table replicas ARNs |
+| [dynamodb\_table\_replica\_stream\_arns](#output\_dynamodb\_table\_replica\_stream\_arns) | Map of the Table replicas stream ARNs |
+| [dynamodb\_table\_replica\_stream\_labels](#output\_dynamodb\_table\_replica\_stream\_labels) | Map of the timestamps of the Table replicas stream |
+| [dynamodb\_table\_replicas](#output\_dynamodb\_table\_replicas) | Map of Table replicas by region |
+| [dynamodb\_table\_stream\_arn](#output\_dynamodb\_table\_stream\_arn) | The ARN of the Table Stream |
+| [dynamodb\_table\_stream\_label](#output\_dynamodb\_table\_stream\_label) | A timestamp, in ISO 8601 format of the Table Stream |
diff --git a/examples/global-tables/main.tf b/examples/global-tables/main.tf
index b5e59d2..fb00a1c 100644
--- a/examples/global-tables/main.tf
+++ b/examples/global-tables/main.tf
@@ -2,11 +2,6 @@ provider "aws" {
region = "eu-west-1"
}
-provider "aws" {
- alias = "euwest2"
- region = "eu-west-2"
-}
-
locals {
tags = {
Terraform = "true"
@@ -23,12 +18,14 @@ resource "random_pet" "this" {
}
resource "aws_kms_key" "primary" {
+ region = "eu-west-1"
+
description = "CMK for primary region"
tags = local.tags
}
resource "aws_kms_key" "secondary" {
- provider = aws.euwest2
+ region = "us-east-1"
description = "CMK for secondary region"
tags = local.tags
@@ -76,11 +73,10 @@ module "dynamodb_table" {
]
replica_regions = [{
- region_name = "eu-west-2"
- kms_key_arn = aws_kms_key.secondary.arn
- propagate_tags = true
- point_in_time_recovery = true
- deletion_protection_enabled = false
+ region_name = "us-east-1"
+ kms_key_arn = aws_kms_key.secondary.arn
+ propagate_tags = true
+ point_in_time_recovery = true
}]
tags = local.tags
diff --git a/examples/global-tables/outputs.tf b/examples/global-tables/outputs.tf
index e21f490..a2687fc 100644
--- a/examples/global-tables/outputs.tf
+++ b/examples/global-tables/outputs.tf
@@ -9,11 +9,31 @@ output "dynamodb_table_id" {
}
output "dynamodb_table_stream_arn" {
- description = "The ARN of the Table Stream. Only available when var.stream_enabled is true"
+ description = "The ARN of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_arn
}
output "dynamodb_table_stream_label" {
- description = "A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true"
+ description = "A timestamp, in ISO 8601 format of the Table Stream"
value = module.dynamodb_table.dynamodb_table_stream_label
}
+
+output "dynamodb_table_replicas" {
+ description = "Map of Table replicas by region"
+ value = module.dynamodb_table.dynamodb_table_replicas
+}
+
+output "dynamodb_table_replica_arns" {
+ description = "Map of the Table replicas ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_arns
+}
+
+output "dynamodb_table_replica_stream_arns" {
+ description = "Map of the Table replicas stream ARNs"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_arns
+}
+
+output "dynamodb_table_replica_stream_labels" {
+ description = "Map of the timestamps of the Table replicas stream"
+ value = module.dynamodb_table.dynamodb_table_replica_stream_labels
+}
diff --git a/examples/s3-import/README.md b/examples/s3-import/README.md
index 5867be6..f546f46 100644
--- a/examples/s3-import/README.md
+++ b/examples/s3-import/README.md
@@ -35,9 +35,9 @@ Note that this example may create resources which can cost money (AWS Elastic IP
|------|--------|---------|
| [import\_csv\_table](#module\_import\_csv\_table) | ../../ | n/a |
| [import\_json\_table](#module\_import\_json\_table) | ../../ | n/a |
-| [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.15 |
-| [s3\_import\_object\_csv](#module\_s3\_import\_object\_csv) | terraform-aws-modules/s3-bucket/aws//modules/object | ~> 3.15 |
-| [s3\_import\_object\_json](#module\_s3\_import\_object\_json) | terraform-aws-modules/s3-bucket/aws//modules/object | ~> 3.15 |
+| [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | >= 3.15 |
+| [s3\_import\_object\_csv](#module\_s3\_import\_object\_csv) | terraform-aws-modules/s3-bucket/aws//modules/object | >= 3.15 |
+| [s3\_import\_object\_json](#module\_s3\_import\_object\_json) | terraform-aws-modules/s3-bucket/aws//modules/object | >= 3.15 |
## Resources
diff --git a/examples/s3-import/main.tf b/examples/s3-import/main.tf
index 7228abc..7bd759c 100644
--- a/examples/s3-import/main.tf
+++ b/examples/s3-import/main.tf
@@ -79,7 +79,7 @@ module "import_csv_table" {
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
- version = "~> 3.15"
+ version = ">= 3.15"
bucket = "import-example-${random_pet.this.id}"
@@ -88,7 +88,7 @@ module "s3_bucket" {
module "s3_import_object_json" {
source = "terraform-aws-modules/s3-bucket/aws//modules/object"
- version = "~> 3.15"
+ version = ">= 3.15"
bucket = module.s3_bucket.s3_bucket_id
key = "import-json-${random_pet.this.id}/sample.json"
@@ -98,7 +98,7 @@ module "s3_import_object_json" {
module "s3_import_object_csv" {
source = "terraform-aws-modules/s3-bucket/aws//modules/object"
- version = "~> 3.15"
+ version = ">= 3.15"
bucket = module.s3_bucket.s3_bucket_id
key = "import-csv-${random_pet.this.id}/sample.csv"
diff --git a/outputs.tf b/outputs.tf
index 0d68576..0e70410 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -1,3 +1,10 @@
+locals {
+ replicas = { for v in try(aws_dynamodb_table.this[0].replica[*], aws_dynamodb_table.autoscaled[0].replica[*], aws_dynamodb_table.autoscaled_gsi_ignore[0].replica[*], []) : v.region_name => v }
+ replica_arns = { for v in local.replicas : v.region_name => v.arn }
+ replica_stream_arns = { for v in local.replicas : v.region_name => v.stream_arn }
+ replica_stream_labels = { for v in local.replicas : v.region_name => v.stream_label }
+}
+
output "dynamodb_table_arn" {
description = "ARN of the DynamoDB table"
value = local.dynamodb_table_arn
@@ -9,11 +16,31 @@ output "dynamodb_table_id" {
}
output "dynamodb_table_stream_arn" {
- description = "The ARN of the Table Stream. Only available when var.stream_enabled is true"
- value = var.stream_enabled ? try(aws_dynamodb_table.this[0].stream_arn, aws_dynamodb_table.autoscaled[0].stream_arn, aws_dynamodb_table.autoscaled_gsi_ignore[0].stream_arn, "") : null
+ description = "The ARN of the Table Stream"
+ value = try(aws_dynamodb_table.this[0].stream_arn, aws_dynamodb_table.autoscaled[0].stream_arn, aws_dynamodb_table.autoscaled_gsi_ignore[0].stream_arn, "")
}
output "dynamodb_table_stream_label" {
- description = "A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true"
- value = var.stream_enabled ? try(aws_dynamodb_table.this[0].stream_label, aws_dynamodb_table.autoscaled[0].stream_label, aws_dynamodb_table.autoscaled_gsi_ignore[0].stream_label, "") : null
+ description = "A timestamp, in ISO 8601 format of the Table Stream"
+ value = try(aws_dynamodb_table.this[0].stream_label, aws_dynamodb_table.autoscaled[0].stream_label, aws_dynamodb_table.autoscaled_gsi_ignore[0].stream_label, "")
+}
+
+output "dynamodb_table_replicas" {
+ description = "Map of Table replicas by region"
+ value = local.replicas
+}
+
+output "dynamodb_table_replica_arns" {
+ description = "Map of the Table replicas ARNs"
+ value = local.replica_arns
+}
+
+output "dynamodb_table_replica_stream_arns" {
+ description = "Map of the Table replicas stream ARNs"
+ value = local.replica_stream_arns
+}
+
+output "dynamodb_table_replica_stream_labels" {
+ description = "Map of the timestamps of the Table replicas stream"
+ value = local.replica_stream_labels
}