Skip to content

Commit 3e1ca2a

Browse files
committed
Add enabled option
1 parent 540af5e commit 3e1ca2a

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

main.tf

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,34 @@
2020
# create s3 bucket and set policy
2121
# TODO: setup encryption
2222

23+
# https://www.terraform.io/docs/providers/aws/r/aws_s3_bucket.html
24+
# https://www.terraform.io/docs/providers/aws/r/aws_s3_bucket_policy.html
25+
# https://www.terraform.io/docs/providers/aws/r/aws_s3_bucket_notification.html
26+
# https://www.terraform.io/docs/providers/aws/r/aws_s3_bucket_object.html
27+
28+
module "enabled" {
29+
source = "devops-workflow/boolean/local"
30+
version = "0.1.1"
31+
value = "${var.enabled}"
32+
}
33+
34+
/*
35+
module "label" {
36+
source = "devops-workflow/label/local"
37+
version = "0.1.3"
38+
organization = "${var.organization}"
39+
name = "${var.name}"
40+
namespace-env = "${var.namespace-env}"
41+
namespace-org = "${var.namespace-org}"
42+
environment = "${var.environment}"
43+
delimiter = "${var.delimiter}"
44+
attributes = "${var.attributes}"
45+
tags = "${var.tags}"
46+
}
47+
*/
48+
2349
resource "aws_s3_bucket" "this" {
24-
count = "${length(var.names)}"
50+
count = "${module.enabled.value ? length(var.names) : 0}"
2551
bucket = "${var.namespaced ?
2652
format("%s-%s-%s", var.org, var.environment, replace(element(var.names, count.index), "_", "-")) :
2753
format("%s-%s", var.org, replace(element(var.names, count.index), "_", "-"))}"

variables.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ variable "tags" {
1717
description = "A map of tags to add to all resources"
1818
default = {}
1919
}
20-
2120
variable "org" {
2221
description = "Organization name to prefix S3 buckets with"
2322
}
2423

24+
variable "enabled" {
25+
description = "Set to false to prevent the module from creating anything"
26+
default = true
27+
}
28+
2529
// Module specific Variables
2630

2731
variable "principal" {

0 commit comments

Comments
 (0)