Skip to content

Commit 2d8d25b

Browse files
authored
feat: added pre-wired rule for icd-databases in fscloud submodule (#294)
1 parent 3eb5aa7 commit 2d8d25b

File tree

6 files changed

+44
-19
lines changed

6 files changed

+44
-19
lines changed

examples/fscloud/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
This example demonstrates how to use the [fscloud profile](../../profiles/fscloud/) module to lay out a complete "secure by default" coarse-grained CBR topology in a given account.
44

55
This examples is designed to show case some of the key customization options for the module. In addition to the pre-wired CBR rules documented at [fscloud profile](../../profiles/fscloud/), this examples show how to customize the module to:
6-
1. Open up network traffic flow from ICD mongodb, ICD Postgresql to the Key Protect private endpoints
7-
2. Open up network traffic flow from Schematics to Key Protect public endpoints
8-
3. Open up network traffic flow from a block of IPs to the Schematics public endpoint
9-
4. Open up network traffic flow from the VPC created in this example to ICD postgresql private endpoints
6+
1. Open up network traffic flow from ICD mongodb, ICD Postgresql to the Key Protect private endpoints.
7+
2. Open up network traffic flow from Schematics to Key Protect public endpoints.
8+
3. Open up network traffic flow from a block of IPs to the Schematics public endpoint.
9+
4. Open up network traffic flow from the VPC created in this example to ICD postgresql private endpoints.
1010

1111
Context: this examples covers a "pseudo" real-world scenario where:
12-
1. ICD Mongodb, and Postgresql instances are encrypted using keys storage in Key Protect.
12+
1. ICD Mongodb and Postgresql instances are encrypted using keys storage in Key Protect.
1313
2. Schematics is used to execute terraform that create Key Protect keys and key ring over its public endpoint.
1414
3. Operators use machines with a set list of public IPs to interact with Schematics.
1515
4. Applications are running the VPC and need access to PostgreSQL via the private endpoint - eg: a VPE.

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module "cbr_account_level" {
6565
allow_cos_to_kms = var.allow_cos_to_kms
6666
allow_block_storage_to_kms = var.allow_block_storage_to_kms
6767
allow_roks_to_kms = var.allow_roks_to_kms
68+
allow_icd_to_kms = var.allow_icd_to_kms
6869
allow_vpcs_to_container_registry = var.allow_vpcs_to_container_registry
6970
allow_vpcs_to_cos = var.allow_vpcs_to_cos
7071
allow_at_to_cos = var.allow_at_to_cos

examples/fscloud/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ variable "allow_roks_to_kms" {
4646
default = true
4747
}
4848

49+
variable "allow_icd_to_kms" {
50+
type = bool
51+
description = "Set rule for ICD to KMS, deafult is true"
52+
default = true
53+
}
54+
4955
variable "allow_vpcs_to_container_registry" {
5056
type = bool
5157
description = "Set rule for VPCs to container registry, default is true"

modules/fscloud/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ This module creates default coarse-grained CBR rules in a given account followin
44
- COS -> KMS
55
- Block storage -> KMS
66
- ROKS -> KMS
7-
- Activity Tracker route -> COS (pending addition of AT as zone)
8-
- VPCs -> container registry
7+
- Activity Tracker route -> COS
98
- VPCs where clusters are deployed -> COS
9+
- VPCs -> container registry
10+
- All ICD -> KMS
1011

1112
This module is designed to allow the consumer to add additional custom rules to open up additional flows necessarity for their usage. See the `custom_rule_contexts_by_service` input variable, and an [usage example](../../examples/fscloud/) demonstrating how to open up more flows.
1213

@@ -48,6 +49,7 @@ The services 'compliance', 'directlink', 'iam-groups', 'containers-kubernetes',
4849
| <a name="input_allow_at_to_cos"></a> [allow\_at\_to\_cos](#input\_allow\_at\_to\_cos) | Set rule for Activity Tracker to COS, default is true | `bool` | `true` | no |
4950
| <a name="input_allow_block_storage_to_kms"></a> [allow\_block\_storage\_to\_kms](#input\_allow\_block\_storage\_to\_kms) | Set rule for block storage to KMS, default is true | `bool` | `true` | no |
5051
| <a name="input_allow_cos_to_kms"></a> [allow\_cos\_to\_kms](#input\_allow\_cos\_to\_kms) | Set rule for COS to KMS, default is true | `bool` | `true` | no |
52+
| <a name="input_allow_icd_to_kms"></a> [allow\_icd\_to\_kms](#input\_allow\_icd\_to\_kms) | Set rule for ICD to KMS, deafult is true | `bool` | `true` | no |
5153
| <a name="input_allow_roks_to_kms"></a> [allow\_roks\_to\_kms](#input\_allow\_roks\_to\_kms) | Set rule for ROKS to KMS, default is true | `bool` | `true` | no |
5254
| <a name="input_allow_vpcs_to_container_registry"></a> [allow\_vpcs\_to\_container\_registry](#input\_allow\_vpcs\_to\_container\_registry) | Set rule for VPCs to container registry, default is true | `bool` | `true` | no |
5355
| <a name="input_allow_vpcs_to_cos"></a> [allow\_vpcs\_to\_cos](#input\_allow\_vpcs\_to\_cos) | Set rule for VPCs to COS, default is true | `bool` | `true` | no |

modules/fscloud/main.tf

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,31 +178,47 @@ module "cbr_zone_vpcs" {
178178
]
179179
}
180180

181-
182181
##############################################################################
183182
# Create CBR rules for each service
184183
##############################################################################
185184

186185
locals {
187-
# tflint-ignore: terraform_unused_declarations
188-
validate_allow_rules = var.allow_cos_to_kms || var.allow_block_storage_to_kms || var.allow_roks_to_kms || var.allow_vpcs_to_container_registry || var.allow_vpcs_to_cos ? true : tobool("Minimum of one rule has to be set to True")
189186
## define FsCloud pre-wired CBR rule context - contains the known default flow that must be open for fscloud ref architecture
190187
cos_cbr_zone_id = local.cbr_zones["cloud-object-storage"].zone_id
191188
# tflint-ignore: terraform_naming_convention
192189
server-protect_cbr_zone_id = local.cbr_zones["server-protect"].zone_id # block storage
193190
# tflint-ignore: terraform_naming_convention
194191
containers-kubernetes_cbr_zone_id = local.cbr_zones["containers-kubernetes"].zone_id
195192
# tflint-ignore: terraform_naming_convention
193+
databases-for-cassandra_cbr_zone_id = local.cbr_zones["databases-for-cassandra"].zone_id
194+
# tflint-ignore: terraform_naming_convention
195+
databases-for-elasticsearch_cbr_zone_id = local.cbr_zones["databases-for-elasticsearch"].zone_id
196+
# tflint-ignore: terraform_naming_convention
197+
databases-for-enterprisedb_cbr_zone_id = local.cbr_zones["databases-for-enterprisedb"].zone_id
198+
# tflint-ignore: terraform_naming_convention
199+
databases-for-etcd_cbr_zone_id = local.cbr_zones["databases-for-etcd"].zone_id
200+
# tflint-ignore: terraform_naming_convention
201+
databases-for-mongodb_cbr_zone_id = local.cbr_zones["databases-for-mongodb"].zone_id
202+
# tflint-ignore: terraform_naming_convention
203+
databases-for-mysql_cbr_zone_id = local.cbr_zones["databases-for-mysql"].zone_id
204+
# tflint-ignore: terraform_naming_convention
205+
databases-for-postgresql_cbr_zone_id = local.cbr_zones["databases-for-postgresql"].zone_id
206+
# tflint-ignore: terraform_naming_convention
207+
databases-for-redis_cbr_zone_id = local.cbr_zones["databases-for-redis"].zone_id
208+
# tflint-ignore: terraform_naming_convention
196209
logdnaat_cbr_zone_id = local.cbr_zones["logdnaat"].zone_id
197210

198211
prewired_rule_contexts_by_service = {
199-
# COS -> KMS, Block storage -> KMS, ROKS -> KMS
212+
# COS -> KMS, Block storage -> KMS, ROKS -> KMS, ICD -> KMS
200213
"kms" : [{
201214
endpointType : "private",
202215
networkZoneIds : flatten([
203216
var.allow_cos_to_kms ? [local.cos_cbr_zone_id] : [],
204217
var.allow_block_storage_to_kms ? [local.server-protect_cbr_zone_id] : [],
205-
var.allow_roks_to_kms ? [local.containers-kubernetes_cbr_zone_id] : []
218+
var.allow_roks_to_kms ? [local.containers-kubernetes_cbr_zone_id] : [],
219+
var.allow_icd_to_kms ? [local.databases-for-cassandra_cbr_zone_id, local.databases-for-elasticsearch_cbr_zone_id, local.databases-for-enterprisedb_cbr_zone_id,
220+
local.databases-for-etcd_cbr_zone_id, local.databases-for-mongodb_cbr_zone_id, local.databases-for-mysql_cbr_zone_id, local.databases-for-postgresql_cbr_zone_id,
221+
local.databases-for-redis_cbr_zone_id] : []
206222
])
207223
}],
208224
# Fs VPCs -> COS, AT -> COS
@@ -222,18 +238,13 @@ locals {
222238
}],
223239
}
224240

225-
prewired_rule_contexts_by_service_pre_check = { for key, value in local.prewired_rule_contexts_by_service :
241+
prewired_rule_contexts_by_service_check = { for key, value in local.prewired_rule_contexts_by_service :
226242
key => [
227243
for rule in value :
228244
rule if length(rule.networkZoneIds) > 0
229245
]
230246
}
231247

232-
prewired_rule_contexts_by_service_check = { for key, value in local.prewired_rule_contexts_by_service_pre_check :
233-
key => value if length(value) > 0
234-
}
235-
236-
237248
## define default 'deny' rule context
238249
deny_rule_context_by_service = { for target_service_name in keys(local.target_service_details) :
239250
target_service_name => [{ endpointType : "public", networkZoneIds : [module.cbr_zone_deny.zone_id] }]
@@ -255,7 +266,6 @@ locals {
255266
]
256267
}
257268

258-
259269
# Merge map values (array of context) under the same service-name key
260270
all_services = keys(merge(local.deny_rule_context_by_service, local.prewired_rule_contexts_by_service_check, local.custom_rule_contexts_by_service))
261271
allow_rules_by_service_intermediary = { for service_name in local.all_services :

modules/fscloud/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ variable "allow_roks_to_kms" {
2626
default = true
2727
}
2828

29+
variable "allow_icd_to_kms" {
30+
type = bool
31+
description = "Set rule for ICD to KMS, deafult is true"
32+
default = true
33+
}
34+
2935
variable "allow_vpcs_to_container_registry" {
3036
type = bool
3137
description = "Set rule for VPCs to container registry, default is true"

0 commit comments

Comments
 (0)