# 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.
######
# Cloud Logging bucket for Security logs: Cloud Audit, Access Transparency Logs, and Data Access Logs
# Logs are routed using a log sink to a central logging project into a dedicated log bucket
# AU-4(1), AU-9(2) - Log buckets are created in a logging project, isolating them from the source of the log entries in other projects
apiVersion: logging.cnrm.cloud.google.com/v1beta1
kind: LoggingLogBucket
metadata:
  name: security-log-bucket # kpt-set: ${security-log-bucket}
  namespace: logging
  annotations:
    config.kubernetes.io/depends-on: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/${logging-project-id} # kpt-set: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/${logging-project-id}
spec:
  projectRef:
    name: logging-project-id # kpt-set: ${logging-project-id}
    namespace: projects
  location: northamerica-northeast1
  description: Cloud Logging bucket for Security logs
  # Implement retention policy and retention locking policy
  # AU-9, AU-11 - RetentionDays sets the policy where existing log content cannot be changed/deleted for the specified number of days (from setters.yaml), locked setting means policy cannot be changed, ensuring immutability.
  locked: false # kpt-set: ${retention-locking-policy}
  retentionDays: 1 # kpt-set: ${retention-in-days}
---
# Cloud Logging bucket for Platform and Component logs
apiVersion: logging.cnrm.cloud.google.com/v1beta1
kind: LoggingLogBucket
metadata:
  name: platform-and-component-log-bucket # kpt-set: ${platform-and-component-log-bucket}
  namespace: logging
  annotations:
    config.kubernetes.io/depends-on: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/${logging-project-id} # kpt-set: resourcemanager.cnrm.cloud.google.com/namespaces/projects/Project/${logging-project-id}
spec:
  projectRef:
    name: logging-project-id # kpt-set: ${logging-project-id}
    namespace: projects
  location: northamerica-northeast1
  description: Cloud Logging bucket for Platform and Component logs
  # Implement retention policy and retention locking policy
  # AU-9, AU-11
  locked: false # kpt-set: ${retention-locking-policy}
  retentionDays: 1 # kpt-set: ${retention-in-days}
