# 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-7, AU-9 - The log buckets created within the Logging project are immutable. These buckets have a retention policy of 365 days and IAM Policy that defines who has access to the bucket
# AU-4(1), AU-6(4), AU-9(2) - Log sinks sending the logs to same project in same region having a logging bucket
# AU-9(4), SI-4 - The centralized logging solution has a configuration in place that defines all logging buckets to be locked
# AU-11 - Logging bucket retention configuration
apiVersion: logging.cnrm.cloud.google.com/v1beta1
kind: LoggingLogBucket
metadata:
  name: 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:
  # AU-4(1), AU-6(4), AU-9(2)
  projectRef:
    name: logging-project-id # kpt-set: ${logging-project-id}
    namespace: projects
  location: northamerica-northeast1
  description: Cloud Logging bucket for Security logs
  # Implement retention locking policy and number of retention days
  # AU-7, AU-9, AU-9(4), SI-4
  locked: false # kpt-set: ${retention-locking-policy}
  # AU-11
  retentionDays: 1 # kpt-set: ${retention-in-days}
---
# Cloud Logging bucket for Platform and Component logs
# Logs are routed using a log sink to a central logging project into a dedicated log bucket
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:
  # AU-4(1), AU-6(4), AU-9(2)
  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 locking policy and number of retention days
  # AU-7, AU-9, AU-9(4), SI-4
  locked: false # kpt-set: ${retention-locking-policy}
  # AU-11
  retentionDays: 1 # kpt-set: ${retention-in-days}
