Skip to content

Commit

Permalink
feat: add a deletion protection flag for DynamoDB table (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
nozaq authored Dec 21, 2023
1 parent b2fc891 commit 41ab8a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
41 changes: 21 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "Terraform",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/terraform:1": {
"version": "latest",
"installTerraformDocs": true
}
},
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig"
]
}
},
"postCreateCommand": "pre-commit install"
}
"name": "Terraform",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/terraform:1": {
"version": "latest",
"installTerraformDocs": true
}
},
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig",
"GitHub.copilot"
]
}
},
"postCreateCommand": "pre-commit install"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ See [the official document](https://www.terraform.io/docs/backends/types/s3.html

| Name | Description | Type | Required |
|------|-------------|------|:--------:|
| <a name="input_dynamodb_deletion_protection_enabled"></a> [dynamodb\_deletion\_protection\_enabled](#input\_dynamodb\_deletion\_protection\_enabled) | Whether or not to enable deletion protection on the DynamoDB table | `bool` | no |
| <a name="input_dynamodb_enable_server_side_encryption"></a> [dynamodb\_enable\_server\_side\_encryption](#input\_dynamodb\_enable\_server\_side\_encryption) | Whether or not to enable encryption at rest using an AWS managed KMS customer master key (CMK) | `bool` | no |
| <a name="input_dynamodb_table_billing_mode"></a> [dynamodb\_table\_billing\_mode](#input\_dynamodb\_table\_billing\_mode) | Controls how you are charged for read and write throughput and how you manage capacity. | `string` | no |
| <a name="input_dynamodb_table_name"></a> [dynamodb\_table\_name](#input\_dynamodb\_table\_name) | The name of the DynamoDB table to use for state locking. | `string` | no |
Expand Down
7 changes: 4 additions & 3 deletions dynamo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ locals {
}

resource "aws_dynamodb_table" "lock" {
name = var.dynamodb_table_name
billing_mode = var.dynamodb_table_billing_mode
hash_key = local.lock_key_id
name = var.dynamodb_table_name
billing_mode = var.dynamodb_table_billing_mode
hash_key = local.lock_key_id
deletion_protection_enabled = var.dynamodb_deletion_protection_enabled

attribute {
name = local.lock_key_id
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ variable "dynamodb_enable_server_side_encryption" {
default = false
}

variable "dynamodb_deletion_protection_enabled" {
description = "Whether or not to enable deletion protection on the DynamoDB table"
type = bool
default = true
}

#---------------------------------------------------------------------------------------------------
# Optionally specifying a fixed bucket name
#---------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 41ab8a9

Please sign in to comment.