---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: rds-snapshot-job
spec:
  schedule: "0 4 1 * *"
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 5
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      backoffLimit: 0
      activeDeadlineSeconds: 1200
      template:
        spec:
          securityContext:
            runAsUser: 999
          containers:
          - name: dbsnapshot
            image: "754256621582.dkr.ecr.eu-west-2.amazonaws.com/cloud-platform/tools:latest"
            command:
            - /bin/entrypoint.sh
            volumeMounts:
            - name: rds-snapshot-script
              mountPath: /bin/entrypoint.sh
              readOnly: true
              subPath: entrypoint.sh
            env:
            - name: DB_INSTANCE
              valueFrom:
                secretKeyRef:
                  name: dps-rds-instance-output
                  key: rds_instance_address
            - name: AWS_DEFAULT_REGION
              value: "eu-west-2"
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: dps-rds-instance-output
                  key: access_key_id
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: dps-rds-instance-output
                  key: secret_access_key
          restartPolicy: "Never"
          volumes:
          - name: rds-snapshot-script
            configMap:
              name: rds-snapshot-script
              defaultMode: 0755
