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

Fix factory ingress policy services in vpc-sc module #2251

Merged
merged 1 commit into from
May 1, 2024
Merged
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
23 changes: 20 additions & 3 deletions modules/vpc-sc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ module "test" {
resources = ["projects/11111", "projects/111111"]
restricted_services = ["storage.googleapis.com"]
egress_policies = ["gcs-sa-foo"]
ingress_policies = ["sa-tf-test"]
ingress_policies = ["sa-tf-test-geo", "sa-tf-test"]
vpc_accessible_services = {
allowed_services = ["storage.googleapis.com"]
enable_restriction = true
Expand All @@ -242,7 +242,7 @@ module "test" {
}
}
}
# tftest modules=1 resources=3 files=a1,a2,e1,i1 inventory=factory.yaml
# tftest modules=1 resources=3 files=a1,a2,e1,i1,i2 inventory=factory.yaml
```

```yaml
Expand Down Expand Up @@ -282,12 +282,29 @@ from:
- serviceAccount:[email protected]
to:
operations:
- service_name: "*"
- service_name: compute.googleapis.com
method_selectors:
- ProjectsService.Get
- RegionsService.Get
resources:
- "*"
# tftest-file id=i1 path=data/ingress-policies/sa-tf-test.yaml
```

```yaml
from:
access_levels:
- geo-it
identities:
- serviceAccount:[email protected]
to:
operations:
- service_name: "*"
resources:
- projects/1234567890
# tftest-file id=i2 path=data/ingress-policies/sa-tf-test-geo.yaml
```

## Notes

- To remove an access level, first remove the binding between perimeter and the access level in `status` and/or `spec` without removing the access level itself. Once you have run `terraform apply`, you'll then be able to remove the access level and run `terraform apply` again.
Expand Down
2 changes: 1 addition & 1 deletion modules/vpc-sc/factory.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ locals {
}, try(v.from, {}))
to = {
operations = [
for o in try(v.operations, []) : merge({
for o in try(v.to.operations, []) : merge({
method_selectors = []
permission_selectors = []
service_name = null
Expand Down
20 changes: 19 additions & 1 deletion tests/modules/vpc_sc/examples/factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,27 @@ values:
- access_level: '*'
resource: null
ingress_to:
- operations: []
- operations:
- method_selectors:
- method: ProjectsService.Get
permission: null
- method: RegionsService.Get
permission: null
service_name: compute.googleapis.com
resources:
- '*'
- ingress_from:
- identities:
- serviceAccount:[email protected]
identity_type: null
sources:
- resource: null
ingress_to:
- operations:
- method_selectors: []
service_name: '*'
resources:
- projects/1234567890
resources:
- projects/11111
- projects/111111
Expand Down
Loading