{% set config = merged_configs.get('google_pubsub_subscription', {}) %}
# Compliance: {{ compliance_comments.get('google_pubsub_subscription', []) | join(', ') }}
resource "google_pubsub_subscription" "main" {
  name    = "{{ config.get('name', '${var.project_id}-sub') }}"
  project = var.project_id
  topic   = google_pubsub_topic.main.id

  ack_deadline_seconds       = {{ config.get('ack_deadline_seconds', 20) }}
  message_retention_duration = "{{ config.get('message_retention_duration', '604800s') }}"
  retain_acked_messages      = {{ config.get('retain_acked_messages', false) | lower }}
  enable_message_ordering    = {{ config.get('enable_message_ordering', false) | lower }}

  expiration_policy {
    ttl = "{{ config.get('expiration_ttl', '') }}"
  }

  retry_policy {
    minimum_backoff = "{{ config.get('minimum_backoff', '10s') }}"
    maximum_backoff = "{{ config.get('maximum_backoff', '600s') }}"
  }
}
