diff --git a/dynamo/main.tf b/dynamo/main.tf index 00e9326..93110f3 100644 --- a/dynamo/main.tf +++ b/dynamo/main.tf @@ -58,7 +58,26 @@ resource "aws_dynamodb_table" "table" { ) } -resource "aws_dynamodb_resource_policy" "require_ssl" { +data "aws_iam_policy_document" "policy_document" { + source_policy_documents = var.resource_policy == "" ? [ + templatefile( + "${path.module}/templates/dynamo_require_ssl.json.tpl", + { + table_arn = aws_dynamodb_table.table.arn + } + ) + ] : [ + var.resource_policy, + templatefile( + "${path.module}/templates/dynamo_require_ssl.json.tpl", + { + table_arn = aws_dynamodb_table.table.arn + } + ) + ] +} + +resource "aws_dynamodb_resource_policy" "resource_policy" { resource_arn = aws_dynamodb_table.table.arn - policy = templatefile("${path.module}/templates/dynamo_require_ssl.json.tpl", { table_arn = aws_dynamodb_table.table.arn }) + policy = data.aws_iam_policy_document.policy_document.json } diff --git a/dynamo/variables.tf b/dynamo/variables.tf index ac99d87..cf19e36 100644 --- a/dynamo/variables.tf +++ b/dynamo/variables.tf @@ -76,3 +76,7 @@ variable "stream_enabled" { variable "stream_view_type" { default = "NEW_IMAGE" } + +variable "resource_policy" { + default = "" +} \ No newline at end of file