Skip to content

Commit ad9975c

Browse files
committed
Apply suggested changes
1 parent cb1e89a commit ad9975c

File tree

9 files changed

+22
-178
lines changed

9 files changed

+22
-178
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ No modules.
9292
| [aws_appautoscaling_target.index_write](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_target) | resource |
9393
| [aws_appautoscaling_target.table_read](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_target) | resource |
9494
| [aws_appautoscaling_target.table_write](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_target) | resource |
95-
| [aws_dynamodb_resource_policy.table_resource_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_resource_policy) | resource |
95+
| [aws_dynamodb_resource_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_resource_policy) | resource |
9696
| [aws_dynamodb_table.autoscaled](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
9797
| [aws_dynamodb_table.autoscaled_gsi_ignore](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
9898
| [aws_dynamodb_table.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
@@ -121,7 +121,7 @@ No modules.
121121
| <a name="input_range_key"></a> [range\_key](#input\_range\_key) | The attribute to use as the range (sort) key. Must also be defined as an attribute | `string` | `null` | no |
122122
| <a name="input_read_capacity"></a> [read\_capacity](#input\_read\_capacity) | The number of read units for this table. If the billing\_mode is PROVISIONED, this field should be greater than 0 | `number` | `null` | no |
123123
| <a name="input_replica_regions"></a> [replica\_regions](#input\_replica\_regions) | Region names for creating replicas for a global DynamoDB table. | `any` | `[]` | no |
124-
| <a name="input_resource_based_policy_json"></a> [resource\_based\_policy\_json](#input\_resource\_based\_policy\_json) | The JSON definition of the resource-based policy. | `string` | `null` | no |
124+
| <a name="input_resource_policy"></a> [resource\_policy](#input\_resource\_policy) | The JSON definition of the resource-based policy. | `string` | `null` | no |
125125
| <a name="input_restore_date_time"></a> [restore\_date\_time](#input\_restore\_date\_time) | Time of the point-in-time recovery point to restore. | `string` | `null` | no |
126126
| <a name="input_restore_source_name"></a> [restore\_source\_name](#input\_restore\_source\_name) | Name of the table to restore. Must match the name of an existing table. | `string` | `null` | no |
127127
| <a name="input_restore_source_table_arn"></a> [restore\_source\_table\_arn](#input\_restore\_source\_table\_arn) | ARN of the source table to restore. Must be supplied for cross-region restores. | `string` | `null` | no |

examples/basic/main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ module "dynamodb_table" {
5050
max_write_request_units = 1
5151
}
5252

53+
resource_policy = <<POLICY
54+
{
55+
"Version": "2012-10-17",
56+
"Statement": [
57+
{
58+
"Sid": "AllowDummyRoleAccess",
59+
"Effect": "Allow",
60+
"Principal": {
61+
"AWS": "arn:aws:iam::222222222222:role/DummyRole"
62+
},
63+
"Action": "dynamodb:GetItem",
64+
"Resource": "__DYNAMODB_TABLE_ARN__"
65+
}
66+
]
67+
}
68+
POLICY
69+
5370
tags = {
5471
Terraform = "true"
5572
Environment = "staging"

examples/resource-based-policy/README.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

examples/resource-based-policy/main.tf

Lines changed: 0 additions & 83 deletions
This file was deleted.

examples/resource-based-policy/outputs.tf

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/resource-based-policy/variables.tf

Whitespace-only changes.

examples/resource-based-policy/versions.tf

Lines changed: 0 additions & 14 deletions
This file was deleted.

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ resource "aws_dynamodb_table" "autoscaled_gsi_ignore" {
378378
}
379379

380380
resource "aws_dynamodb_resource_policy" "this" {
381-
count = var.create_table && var.resource_based_policy_json != null ? 1 : 0
381+
count = var.create_table && var.resource_policy != null ? 1 : 0
382382

383383
resource_arn = try(aws_dynamodb_table.this[0].arn, aws_dynamodb_table.autoscaled[0].arn, aws_dynamodb_table.autoscaled_gsi_ignore[0].arn, "")
384-
policy = var.resource_based_policy_json
384+
policy = replace(var.resource_policy, "__DYNAMODB_TABLE_ARN__", try(aws_dynamodb_table.this[0].arn, aws_dynamodb_table.autoscaled[0].arn, aws_dynamodb_table.autoscaled_gsi_ignore[0].arn, ""))
385385
}

wrappers/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module "wrapper" {
2727
range_key = try(each.value.range_key, var.defaults.range_key, null)
2828
read_capacity = try(each.value.read_capacity, var.defaults.read_capacity, null)
2929
replica_regions = try(each.value.replica_regions, var.defaults.replica_regions, [])
30-
resource_based_policy_json = try(each.value.resource_based_policy_json, var.defaults.resource_based_policy_json, null)
30+
resource_policy = try(each.value.resource_policy, var.defaults.resource_policy, null)
3131
restore_date_time = try(each.value.restore_date_time, var.defaults.restore_date_time, null)
3232
restore_source_name = try(each.value.restore_source_name, var.defaults.restore_source_name, null)
3333
restore_source_table_arn = try(each.value.restore_source_table_arn, var.defaults.restore_source_table_arn, null)

0 commit comments

Comments
 (0)