Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic filter for subnets and NACLs #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions _data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ data "aws_subnet_ids" "requester" {
vpc_id = var.vpc_id

filter {
name = "tag:Scheme"
values = ["transit"]
name = var.requester_transit_subnets_filter.name
values = var.requester_transit_subnets_filter.values
}
}

Expand All @@ -24,30 +24,27 @@ data "aws_subnet" "requester" {
data "aws_subnet_ids" "accepter_public" {
provider = aws.peer
vpc_id = var.peer_vpc_id

filter {
name = "tag:Scheme"
values = ["public"]
name = var.accepter_public_subnets_filter.name
values = var.accepter_public_subnets_filter.values
}
}

data "aws_subnet_ids" "accepter_private" {
provider = aws.peer
vpc_id = var.peer_vpc_id

filter {
name = "tag:Scheme"
values = ["private"]
name = var.accepter_private_subnets_filter.name
values = var.accepter_private_subnets_filter.values
}
}

data "aws_subnet_ids" "accepter_secure" {
provider = aws.peer
vpc_id = var.peer_vpc_id

filter {
name = "tag:Scheme"
values = ["secure"]
name = var.accepter_secure_subnets_filter.name
values = var.accepter_secure_subnets_filter.values
}
}

Expand Down Expand Up @@ -78,33 +75,36 @@ data "aws_network_acls" "accepter_public" {
provider = aws.peer
vpc_id = var.peer_vpc_id

tags = {
Scheme = "public"
filter {
name = var.accepter_private_nacls_filter.name
values = var.accepter_private_nacls_filter.values
}
}

data "aws_network_acls" "accepter_private" {
provider = aws.peer
vpc_id = var.peer_vpc_id

tags = {
Scheme = "private"
filter {
name = var.accepter_private_nacls_filter.name
values = var.accepter_private_nacls_filter.values
}
}

data "aws_network_acls" "accepter_secure" {
provider = aws.peer
vpc_id = var.peer_vpc_id

tags = {
Scheme = "secure"
filter {
name = var.accepter_private_nacls_filter.name
values = var.accepter_private_nacls_filter.values
}
}

data "aws_network_acls" "requester" {
vpc_id = var.vpc_id

tags = {
Scheme = "transit"
filter {
name = var.requester_transit_nacls_filter.name
values = var.requester_transit_nacls_filter.values
}
}
72 changes: 72 additions & 0 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,75 @@ variable "serial" {
variable "accepter_region" {
description = "Region of acccepter"
}

#===== subnet variables =====#
variable "accepter_public_subnets_filter" {
type = object({
name = string,
values = list(string)
})
description = "List of public subnet IDs of accepter"
default = { name = "tag:Scheme", values = ["public"] }
}

variable "accepter_private_subnets_filter" {
type = object({
name = string,
values = list(string)
})
description = "List of private subnet IDs of accepter"
default = { name = "tag:Scheme", values = ["private"] }
}

variable "accepter_secure_subnets_filter" {
type = object({
name = string,
values = list(string)
})
description = "List of secure subnet IDs of accepter"
default = { name = "tag:Scheme", values = ["secure"] }
}

variable "requester_transit_subnets_filter" {
type = object({
name = string,
values = list(string)
})
description = "List of secure subnet IDs of accepter"
default = { name = "tag:Scheme", values = ["transit"] }
}

#===== nacls filter =====#
variable "accepter_public_nacls_filter" {
type = object({
name = string,
values = list(string)
})
description = "Filter of public NACLs"
default = { name = "tag:Scheme", values = ["public"] }
}
variable "accepter_private_nacls_filter" {
type = object({
name = string,
values = list(string)
})
description = "Filter of private NACLs"
default = { name = "tag:Scheme", values = ["private"] }
}
variable "accepter_secure_nacls_filter" {
type = object({
name = string,
values = list(string)
})
description = "Filter of secure NACLs"
default = { name = "tag:Scheme", values = ["secure"] }
}

variable "requester_transit_nacls_filter" {
type = object({
name = string,
values = list(string)
})
description = "Filter of transit NACLs"
default = { name = "tag:Scheme", values = ["transit"] }
}
Loading