Skip to content

Commit

Permalink
Adds new input variable tags_s3_bucket (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofhouse committed Oct 30, 2021
1 parent a52d2a4 commit 3fb36e4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module "statics_deploy" {

deployment_name = var.deployment_name
tags = var.tags
tags_s3_bucket = var.tags_s3_bucket

debug_use_local_packages = var.debug_use_local_packages
tf_next_module_root = path.module
Expand Down Expand Up @@ -199,6 +200,7 @@ module "proxy_config" {

deployment_name = var.deployment_name
tags = var.tags
tags_s3_bucket = var.tags_s3_bucket
}

#####################
Expand Down
2 changes: 1 addition & 1 deletion modules/cloudfront-proxy-config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "aws_s3_bucket" "proxy_config_store" {
bucket_prefix = "${var.deployment_name}-tfn-config"
acl = "private"
force_destroy = true
tags = var.tags
tags = merge(var.tags, var.tags_s3_bucket)
}

data "aws_iam_policy_document" "cf_access" {
Expand Down
5 changes: 5 additions & 0 deletions modules/cloudfront-proxy-config/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ variable "tags" {
type = map(string)
default = {}
}

variable "tags_s3_bucket" {
type = map(string)
default = {}
}
6 changes: 4 additions & 2 deletions modules/statics-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ resource "aws_s3_bucket" "static_upload" {
bucket_prefix = "${var.deployment_name}-tfn-deploy"
acl = "private"
force_destroy = true
tags = var.tags

# We are using versioning here to ensure that no file gets overridden at upload
versioning {
enabled = true
}

tags = merge(var.tags, var.tags_s3_bucket)
}

resource "aws_s3_bucket_notification" "on_create" {
Expand All @@ -39,7 +40,6 @@ resource "aws_s3_bucket" "static_deploy" {
bucket_prefix = "${var.deployment_name}-tfn-static"
acl = "private"
force_destroy = true
tags = var.tags

lifecycle_rule {
id = "Expire static assets"
Expand All @@ -53,6 +53,8 @@ resource "aws_s3_bucket" "static_deploy" {
days = var.expire_static_assets > 0 ? var.expire_static_assets : 0
}
}

tags = merge(var.tags, var.tags_s3_bucket)
}

# CloudFront permissions for the bucket
Expand Down
5 changes: 5 additions & 0 deletions modules/statics-deploy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ variable "tags" {
default = {}
}

variable "tags_s3_bucket" {
type = map(string)
default = {}
}

#####################
# Deployment creation
#####################
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ variable "tags" {
default = {}
}

variable "tags_s3_bucket" {
description = "Tag metadata to label AWS S3 buckets. Overrides tags with the same name in input variable tags."
type = map(string)
default = {}
}

######################
# Multiple Deployments
######################
Expand Down

0 comments on commit 3fb36e4

Please sign in to comment.