solutions/project/hub-env/org-policies/exceptions/compute-vm-can-ip-forward-except-hub-project.yaml (17 lines of code) (raw):
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#########
#
# GCP Organization Policies
# Org policies that correspond with a Guardrail will contain a label indicating what Guardrails it helps in enforcing
# https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints
#
# Constraint: constraints/compute.vmCanIpForward
#
# This list constraint defines the set of VM instances that can enable IP forwarding.
# By default, any VM can enable IP forwarding in any virtual network.
# VM instances must be specified in the form:
# organizations/ORGANIZATION_ID, folders/FOLDER_ID, projects/PROJECT_ID,
# or projects/PROJECT_ID/zones/ZONE/instances/INSTANCE-NAME.
#
# This exception is to allow the Fortigate VM in the hub project to forward traffic.
#
#########
apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: ResourceManagerPolicy
metadata:
name: compute-vm-can-ip-forward-except-hub-project
namespace: policies
annotations:
config.kubernetes.io/depends-on: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/hub-project-id # kpt-set: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/${hub-project-id}
labels:
guardrail: "false"
spec:
constraint: "constraints/compute.vmCanIpForward"
listPolicy:
allow:
values: # kpt-set: ${project-allowed-vm-external-ip-access}
- "projects/PROJECT_ID/zones/ZONE/instances/INSTANCE-NAME"
projectRef:
external: "0000000000" # kpt-set: ${hub-project-id}