From e3a4d079cd3af32005c585706d72ae97d9856e30 Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Tue, 15 Mar 2022 21:20:26 +0800 Subject: [PATCH 1/7] generate addon for elastic cloud Signed-off-by: Nicola115 <2225992901@qq.com> --- addons/terraform-ec/metadata.yaml | 31 +++++++++++++++++++ addons/terraform-ec/readme.md | 3 ++ .../resources/ec-account-creds.cue | 18 +++++++++++ addons/terraform-ec/resources/ec-provider.cue | 22 +++++++++++++ addons/terraform-ec/resources/parameter.cue | 4 +++ addons/terraform-ec/template.yaml | 5 +++ .../terraform-provider-scaffold/metadata.yaml | 17 +++------- 7 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 addons/terraform-ec/metadata.yaml create mode 100644 addons/terraform-ec/readme.md create mode 100644 addons/terraform-ec/resources/ec-account-creds.cue create mode 100644 addons/terraform-ec/resources/ec-provider.cue create mode 100644 addons/terraform-ec/resources/parameter.cue create mode 100644 addons/terraform-ec/template.yaml diff --git a/addons/terraform-ec/metadata.yaml b/addons/terraform-ec/metadata.yaml new file mode 100644 index 00000000..12299992 --- /dev/null +++ b/addons/terraform-ec/metadata.yaml @@ -0,0 +1,31 @@ +name: terraform-ec +version: 1.0.0 +description: Kubernetes Terraform Controller Provider for Elastic Cloud +url: https://github.com/oam-dev/terraform-controller + +tags: + - Terraform Controller Provider + - IaC + - Cloud Resources + +deployTo: + control_plane: true + runtime_cluster: false + +dependencies: + - name: terraform + +# -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- +# provider short name +shortCloudName: ec + +# The Cloud name of the provider +completeCloudName: Elastic Cloud + +# When enabling a Terraform provider, these properties need to set for authentication. For Tencent Cloud, +# name: Environment variable name when authenticating Terraform, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L59 +# secretKey: Secret key when storing authentication information in a Kubernetes, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L109. +cloudProperties: + - name: EC_API_KEY + secretKey: ecApiKey + description: Get EC_API_KEY per this guide https://www.elastic.co/guide/en/cloud-enterprise/current/ece-restful-api-authentication.html diff --git a/addons/terraform-ec/readme.md b/addons/terraform-ec/readme.md new file mode 100644 index 00000000..e4c57339 --- /dev/null +++ b/addons/terraform-ec/readme.md @@ -0,0 +1,3 @@ +# Addon terraform-ec + +This addon contains Terraform provider for Elastic Cloud. \ No newline at end of file diff --git a/addons/terraform-ec/resources/ec-account-creds.cue b/addons/terraform-ec/resources/ec-account-creds.cue new file mode 100644 index 00000000..fa652f9e --- /dev/null +++ b/addons/terraform-ec/resources/ec-account-creds.cue @@ -0,0 +1,18 @@ +import "strings" + +output: { + type: "raw" + properties: { + apiVersion: "v1" + kind: "Secret" + metadata: { + name: "ec-account-creds" + namespace: "vela-system" + } + type: "Opaque" + stringData: credentials: strings.Join([ + "ecApiKey: " + parameter.EC_API_KEY, + ], "\n") + } +} + diff --git a/addons/terraform-ec/resources/ec-provider.cue b/addons/terraform-ec/resources/ec-provider.cue new file mode 100644 index 00000000..7dad869e --- /dev/null +++ b/addons/terraform-ec/resources/ec-provider.cue @@ -0,0 +1,22 @@ +output: { + type: "raw" + properties: { + apiVersion: "terraform.core.oam.dev/v1beta1" + kind: "Provider" + metadata: { + name: "ec" + namespace: "default" + } + spec: { + provider: "ec" + credentials: { + source: "Secret" + secretRef: { + namespace: "vela-system" + name: "ec-account-creds" + key: "credentials" + } + } + } + } +} diff --git a/addons/terraform-ec/resources/parameter.cue b/addons/terraform-ec/resources/parameter.cue new file mode 100644 index 00000000..9b010363 --- /dev/null +++ b/addons/terraform-ec/resources/parameter.cue @@ -0,0 +1,4 @@ +parameter: { + //+usage=Get EC_API_KEY per this guide https://www.elastic.co/guide/en/cloud-enterprise/current/ece-restful-api-authentication.html + EC_API_KEY: *"" | string +} diff --git a/addons/terraform-ec/template.yaml b/addons/terraform-ec/template.yaml new file mode 100644 index 00000000..95cda5c4 --- /dev/null +++ b/addons/terraform-ec/template.yaml @@ -0,0 +1,5 @@ +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: terraform-ec + namespace: vela-system diff --git a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml index 7e76636e..df94a88c 100644 --- a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml +++ b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml @@ -17,22 +17,15 @@ dependencies: # -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- # provider short name -shortCloudName: tencent +shortCloudName: ec # The Cloud name of the provider -completeCloudName: Tencent Cloud +completeCloudName: Elastic Cloud # When enabling a Terraform provider, these properties need to set for authentication. For Tencent Cloud, # name: Environment variable name when authenticating Terraform, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L59 # secretKey: Secret key when storing authentication information in a Kubernetes, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L109. cloudProperties: - - name: TENCENTCLOUD_SECRET_ID - secretKey: secretID - description: Get TENCENTCLOUD_SECRET_ID per this guide https://cloud.tencent.com/document/product/1213/67093 - - name: TENCENTCLOUD_SECRET_KEY - secretKey: secretKey - description: Get TENCENTCLOUD_SECRET_KEY per this guide https://cloud.tencent.com/document/product/1213/67093 - # If one property is region, please set `isRegion` to true - - name: TENCENTCLOUD_REGION - description: Get TENCENTCLOUD_REGION by picking one RegionId from Tencent Cloud region list https://cloud.tencent.com/document/api/1140/40509#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 - isRegion: true + - name: EC_API_KEY + secretKey: ecApiKey + description: Get EC_API_KEY per this guide https://www.elastic.co/guide/en/cloud-enterprise/current/ece-restful-api-authentication.html From 694a0319baae61ccf45e62032b93cd4f6bf773c8 Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Wed, 16 Mar 2022 10:49:53 +0800 Subject: [PATCH 2/7] rename provider ec as elastic Signed-off-by: Nicola115 <2225992901@qq.com> --- addons/{terraform-ec => terraform-elastic}/metadata.yaml | 4 ++-- addons/{terraform-ec => terraform-elastic}/readme.md | 2 +- .../resources/elastic-account-creds.cue} | 2 +- .../resources/elastic-provider.cue} | 6 +++--- .../resources/parameter.cue | 0 addons/{terraform-ec => terraform-elastic}/template.yaml | 2 +- .../terraform/terraform-provider-scaffold/metadata.yaml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename addons/{terraform-ec => terraform-elastic}/metadata.yaml (96%) rename addons/{terraform-ec => terraform-elastic}/readme.md (69%) rename addons/{terraform-ec/resources/ec-account-creds.cue => terraform-elastic/resources/elastic-account-creds.cue} (87%) rename addons/{terraform-ec/resources/ec-provider.cue => terraform-elastic/resources/elastic-provider.cue} (77%) rename addons/{terraform-ec => terraform-elastic}/resources/parameter.cue (100%) rename addons/{terraform-ec => terraform-elastic}/template.yaml (76%) diff --git a/addons/terraform-ec/metadata.yaml b/addons/terraform-elastic/metadata.yaml similarity index 96% rename from addons/terraform-ec/metadata.yaml rename to addons/terraform-elastic/metadata.yaml index 12299992..101498f4 100644 --- a/addons/terraform-ec/metadata.yaml +++ b/addons/terraform-elastic/metadata.yaml @@ -1,4 +1,4 @@ -name: terraform-ec +name: terraform-elastic version: 1.0.0 description: Kubernetes Terraform Controller Provider for Elastic Cloud url: https://github.com/oam-dev/terraform-controller @@ -17,7 +17,7 @@ dependencies: # -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- # provider short name -shortCloudName: ec +shortCloudName: elastic # The Cloud name of the provider completeCloudName: Elastic Cloud diff --git a/addons/terraform-ec/readme.md b/addons/terraform-elastic/readme.md similarity index 69% rename from addons/terraform-ec/readme.md rename to addons/terraform-elastic/readme.md index e4c57339..228e8932 100644 --- a/addons/terraform-ec/readme.md +++ b/addons/terraform-elastic/readme.md @@ -1,3 +1,3 @@ -# Addon terraform-ec +# Addon terraform-elastic This addon contains Terraform provider for Elastic Cloud. \ No newline at end of file diff --git a/addons/terraform-ec/resources/ec-account-creds.cue b/addons/terraform-elastic/resources/elastic-account-creds.cue similarity index 87% rename from addons/terraform-ec/resources/ec-account-creds.cue rename to addons/terraform-elastic/resources/elastic-account-creds.cue index fa652f9e..d14338e7 100644 --- a/addons/terraform-ec/resources/ec-account-creds.cue +++ b/addons/terraform-elastic/resources/elastic-account-creds.cue @@ -6,7 +6,7 @@ output: { apiVersion: "v1" kind: "Secret" metadata: { - name: "ec-account-creds" + name: "elastic-account-creds" namespace: "vela-system" } type: "Opaque" diff --git a/addons/terraform-ec/resources/ec-provider.cue b/addons/terraform-elastic/resources/elastic-provider.cue similarity index 77% rename from addons/terraform-ec/resources/ec-provider.cue rename to addons/terraform-elastic/resources/elastic-provider.cue index 7dad869e..ec1d9587 100644 --- a/addons/terraform-ec/resources/ec-provider.cue +++ b/addons/terraform-elastic/resources/elastic-provider.cue @@ -4,16 +4,16 @@ output: { apiVersion: "terraform.core.oam.dev/v1beta1" kind: "Provider" metadata: { - name: "ec" + name: "elastic" namespace: "default" } spec: { - provider: "ec" + provider: "elastic" credentials: { source: "Secret" secretRef: { namespace: "vela-system" - name: "ec-account-creds" + name: "elastic-account-creds" key: "credentials" } } diff --git a/addons/terraform-ec/resources/parameter.cue b/addons/terraform-elastic/resources/parameter.cue similarity index 100% rename from addons/terraform-ec/resources/parameter.cue rename to addons/terraform-elastic/resources/parameter.cue diff --git a/addons/terraform-ec/template.yaml b/addons/terraform-elastic/template.yaml similarity index 76% rename from addons/terraform-ec/template.yaml rename to addons/terraform-elastic/template.yaml index 95cda5c4..57c093ef 100644 --- a/addons/terraform-ec/template.yaml +++ b/addons/terraform-elastic/template.yaml @@ -1,5 +1,5 @@ apiVersion: core.oam.dev/v1beta1 kind: Application metadata: - name: terraform-ec + name: terraform-elastic namespace: vela-system diff --git a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml index df94a88c..1d1f3d42 100644 --- a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml +++ b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml @@ -17,7 +17,7 @@ dependencies: # -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- # provider short name -shortCloudName: ec +shortCloudName: elastic # The Cloud name of the provider completeCloudName: Elastic Cloud From 53ff374ba0ca0a28945ded663a3aa2fc1bba8913 Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Mon, 21 Mar 2022 17:19:38 +0800 Subject: [PATCH 3/7] add component definitions to further verify provider elastic Signed-off-by: Nicola115 <2225992901@qq.com> --- .../terraform-elastic-deployment.yaml | 23 +++++++++++++++++++ .../components/cloud-services/terraform/.md | 0 2 files changed, 23 insertions(+) create mode 100644 addons/terraform-elastic/definitions/terraform-elastic-deployment.yaml create mode 100644 addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md diff --git a/addons/terraform-elastic/definitions/terraform-elastic-deployment.yaml b/addons/terraform-elastic/definitions/terraform-elastic-deployment.yaml new file mode 100644 index 00000000..8f544509 --- /dev/null +++ b/addons/terraform-elastic/definitions/terraform-elastic-deployment.yaml @@ -0,0 +1,23 @@ +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition +metadata: + annotations: + definition.oam.dev/description: "" + creationTimestamp: null + labels: + type: terraform + name: elastic-deployment + namespace: vela-system +spec: + schematic: + terraform: + configuration: https://github.com/puppetlabs/terraform-ec-deployment.git + providerRef: + name: elastic + namespace: default + type: remote + workload: + definition: + apiVersion: terraform.core.oam.dev/v1beta1 + kind: Configuration +status: {} diff --git a/addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md b/addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md new file mode 100644 index 00000000..e69de29b From f47f53201b281f27b232b63a67c01b55e6fbbde0 Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Mon, 21 Mar 2022 17:30:02 +0800 Subject: [PATCH 4/7] remove empty doc Signed-off-by: Nicola115 <2225992901@qq.com> --- .../docs/end-user/components/cloud-services/terraform/.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md diff --git a/addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md b/addons/terraform-elastic/kubevela.io/docs/end-user/components/cloud-services/terraform/.md deleted file mode 100644 index e69de29b..00000000 From 37a687535fd83eff6e9d63fad802c1429fadddaf Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Thu, 24 Mar 2022 10:41:28 +0800 Subject: [PATCH 5/7] restore metadata.yaml Signed-off-by: Nicola115 <2225992901@qq.com> --- .../terraform-provider-scaffold/metadata.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml index 1d1f3d42..757e257a 100644 --- a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml +++ b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml @@ -14,18 +14,24 @@ deployTo: dependencies: - name: terraform - # -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- # provider short name -shortCloudName: elastic +shortCloudName: tencent # The Cloud name of the provider -completeCloudName: Elastic Cloud +completeCloudName: Tencent Cloud # When enabling a Terraform provider, these properties need to set for authentication. For Tencent Cloud, # name: Environment variable name when authenticating Terraform, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L59 # secretKey: Secret key when storing authentication information in a Kubernetes, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L109. cloudProperties: - - name: EC_API_KEY - secretKey: ecApiKey - description: Get EC_API_KEY per this guide https://www.elastic.co/guide/en/cloud-enterprise/current/ece-restful-api-authentication.html + - name: TENCENTCLOUD_SECRET_ID + secretKey: secretID + description: Get TENCENTCLOUD_SECRET_ID per this guide https://cloud.tencent.com/document/product/1213/67093 + - name: TENCENTCLOUD_SECRET_KEY + secretKey: secretKey + description: Get TENCENTCLOUD_SECRET_KEY per this guide https://cloud.tencent.com/document/product/1213/67093 + # If one property is region, please set `isRegion` to true + - name: TENCENTCLOUD_REGION + description: Get TENCENTCLOUD_REGION by picking one RegionId from Tencent Cloud region list https://cloud.tencent.com/document/api/1140/40509#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 + isRegion: true From 8adea5b2a7493b075d68328f5fba70581beab3e9 Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Thu, 24 Mar 2022 10:43:15 +0800 Subject: [PATCH 6/7] restore metadata.yaml Signed-off-by: Nicola115 <2225992901@qq.com> --- hack/addons/terraform/terraform-provider-scaffold/metadata.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml index 757e257a..7e76636e 100644 --- a/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml +++ b/hack/addons/terraform/terraform-provider-scaffold/metadata.yaml @@ -14,6 +14,7 @@ deployTo: dependencies: - name: terraform + # -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- # provider short name shortCloudName: tencent From 5a32f6bcc4ebd5c9656d7ea6565d99df4dacdcda Mon Sep 17 00:00:00 2001 From: Nicola115 <2225992901@qq.com> Date: Thu, 24 Mar 2022 15:32:25 +0800 Subject: [PATCH 7/7] remove shortCloudName and completeCloudName in the terraform-elastic/metadata Signed-off-by: Nicola115 <2225992901@qq.com> --- addons/terraform-elastic/metadata.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/terraform-elastic/metadata.yaml b/addons/terraform-elastic/metadata.yaml index 101498f4..39464dfb 100644 --- a/addons/terraform-elastic/metadata.yaml +++ b/addons/terraform-elastic/metadata.yaml @@ -15,12 +15,6 @@ deployTo: dependencies: - name: terraform -# -------------------------------------Configuration Metadata for a Terraform Addon------------------------------------- -# provider short name -shortCloudName: elastic - -# The Cloud name of the provider -completeCloudName: Elastic Cloud # When enabling a Terraform provider, these properties need to set for authentication. For Tencent Cloud, # name: Environment variable name when authenticating Terraform, like https://github.com/oam-dev/terraform-controller/blob/master/controllers/provider/credentials.go#L59