version: 1
kind: component

requires:
  - terraform

parameters:
  - name: hub.componentName
  - name: component.cloudSql
    parameters:
      - name: name
        value: "${hub.componentName}"
        env: TF_VAR_name
      - name: version
        value: MYSQL_5_7
        brief: >
          Possible values:
            MYSQL_5_6 MYSQL_5_7 MYSQL_8_0
            POSTGRES_9_6 POSTGRES_10 POSTGRES_11 POSTGRES_12 POSTGRES_13
            SQLSERVER_2017_STANDARD SQLSERVER_2017_ENTERPRISE SQLSERVER_2017_EXPRESS SQLSERVER_2017_WEB
            SQLSERVER_2019_STANDARD SQLSERVER_2019_ENTERPRISE SQLSERVER_2019_EXPRESS SQLSERVER_2019_WEB

          For up-to-date possible values:
            https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#database_version

          More information about version policies:
            https://cloud.google.com/sql/docs/db-versions
        env: TF_VAR_database_version
      - name: network
        value: default
        env: TF_VAR_network
      - name: dbName
        value: default
        env: TF_VAR_db_name
      - name: dbUser
        value: default
        env: TF_VAR_db_user
      - name: password
        env: TF_VAR_db_password
        empty: allow
      - name: publicIP
        env: TF_VAR_public_ip
        value: true
        brief: Whether this Cloud SQL instance should be assigned a public IPV4 address.
      - name: availabilityType
        value: ZONAL
        env: TF_VAR_availability_type
      - name: allocatedIpRangeName
        empty: allow
        env: TF_VAR_allocated_ip_range_name
        brief: The name of the allocated ip range for the private ip CloudSQL instance.
      - name: randomName
        value: true
        env: TF_VAR_random
outputs:
  - name: component.cloudSql.dbName
  - name: component.cloudSql.dbUser
  - name: component.cloudSql.privateIp
    fromTfVar: private_ip
  - name: component.cloudSql.publicIp
    fromTfVar: public_ip
  - name: component.cloudSql.password
    fromTfVar: password
