Skip to content

Commit c66c0a6

Browse files
Hamza-Azizhans-d
andauthored
feature: Add support for deletion_protection_enabled attribute for DynamoDB (#156)
* feat: support Dynamodb deletion_protection_enabled attribute * feat: support Dynamodb deletion_protection_enabled attribute * Generated readme * Update readme * Fix: make deletion_protection_enabled defaults to false * Update readme --------- Co-authored-by: Hans D <[email protected]>
1 parent 88aed7a commit c66c0a6

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ Available targets:
278278
| <a name="input_bucket_enabled"></a> [bucket\_enabled](#input\_bucket\_enabled) | Whether to create the S3 bucket. | `bool` | `true` | no |
279279
| <a name="input_bucket_ownership_enforced_enabled"></a> [bucket\_ownership\_enforced\_enabled](#input\_bucket\_ownership\_enforced\_enabled) | Set bucket object ownership to "BucketOwnerEnforced". Disables ACLs. | `bool` | `true` | no |
280280
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
281+
| <a name="input_deletion_protection_enabled"></a> [deletion\_protection\_enabled](#input\_deletion\_protection\_enabled) | A boolean that enables deletion protection for DynamoDB table | `bool` | `false` | no |
281282
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
282283
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
283284
| <a name="input_dynamodb_enabled"></a> [dynamodb\_enabled](#input\_dynamodb\_enabled) | Whether to create the DynamoDB table. | `bool` | `true` | no |

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
| <a name="input_bucket_enabled"></a> [bucket\_enabled](#input\_bucket\_enabled) | Whether to create the S3 bucket. | `bool` | `true` | no |
6565
| <a name="input_bucket_ownership_enforced_enabled"></a> [bucket\_ownership\_enforced\_enabled](#input\_bucket\_ownership\_enforced\_enabled) | Set bucket object ownership to "BucketOwnerEnforced". Disables ACLs. | `bool` | `true` | no |
6666
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
67+
| <a name="input_deletion_protection_enabled"></a> [deletion\_protection\_enabled](#input\_deletion\_protection\_enabled) | A boolean that enables deletion protection for DynamoDB table | `bool` | `false` | no |
6768
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
6869
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
6970
| <a name="input_dynamodb_enabled"></a> [dynamodb\_enabled](#input\_dynamodb\_enabled) | Whether to create the DynamoDB table. | `bool` | `true` | no |

main.tf

+6-5
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,12 @@ module "dynamodb_table_label" {
257257
}
258258

259259
resource "aws_dynamodb_table" "with_server_side_encryption" {
260-
count = local.dynamodb_enabled ? 1 : 0
261-
name = local.dynamodb_table_name
262-
billing_mode = var.billing_mode
263-
read_capacity = var.billing_mode == "PROVISIONED" ? var.read_capacity : null
264-
write_capacity = var.billing_mode == "PROVISIONED" ? var.write_capacity : null
260+
count = local.dynamodb_enabled ? 1 : 0
261+
name = local.dynamodb_table_name
262+
billing_mode = var.billing_mode
263+
read_capacity = var.billing_mode == "PROVISIONED" ? var.read_capacity : null
264+
write_capacity = var.billing_mode == "PROVISIONED" ? var.write_capacity : null
265+
deletion_protection_enabled = var.deletion_protection_enabled
265266

266267
# https://www.terraform.io/docs/backends/types/s3.html#dynamodb_table
267268
hash_key = "LockID"

variables.tf

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ variable "force_destroy" {
3434
default = false
3535
}
3636

37+
variable "deletion_protection_enabled" {
38+
type = bool
39+
description = "A boolean that enables deletion protection for DynamoDB table"
40+
default = false
41+
}
42+
43+
3744
variable "mfa_delete" {
3845
type = bool
3946
description = "A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 )"

0 commit comments

Comments
 (0)