apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
  name: alibaba-oss
  namespace: vela-system
  annotations:
    definition.oam.dev/description: Terraform configuration for Alibaba Cloud OSS object
    # identifier of this cloud resource
    cloud-resource/identifier: BUCKET_NAME
    # the console url of this cloud resource
    cloud-resource/console-url: "https://oss.console.aliyun.com/bucket/oss-{REGION}/{BUCKET_NAME}/overview"
    # the outputs which are sensitive. Separate them by a comma if there are more than one
  labels:
    type: terraform
spec:
  workload:
    definition:
      apiVersion: terraform.core.oam.dev/v1beta1
      kind: Configuration
  schematic:
    terraform:
      configuration: |
        resource "alicloud_oss_bucket" "bucket-acl" {
          bucket = var.bucket
          acl = var.acl
        }
        output "BUCKET_NAME" {
          value = "${alicloud_oss_bucket.bucket-acl.bucket}"
        }
        output "BUCKET_ENDPOINT" {
          value = "${alicloud_oss_bucket.bucket-acl.bucket}.${alicloud_oss_bucket.bucket-acl.extranet_endpoint}"
        }
        variable "bucket" {
          description = "OSS bucket name"
          default = "vela-website"
          type = string
        }
        variable "acl" {
          description = "OSS bucket ACL, supported 'private', 'public-read', 'public-read-write'"
          default = "private"
          type = string
        }