Skip to content

Commit

Permalink
Allow specifying the running security groups for a space
Browse files Browse the repository at this point in the history
  • Loading branch information
rahearn committed Oct 10, 2024
1 parent bc66708 commit 8aead5c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ module "egress_space" {
deployers = [
var.cf_user
]
asg_names = [
"trusted_local_networks_egress",
"public_networks_egress"
]
}
```

Expand Down
18 changes: 18 additions & 0 deletions cg_space/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,21 @@ resource "cloudfoundry_space_users" "space_permissions" {
managers = local.manager_ids
developers = local.developer_ids
}

###
# Space Security Groups
###

data "cloudfoundry_asg" "asgs" {
for_each = var.asg_names
name = each.key
}

locals {
asg_ids = [for asg in data.cloudfoundry_asg.asgs : asg.id]
}

resource "cloudfoundry_space_asgs" "running_security_groups" {
space = cloudfoundry_space.space.id
running_asgs = local.asg_ids
}
1 change: 1 addition & 0 deletions cg_space/tests/creation.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mock_provider "cloudfoundry" {
variables {
cf_org_name = "gsa-tts-devtools-prototyping"
cf_space_name = "terraform-cloudgov-ci-tests-egress"
asg_names = ["trusted_local_networks_egress"]
}

run "test_space_creation" {
Expand Down
6 changes: 6 additions & 0 deletions cg_space/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ variable "cf_space_name" {
description = "cloud.gov space name to create"
}

variable "asg_names" {
type = set(string)
description = "list of security group names to apply to the Space"
default = []
}

variable "managers" {
type = set(string)
description = "list of cloud.gov users to be assigned to the SpaceManager role"
Expand Down

0 comments on commit 8aead5c

Please sign in to comment.