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

feat: providing granuarity on network ACLs #471

Merged
merged 24 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2c59cae
refactor: modified cidr references
imprateeksh Mar 22, 2023
b7a3274
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 24, 2023
3604bfd
refactor: reverted cidr references
imprateeksh Mar 24, 2023
b91ad20
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 25, 2023
00aa32a
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 27, 2023
3451029
feat: reducing acl
imprateeksh Mar 28, 2023
daa9e4f
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 28, 2023
1aefc99
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 28, 2023
9f66660
feat: reducing acl
imprateeksh Mar 28, 2023
e95b26d
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 28, 2023
8f69203
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 29, 2023
f8cfce6
refactor: utilizing data source to get addresses
imprateeksh Mar 29, 2023
a308c8b
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 29, 2023
da828a5
feat: added data source to fetch address prefixes
imprateeksh Mar 29, 2023
96e1d6c
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 29, 2023
5184135
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 30, 2023
f5fa724
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 30, 2023
a27bdd0
Merge branch 'main' into 357-acl-reduce
vbontempi Mar 30, 2023
459cc8e
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 30, 2023
a828cb1
fix: added dependency for data source
imprateeksh Mar 30, 2023
7ed22ea
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 31, 2023
4815a89
Merge branch 'main' into 357-acl-reduce
imprateeksh Mar 31, 2023
d70eea4
Merge branch 'main' into 357-acl-reduce
vburckhardt Mar 31, 2023
b95b7cb
fix: ensure address list used for acl contains subnet prefixes
vburckhardt Mar 31, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ You need the following permissions to run this module.
| [ibm_is_vpc_address_prefix.subnet_prefix](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpc_address_prefix) | resource |
| [ibm_is_vpc_routing_table.route_table](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpc_routing_table) | resource |
| [ibm_is_vpc_routing_table_route.routing_table_routes](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpc_routing_table_route) | resource |
| [ibm_is_vpc_address_prefixes.get_address_prefixes](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/is_vpc_address_prefixes) | data source |

## Inputs

Expand Down
1 change: 1 addition & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ module "slz_vpc" {
create_authorization_policy_vpc_to_cos = var.create_authorization_policy_vpc_to_cos
existing_cos_instance_guid = ibm_resource_instance.cos_instance[0].guid
existing_storage_bucket_name = ibm_cos_bucket.cos_bucket[0].bucket_name
address_prefixes = var.address_prefixes
}
18 changes: 18 additions & 0 deletions examples/default/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,21 @@ variable "create_authorization_policy_vpc_to_cos" {
type = bool
default = true
}

variable "address_prefixes" {
description = "OPTIONAL - IP range that will be defined for the VPC for a certain location. Use only with manual address prefixes"
type = object({
zone-1 = optional(list(string))
zone-2 = optional(list(string))
zone-3 = optional(list(string))
})
default = {
zone-1 = ["10.10.10.0/24", "10.10.12.0/24"]
zone-2 = ["10.20.10.0/24"]
zone-3 = ["10.30.10.0/24"]
}
validation {
error_message = "Keys for `use_public_gateways` must be in the order `zone-1`, `zone-2`, `zone-3`."
condition = var.address_prefixes == null ? true : (keys(var.address_prefixes)[0] == "zone-1" && keys(var.address_prefixes)[1] == "zone-2" && keys(var.address_prefixes)[2] == "zone-3")
}
}
17 changes: 15 additions & 2 deletions module-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
},
"pos": {
"filename": "network_acls.tf",
"line": 133
"line": 141
}
},
"ibm_is_public_gateway.gateway": {
Expand Down Expand Up @@ -651,7 +651,20 @@
}
}
},
"data_resources": {},
"data_resources": {
"data.ibm_is_vpc_address_prefixes.get_address_prefixes": {
"mode": "data",
"type": "ibm_is_vpc_address_prefixes",
"name": "get_address_prefixes",
"provider": {
"name": "ibm"
},
"pos": {
"filename": "network_acls.tf",
"line": 5
}
}
},
"module_calls": {
"dynamic_values": {
"name": "dynamic_values",
Expand Down
24 changes: 16 additions & 8 deletions network_acls.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# Network ACL
##############################################################################

data "ibm_is_vpc_address_prefixes" "get_address_prefixes" {
imprateeksh marked this conversation as resolved.
Show resolved Hide resolved
vpc = ibm_is_vpc.vpc.id
}

locals {
ibm_cloud_internal_rules = [
# IaaS and PaaS Rules. Note that this coarse grained list will be narrowed in upcoming releases.
Expand Down Expand Up @@ -47,31 +51,35 @@ locals {
}
]

vpc_connectivity_rules = [
# All connectivity across any subnet within VPC
# TODO: narrow down to VPC address spaces
vpc_inbound_rule = [
for address in data.ibm_is_vpc_address_prefixes.get_address_prefixes.address_prefixes :
{
name = "ibmflow-allow-vpc-connectivity-inbound"
name = "ibmflow-allow-vpc-connectivity-inbound-${substr(address.name, 0, 5)}" # Providing unique rule names
action = "allow"
source = var.network_cidr != null ? var.network_cidr : "0.0.0.0/0"
source = address.cidr
destination = var.network_cidr != null ? var.network_cidr : "0.0.0.0/0"
direction = "inbound"
tcp = null
udp = null
icmp = null
},
}
]
vpc_outbound_rule = [
for address in data.ibm_is_vpc_address_prefixes.get_address_prefixes.address_prefixes :
{
name = "ibmflow-allow-vpc-connectivity-outbound"
name = "ibmflow-allow-vpc-connectivity-outbound-${substr(address.name, 0, 5)}"
action = "allow"
source = var.network_cidr != null ? var.network_cidr : "0.0.0.0/0"
destination = var.network_cidr != null ? var.network_cidr : "0.0.0.0/0"
destination = address.cidr
direction = "outbound"
tcp = null
udp = null
icmp = null
}
]

vpc_connectivity_rules = distinct(flatten(concat(local.vpc_inbound_rule, local.vpc_outbound_rule)))

deny_all_rules = [
{
name = "ibmflow-deny-all-inbound"
Expand Down