apiVersion: v1
data:
  application: |
    apiVersion: core.oam.dev/v1beta1
    kind: Application
    metadata:
      annotations:
        addons.oam.dev/description: Terraform Controller is a Kubernetes Controller for
          Terraform.
      name: terraform
      namespace: vela-system
    spec:
      components:
      - name: ns-terraform-system
        properties:
          apiVersion: v1
          kind: Namespace
          metadata:
            name: terraform-system
        type: raw
      - name: terraform-controller
        properties:
          chart: terraform-controller
          repoType: helm
          url: https://charts.kubevela.net/addons
          version: 0.2.6
        type: helm
      - name: alibaba-ack
        properties:
          apiVersion: core.oam.dev/v1beta1
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for Alibaba Cloud
                ACK cluster
            labels:
              type: terraform
            name: alibaba-ack
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: https://github.com/kubevela-contrib/terraform-modules.git
                path: alibaba/cs/dedicated-kubernetes
                type: remote
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      - name: alibaba-eip
        properties:
          apiVersion: core.oam.dev/v1alpha2
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for Alibaba Cloud
                Elastic IP
            labels:
              type: terraform
            name: alibaba-eip
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: https://github.com/oam-dev/terraform-alibaba-eip.git
                type: remote
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      - name: alibaba-oss
        properties:
          apiVersion: core.oam.dev/v1alpha2
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for Alibaba Cloud
                OSS object
            labels:
              type: terraform
            name: alibaba-oss
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: "resource \"alicloud_oss_bucket\" \"bucket-acl\" {\n  bucket
                  = var.bucket\n  acl = var.acl\n}\noutput \"BUCKET_NAME\" {\n  value
                  = \"${alicloud_oss_bucket.bucket-acl.bucket}.${alicloud_oss_bucket.bucket-acl.extranet_endpoint}\"\n}\nvariable
                  \"bucket\" {\n  description = \"OSS bucket name\"\n  default = \"vela-website\"\n
                  \ type = string\n}\nvariable \"acl\" {\n  description = \"OSS bucket
                  ACL, supported 'private', 'public-read', 'public-read-write'\"\n  default
                  = \"private\"\n  type = string\n} \n"
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      - name: alibaba-rds
        properties:
          apiVersion: core.oam.dev/v1alpha2
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for Alibaba Cloud
                RDS object
            labels:
              type: terraform
            name: alibaba-rds
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: |
                  module "rds" {
                    source = "github.com/kubevela-contrib/terraform-alicloud-rds"
                    engine = "MySQL"
                    engine_version = "8.0"
                    instance_type = "rds.mysql.c1.large"
                    instance_storage = "20"
                    instance_name = var.instance_name
                    account_name = var.account_name
                    password = var.password
                    allocate_public_connection = var.allocate_public_connection
                    security_ips = ["0.0.0.0/0",]
                  }

                  output "DB_NAME" {
                    value = module.rds.this_db_instance_name
                  }
                  output "DB_USER" {
                    value = module.rds.this_db_database_account
                  }
                  output "DB_PORT" {
                    value = module.rds.this_db_instance_port
                  }
                  output "DB_HOST" {
                    value = module.rds.this_db_instance_connection_string
                  }
                  output "DB_PASSWORD" {
                    value = var.password
                  }
                  output "DB_PUBLIC_HOST" {
                    value = module.rds.db_public_connection_string
                  }

                  variable "instance_name" {
                    description = "RDS instance name"
                    type = string
                    default = "poc"
                  }

                  variable "account_name" {
                    description = "RDS instance user account name"
                    type = string
                    default = "oam"
                  }

                  variable "password" {
                    description = "RDS instance account password"
                    type = string
                    default = "Xyfff83jfewGGfaked"
                  }

                  variable "allocate_public_connection" {
                    description = "Whether to allocate public connection for a RDS instance."
                    type        = bool
                    default     = true
                  }
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      - name: aws-s3
        properties:
          apiVersion: core.oam.dev/v1alpha2
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for AWS S3
            labels:
              type: terraform
            name: aws-s3
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: |
                  resource "aws_s3_bucket" "bucket-acl" {
                    bucket = var.bucket
                    acl    = var.acl
                  }

                  output "BUCKET_NAME" {
                    value = aws_s3_bucket.bucket-acl.bucket_domain_name
                  }

                  variable "bucket" {
                    description = "S3 bucket name"
                    default = "vela-website"
                    type = string
                  }

                  variable "acl" {
                    description = "S3 bucket ACL"
                    default = "private"
                    type = string
                  }
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      - name: azure-database-mariadb
        properties:
          apiVersion: core.oam.dev/v1alpha2
          kind: ComponentDefinition
          metadata:
            annotations:
              definition.oam.dev/description: Terraform configuration for Azure Database
                Mariadb
              provider: azure
            labels:
              type: terraform
            name: azure-database-mariadb
            namespace: vela-system
          spec:
            schematic:
              terraform:
                configuration: |
                  # Configure the Microsoft Azure Provider
                  provider "azurerm" {
                    features {}
                  }

                  resource "azurerm_resource_group" "example" {
                    name = var.resource_group
                    location = var.location
                  }

                  resource "azurerm_mariadb_server" "example" {
                    name = var.server_name
                    location = var.location
                    resource_group_name = azurerm_resource_group.example.name

                    sku_name = "B_Gen5_2"

                    storage_mb = 51200
                    backup_retention_days = 7
                    geo_redundant_backup_enabled = false

                    administrator_login = var.username
                    administrator_login_password = var.password
                    version = "10.2"
                    ssl_enforcement_enabled = true
                  }

                  resource "azurerm_mariadb_database" "example" {
                    name = var.db_name
                    resource_group_name = azurerm_resource_group.example.name
                    server_name = azurerm_mariadb_server.example.name
                    charset = "utf8"
                    collation = "utf8_general_ci"
                  }

                  variable "server_name" {
                    type = string
                    description = "mariadb server name"
                    default = "mariadb-svr-sample"
                  }

                  variable "db_name" {
                    default = "backend"
                    type = string
                    description = "Database instance name"
                  }

                  variable "username" {
                    default = "acctestun"
                    type = string
                    description = "Database instance username"
                  }

                  variable "password" {
                    default = "H@Sh1CoR3!faked"
                    type = string
                    description = "Database instance password"
                  }

                  variable "location" {
                    description = "Azure location"
                    type = string
                    default = "West Europe"
                  }

                  variable "resource_group" {
                    description = "Resource group"
                    type = string
                    default = "kubevela-group"
                  }

                  output "SERVER_NAME" {
                    value = var.server_name
                  }

                  output "DB_NAME" {
                    value = var.db_name
                  }
                  output "DB_USER" {
                    value = var.username
                  }
                  output "DB_PASSWORD" {
                    sensitive = true
                    value = var.password
                  }
                  output "DB_PORT" {
                    value = "3306"
                  }
                  output "DB_HOST" {
                    value = azurerm_mariadb_server.example.fqdn
                  }
                providerRef:
                  name: azure
                  namespace: default
            workload:
              definition:
                apiVersion: terraform.core.oam.dev/v1beta1
                kind: Configuration
        type: raw
      workflow:
        steps:
        - name: checking-depends-on
          properties:
            name: fluxcd
            namespace: vela-system
          type: depends-on-app
        - name: apply-ns
          properties:
            component: ns-terraform-system
          type: apply-component
        - name: apply-resources
          type: apply-remaining
    status:
      rollout:
        batchRollingState: ""
        currentBatch: 0
        lastTargetAppRevision: ""
        rollingState: ""
        upgradedReadyReplicas: 0
        upgradedReplicas: 0
kind: ConfigMap
metadata:
  annotations:
    addons.oam.dev/description: Terraform Controller is a Kubernetes Controller for
      Terraform.
    addons.oam.dev/name: terraform
  labels:
    addons.oam.dev/type: terraform
  name: terraform
  namespace: {{.Values.systemDefinitionNamespace}}
