{% set config = merged_configs.get('google_sql_user', {}) %}
# Compliance: {{ compliance_comments.get('google_sql_user', []) | join(', ') }}
resource "google_sql_user" "main" {
  name     = "{{ config.get('name', '${var.project_id}-user') }}"
  project  = var.project_id
  instance = google_sql_database_instance.main.name

  type = "{{ config.get('type', 'CLOUD_IAM_SERVICE_ACCOUNT') }}"

  {% if config.get('type', 'CLOUD_IAM_SERVICE_ACCOUNT') == 'BUILT_IN' %}
  password = var.sql_user_password
  {% endif %}

  deletion_policy = "{{ config.get('deletion_policy', 'ABANDON') }}"
}
