Skip to content

Commit bce94be

Browse files
authored
feat: Add deletion_protection_enabled (#70)
* add deletion_protection_enabled * pre-commit run * feedback changes --------- Co-authored-by: magreenbaum <magreenbaum>
1 parent 2589b19 commit bce94be

File tree

6 files changed

+40
-29
lines changed

6 files changed

+40
-29
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the
5353
| Name | Version |
5454
|------|---------|
5555
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
56-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.23 |
56+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.59 |
5757

5858
## Providers
5959

6060
| Name | Version |
6161
|------|---------|
62-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.23 |
62+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.59 |
6363

6464
## Modules
6565

@@ -92,6 +92,7 @@ No modules.
9292
| <a name="input_autoscaling_write"></a> [autoscaling\_write](#input\_autoscaling\_write) | A map of write autoscaling settings. `max_capacity` is the only required key. See example in examples/autoscaling | `map(string)` | `{}` | no |
9393
| <a name="input_billing_mode"></a> [billing\_mode](#input\_billing\_mode) | Controls how you are billed for read/write throughput and how you manage capacity. The valid values are PROVISIONED or PAY\_PER\_REQUEST | `string` | `"PAY_PER_REQUEST"` | no |
9494
| <a name="input_create_table"></a> [create\_table](#input\_create\_table) | Controls if DynamoDB table and associated resources are created | `bool` | `true` | no |
95+
| <a name="input_deletion_protection_enabled"></a> [deletion\_protection\_enabled](#input\_deletion\_protection\_enabled) | Enables deletion protection for table | `bool` | `null` | no |
9596
| <a name="input_global_secondary_indexes"></a> [global\_secondary\_indexes](#input\_global\_secondary\_indexes) | Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc. | `any` | `[]` | no |
9697
| <a name="input_hash_key"></a> [hash\_key](#input\_hash\_key) | The attribute to use as the hash (partition) key. Must also be defined as an attribute | `string` | `null` | no |
9798
| <a name="input_local_secondary_indexes"></a> [local\_secondary\_indexes](#input\_local\_secondary\_indexes) | Describe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource. | `any` | `[]` | no |

examples/basic/main.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ resource "random_pet" "this" {
99
module "dynamodb_table" {
1010
source = "../../"
1111

12-
name = "my-table-${random_pet.this.id}"
13-
hash_key = "id"
14-
range_key = "title"
15-
table_class = "STANDARD"
12+
name = "my-table-${random_pet.this.id}"
13+
hash_key = "id"
14+
range_key = "title"
15+
table_class = "STANDARD"
16+
deletion_protection_enabled = false
1617

1718
attributes = [
1819
{

main.tf

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
resource "aws_dynamodb_table" "this" {
22
count = var.create_table && !var.autoscaling_enabled ? 1 : 0
33

4-
name = var.name
5-
billing_mode = var.billing_mode
6-
hash_key = var.hash_key
7-
range_key = var.range_key
8-
read_capacity = var.read_capacity
9-
write_capacity = var.write_capacity
10-
stream_enabled = var.stream_enabled
11-
stream_view_type = var.stream_view_type
12-
table_class = var.table_class
4+
name = var.name
5+
billing_mode = var.billing_mode
6+
hash_key = var.hash_key
7+
range_key = var.range_key
8+
read_capacity = var.read_capacity
9+
write_capacity = var.write_capacity
10+
stream_enabled = var.stream_enabled
11+
stream_view_type = var.stream_view_type
12+
table_class = var.table_class
13+
deletion_protection_enabled = var.deletion_protection_enabled
1314

1415
ttl {
1516
enabled = var.ttl_enabled
@@ -87,15 +88,16 @@ resource "aws_dynamodb_table" "this" {
8788
resource "aws_dynamodb_table" "autoscaled" {
8889
count = var.create_table && var.autoscaling_enabled ? 1 : 0
8990

90-
name = var.name
91-
billing_mode = var.billing_mode
92-
hash_key = var.hash_key
93-
range_key = var.range_key
94-
read_capacity = var.read_capacity
95-
write_capacity = var.write_capacity
96-
stream_enabled = var.stream_enabled
97-
stream_view_type = var.stream_view_type
98-
table_class = var.table_class
91+
name = var.name
92+
billing_mode = var.billing_mode
93+
hash_key = var.hash_key
94+
range_key = var.range_key
95+
read_capacity = var.read_capacity
96+
write_capacity = var.write_capacity
97+
stream_enabled = var.stream_enabled
98+
stream_view_type = var.stream_view_type
99+
table_class = var.table_class
100+
deletion_protection_enabled = var.deletion_protection_enabled
99101

100102
ttl {
101103
enabled = var.ttl_enabled

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,9 @@ variable "table_class" {
161161
type = string
162162
default = null
163163
}
164+
165+
variable "deletion_protection_enabled" {
166+
description = "Enables deletion protection for table"
167+
type = bool
168+
default = null
169+
}

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.23"
7+
version = ">= 4.59"
88
}
99
}
1010
}

wrappers/main.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ module "wrapper" {
3333
scale_out_cooldown = 0
3434
target_value = 70
3535
})
36-
autoscaling_read = try(each.value.autoscaling_read, var.defaults.autoscaling_read, {})
37-
autoscaling_write = try(each.value.autoscaling_write, var.defaults.autoscaling_write, {})
38-
autoscaling_indexes = try(each.value.autoscaling_indexes, var.defaults.autoscaling_indexes, {})
39-
table_class = try(each.value.table_class, var.defaults.table_class, null)
36+
autoscaling_read = try(each.value.autoscaling_read, var.defaults.autoscaling_read, {})
37+
autoscaling_write = try(each.value.autoscaling_write, var.defaults.autoscaling_write, {})
38+
autoscaling_indexes = try(each.value.autoscaling_indexes, var.defaults.autoscaling_indexes, {})
39+
table_class = try(each.value.table_class, var.defaults.table_class, null)
40+
deletion_protection_enabled = try(each.value.deletion_protection_enabled, var.defaults.deletion_protection_enabled, null)
4041
}

0 commit comments

Comments
 (0)