Skip to content

Commit

Permalink
fix: S3 bucket force destroy (#324)
Browse files Browse the repository at this point in the history
* fix: S3 bucket force destroy

* fix: S3 bucket force destroy

* fix: S3 bucket force destroy

* fix: S3 bucket force destroy
  • Loading branch information
shivawandb authored Jan 17, 2025
1 parent 6d0dfae commit de63184
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
9 changes: 5 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ locals {
}

module "networking" {
source = "./modules/networking"
namespace = var.namespace
create_vpc = var.create_vpc
enable_flow_log = var.enable_flow_log
source = "./modules/networking"
namespace = var.namespace
create_vpc = var.create_vpc
enable_flow_log = var.enable_flow_log
keep_flow_log_bucket = var.keep_flow_log_bucket

cidr = var.network_cidr
private_subnet_cidrs = var.network_private_subnet_cidrs
Expand Down
6 changes: 3 additions & 3 deletions modules/networking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "aws_flow_log" "vpc_flow_logs" {
}

resource "aws_s3_bucket" "flow_log" {
count = var.create_vpc && var.enable_flow_log ? 1 : 0

bucket = "${var.namespace}-vpc-flow-logs"
count = (var.create_vpc && var.enable_flow_log) || var.keep_flow_log_bucket ? 1 : 0
bucket = "${var.namespace}-vpc-flow-logs"
force_destroy = true
}
6 changes: 6 additions & 0 deletions modules/networking/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ variable "enable_flow_log" {
description = "Controls whether VPC Flow Logs are enabled"
type = bool
default = false
}

variable "keep_flow_log_bucket" {
description = "Controls whether S3 bucket storing VPC Flow Logs will be kept"
type = bool
default = true
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ variable "enable_flow_log" {
default = false
}

variable "keep_flow_log_bucket" {
description = "Controls whether S3 bucket storing VPC Flow Logs will be kept"
type = bool
default = true
}

variable "network_id" {
default = ""
description = "The identity of the VPC in which resources will be deployed."
Expand Down

0 comments on commit de63184

Please sign in to comment.