Skip to content

Commit 41a9aa5

Browse files
Enable dynamodb switch (#65)
* Update variables.tf * Update main.tf * Updated README.md Co-authored-by: actions-bot <[email protected]>
1 parent 6126606 commit 41a9aa5

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Available targets:
191191
192192
```
193193
<!-- markdownlint-restore -->
194+
<!-- markdownlint-disable -->
194195
## Requirements
195196

196197
| Name | Version |
@@ -222,6 +223,7 @@ Available targets:
222223
| block\_public\_policy | Whether Amazon S3 should block public bucket policies for this bucket | `bool` | `true` | no |
223224
| context | Default context to use for passing state between label invocations | <pre>object({<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> enabled = bool<br> delimiter = string<br> attributes = list(string)<br> label_order = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": "",<br> "enabled": true,<br> "environment": "",<br> "label_order": [],<br> "name": "",<br> "namespace": "",<br> "regex_replace_chars": "",<br> "stage": "",<br> "tags": {}<br>}</pre> | no |
224225
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
226+
| enable\_dynamodb | Enable DynamoDB Locking | `bool` | `true` | no |
225227
| enable\_point\_in\_time\_recovery | Enable DynamoDB point-in-time recovery | `bool` | `false` | no |
226228
| enable\_public\_access\_block | Enable Bucket Public Access Block | `bool` | `true` | no |
227229
| enable\_server\_side\_encryption | Enable DynamoDB server-side encryption | `bool` | `true` | no |
@@ -261,6 +263,7 @@ Available targets:
261263
| s3\_bucket\_id | S3 bucket ID |
262264
| terraform\_backend\_config | Rendered Terraform backend config file |
263265

266+
<!-- markdownlint-restore -->
264267

265268

266269

docs/terraform.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable -->
12
## Requirements
23

34
| Name | Version |
@@ -29,6 +30,7 @@
2930
| block\_public\_policy | Whether Amazon S3 should block public bucket policies for this bucket | `bool` | `true` | no |
3031
| context | Default context to use for passing state between label invocations | <pre>object({<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> enabled = bool<br> delimiter = string<br> attributes = list(string)<br> label_order = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": "",<br> "enabled": true,<br> "environment": "",<br> "label_order": [],<br> "name": "",<br> "namespace": "",<br> "regex_replace_chars": "",<br> "stage": "",<br> "tags": {}<br>}</pre> | no |
3132
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
33+
| enable\_dynamodb | Enable DynamoDB Locking | `bool` | `true` | no |
3234
| enable\_point\_in\_time\_recovery | Enable DynamoDB point-in-time recovery | `bool` | `false` | no |
3335
| enable\_public\_access\_block | Enable Bucket Public Access Block | `bool` | `true` | no |
3436
| enable\_server\_side\_encryption | Enable DynamoDB server-side encryption | `bool` | `true` | no |
@@ -68,3 +70,4 @@
6870
| s3\_bucket\_id | S3 bucket ID |
6971
| terraform\_backend\_config | Rendered Terraform backend config file |
7072

73+
<!-- markdownlint-restore -->

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,13 @@ resource "aws_s3_bucket_public_access_block" "default" {
156156

157157
module "dynamodb_table_label" {
158158
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.17.0"
159+
enabled = var.enable_dynamodb
159160
context = module.base_label.context
160161
attributes = compact(concat(var.attributes, ["lock"]))
161162
}
162163

163164
resource "aws_dynamodb_table" "with_server_side_encryption" {
164-
count = var.enable_server_side_encryption ? 1 : 0
165+
count = var.enable_dynamodb && var.enable_server_side_encryption ? 1 : 0
165166
name = module.dynamodb_table_label.id
166167
billing_mode = var.billing_mode
167168
read_capacity = var.billing_mode == "PROVISIONED" ? var.read_capacity : null
@@ -195,7 +196,7 @@ resource "aws_dynamodb_table" "with_server_side_encryption" {
195196
}
196197

197198
resource "aws_dynamodb_table" "without_server_side_encryption" {
198-
count = var.enable_server_side_encryption ? 0 : 1
199+
count = var.enable_dynamodb && var.enable_server_side_encryption ? 0 : 1
199200
name = module.dynamodb_table_label.id
200201
billing_mode = var.billing_mode
201202
read_capacity = var.billing_mode == "PROVISIONED" ? var.read_capacity : null

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ variable "enable_public_access_block" {
144144
default = true
145145
}
146146

147+
variable "enable_dynamodb" {
148+
type = bool
149+
description = "Enable DynamoDB Locking"
150+
default = true
151+
}
152+
147153
variable "block_public_acls" {
148154
type = bool
149155
description = "Whether Amazon S3 should block public ACLs for this bucket"

0 commit comments

Comments
 (0)