diff --git a/README.md b/README.md index 850e35f2d777de06c5fbe658036935805c01365f..a6b7ae4edb464e5e51c6c227276b1cd84300844b 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,59 @@ echo "[gcp-cleanup] Cleanup burger/$CI_ENVIRONMENT_SLUG..." gcloud --quiet app versions delete --project=${gcp_project_id} --service=coockedoodledoo ${CI_ENVIRONMENT_SLUG} ``` +## Variants + +The Google Cloud template can be used in conjunction with template variants to cover specific cases. + +### Vault variant + +This variant allows delegating your secrets management to a [Vault](https://www.vaultproject.io/) server. + +#### Configuration + +In order to be able to communicate with the Vault server, the variant requires the additional configuration parameters: + +| Name | description | default value | +| ----------------- | -------------------------------------- | ----------------- | +| `VAULT_BASE_URL` | The Vault server base API url | _none_ | +| :lock: `VAULT_ROLE_ID` | The [AppRole](https://www.vaultproject.io/docs/auth/approle) RoleID | **must be defined** | +| :lock: `VAULT_SECRET_ID` | The [AppRole](https://www.vaultproject.io/docs/auth/approle) SecretID | **must be defined** | + +#### Usage + +Then you may retrieve any of your secret(s) from Vault using the following syntax: + +```text +@url@http://vault-secrets-provider/api/secrets/{secret_path}?field={field} +``` + +With: + +| Name | description | +| -------------------------------- | -------------------------------------- | +| `secret_path` (_path parameter_) | this is your secret location in the Vault server | +| `field` (_query parameter_) | parameter to access a single basic field from the secret JSON payload | + +#### Example + +```yaml +include: + # main template + - project: 'to-be-continuous/gcloud' + ref: '1.5.2' + file: '/templates/gitlab-ci-gcloud.yml' + # Vault variant + - project: 'to-be-continuous/gcloud' + ref: '1.5.2' + file: '/templates/gitlab-ci-gcloud-vault.yml' + +variables: + # Secrets managed by Vault + SOME_SECRET_USED_IN_MY_APP: "@url@http://vault-secrets-provider/api/secrets/b7ecb6ebabc231/prod/gcloud/secret?field=my.app.secret" + VAULT_BASE_URL: "https://vault.acme.host/v1" + # $VAULT_ROLE_ID and $VAULT_SECRET_ID defined as a secret CI/CD variable +``` + ## Gitlab compatibility :information_source: This template is actually tested and validated on GitLab Community Edition instance version 13.12.11 diff --git a/kicker.json b/kicker.json index 94931023569cb1653e49fe821f92809d15614da6..f96825dd76ecb22da332b7de8d3b94681faeb5ae 100644 --- a/kicker.json +++ b/kicker.json @@ -146,5 +146,32 @@ } ] } + ], + "variants": [ + { + "id": "vault", + "name": "Vault", + "description": "Retrieve secrets from a [Vault](https://www.vaultproject.io/) server", + "template_path": "templates/gitlab-ci-gcloud-vault.yml", + "variables": [ + { + "name": "VAULT_BASE_URL", + "description": "The Vault server base API url", + "mandatory": true + }, + { + "name": "VAULT_ROLE_ID", + "description": "The [AppRole](https://www.vaultproject.io/docs/auth/approle) RoleID", + "mandatory": true, + "secret": true + }, + { + "name": "VAULT_SECRET_ID", + "description": "The [AppRole](https://www.vaultproject.io/docs/auth/approle) SecretID", + "mandatory": true, + "secret": true + } + ] + } ] } diff --git a/templates/gitlab-ci-gcloud-vault.yml b/templates/gitlab-ci-gcloud-vault.yml new file mode 100644 index 0000000000000000000000000000000000000000..6fb22d9110bf8dcbc3b318f7bbf294ceb64be4c0 --- /dev/null +++ b/templates/gitlab-ci-gcloud-vault.yml @@ -0,0 +1,14 @@ +# ===================================================================================================================== +# === Vault template variant +# ===================================================================================================================== +variables: + # variables have to be explicitly declared in the YAML to be exported to the service + VAULT_ROLE_ID: "$VAULT_ROLE_ID" + VAULT_SECRET_ID: "$VAULT_SECRET_ID" + +.gcp-base: + services: + - name: "$CI_REGISTRY/to-be-continuous/tools/tracking:master" + command: ["--service", "gcloud", "1.5.2" ] + - name: "$CI_REGISTRY/to-be-continuous/tools/vault-secrets-provider:master" + alias: "vault-secrets-provider"