Live Environments
This guide will assist you in integrating Vault++ into your staging or production environment.
Prerequisites
- Have a Vault++ account.
- Have created an application and added some secrets to non-local environment (for example staging).
Introduction
Vault++ injects secrets into your application during deployment, offering several advantages:
- Zero resource overhead: Unlike using an SDK or a wrapper command, this method imposes no additional CPU or memory usage.
- Enhanced Security: By reducing the number of secret touchpoints, security is improved. The deployment pipeline, which typically already has access to secrets, serves as the sole touchpoint, eliminating the need for an agent within your infrastructure.
- Seamless Integration of Secret Updates: This approach ensures that applications can be redeployed immediately when secrets are updated, maintaining synchronization between deployments and secret changes.
- No Token Management: Since secrets are injected directly during deployment, applications do not need to manage or store tokens or credentials to access Vault++, further simplifying secret management and reducing the risk of token leaks.
1. Create a service account
A service account facilitates Vault++ access from your CICD pipeline. To create a service account and integrate it into your CICD pipeline, follow these steps:
- Github Actions
- Bitbucket Pipeline
- Gitlab Pipeline
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example CICD - Staging, then press Enter.
-
A dialog will display the private key and an encryption password. Do not close the dialog as you cannot access these credentials again after closing.
-
In a new browser tab, open your GitHub repository and click the Settings tab.
-
Under the Code and automation section in the left sidebar, select Environments.
infoEnsure that environment names in GitHub match those in Vault++. If no matching environment exists, create one by clicking the New Environment button.
-
Select the appropriate environment (e.g., staging) and add the following secrets from the Vault++ dialog:
VPP_SERVICE_ACCOUNT_KEY
VPP_SERVICE_ACCOUNT_PASSWORD
-
In the environment settings, configure the Deployment branches and tags to restrict access. Choose Protected branches only or specify selected branches (e.g., main or master) to prevent unauthorized access from unintended branches or pipelines, such as those triggered by pull requests.
tipFor repositories on GitHub Free, the Environments feature is unavailable. Instead, use Repository Secrets located under Security → Secrets and Variables → Actions.
Note that using Repository Secrets exposes the service account to all branches, which is less secure. In this setup, you may grant the service account access to multiple environments in Vault++ during Step 10, as using multiple service accounts offers no additional benefit.
Return to Vault++, close the service account dialog and click the Update Access button (showing as 0 ENVIRONMENTS).
Allow access to the environment you just configured, for example staging, and click Save.
Best Practice: Assign only one environment per service account to maintain clear separation of access and enhance security.
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example CICD - Staging, then press Enter.
-
A dialog will display the private key and an encryption password. Do not close the dialog as you cannot access these credentials again after closing.
-
In a new browser tab, open your Bitbucket repository.
-
In the left sidebar, click Repository Settings and then click Deployments under the Pipelines group.
-
Select the appropriate environment (e.g., staging) and add the following secrets from the Vault++ dialog:
VPP_SERVICE_ACCOUNT_KEY
VPP_SERVICE_ACCOUNT_PASSWORD
tipIf you are on Bitbucket paid plans, restrict access to this environment by adding your main/master branch to Branches allowed to deploy to <env>. Targeting main branch is important to prevent access to this service account from unintended branches or pipelines, such as those triggered by pull requests.
Return to Vault++, close the service account dialog and click the Update Access button (showing as 0 ENVIRONMENTS).
Allow access to the environment you just configured, for example staging, and click Save.
Best Practice: Assign only one environment per service account to maintain clear separation of access and enhance security.
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example CICD - Staging, then press Enter.
-
A dialog will display the private key and an encryption password. Do not close the dialog as you cannot access these credentials again after closing.
-
In a new browser tab, open your GitLab repository.
-
In the left sidebar, click Operate and then click the Environments.
-
Ensure that environment names in GitLab match those in Vault++. If no matching environment exists, create one by clicking the New Environment button add a new one, for example staging.
-
In the left sidebar, click Settings and click CI/CD.
-
Find the Variables section, and click the Add Variable button.
-
Use the following reference to add both
VPP_SERVICE_ACCOUNT_KEY
andVPP_SERVICE_ACCOUNT_PASSWORD
from Vault++ to GitLab:- Set Type to Variable
- Set Environments to the environment you created in step 7 (for example staging)
- Set Visibility to Masked and hidden
- Enable the Protect variable flag
- Disable the Expand variable reference
- Set key to
VPP_SERVICE_ACCOUNT_KEY
orVPP_SERVICE_ACCOUNT_PASSWORD
- Set value according to the key you set
You can use the same variable key with different values in GitLab CI/CD variables. This allows you to assign different values to VPP_SERVICE_ACCOUNT_KEY
and VPP_SERVICE_ACCOUNT_PASSWORD
for each environment, which implies using different service accounts for each environment.
Return to Vault++, close the service account dialog and click the Update Access button (showing as 0 ENVIRONMENTS).
Allow access to the environment you just configured, for example staging, and click Save.
Best Practice: Assign only one environment per service account to maintain clear separation of access and enhance security.
2. Create export command
To provide secrets for your application, you need to create a vpp export command which you will use in your CICD pipelines.
The vpp export command allows you to export secrets as Kubernetes Opaque Secrets which can be attached to your Kubernetes Deployment. Below is an example of a vpp export command that exports secrets as Kubernetes Opaque Secrets:
# vpp export --help
# Usage: vpp export [options] <file>
# For Kubernetes:
# -o, --output k8s
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
# --k8s-secret-name <name> Kubernetes secret name
# --k8s-secret-namespace <namespace> Optional Kubernetes secret namespace
vpp export --exclude=CI_ --output=k8s --k8s-secret-name=my-api-secret --env=staging secrets.yaml
kubectl apply -f secrets.yaml # apply the secret resource and make it available in your cluster
Below is an example of a Kubernetes Deployment attaching secrets from Kubernetes Secret resource.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-api-deployment
labels:
app: my-api
spec:
replicas: 3
selector:
matchLabels:
app: my-api
template:
metadata:
labels:
app: my-api
spec:
containers:
- name: api
image: my-api:12345
ports:
- containerPort: 80
env:
- name: DEMO_SECRET_1
valueFrom:
secretKeyRef:
name: my-api-secret
key: DEMO_SECRET_1
- name: DEMO_SECRET_2
valueFrom:
secretKeyRef:
name: my-api-secret
key: DEMO_SECRET_2
If you need more customizations, you can use the YAML export format and load your own custom Kubernetes Secret template.
The vpp export command supports exporting secrets to AWS Secrets Manager using a JSON format that can be read by the AWS CLI secretsmanager put-secret-value. Your ECS application can then access the secrets using the native ECS integration with AWS Secrets Manager.
Below is an example of vpp export command to export secrets to AWS Secrets Manager:
# vpp export --help
# Usage: vpp export [options] <file>
# For ECS (via AWS Secrets Manager):
# -o, --output json
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=json --env=staging secrets.json
aws secretsmanager put-secret-value --secret-id your-secret-id --secret-string "$(cat secrets.json)"
# deploy your ECS app after...
aws ecs update-service --force-new-deployment --cluster cluster-name --service svc-name --task-definition task-def-name
The following is an example of attaching secrets in an ECS Container Definition:
{
"name": "example-name",
"image": "12345678.dkr.ecr.us-east-1.amazonaws.com/some-repo@sha256:1234567890",
"cpu": 0,
"portMappings": [],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"secrets": [
{
"name": "EXAMPLE_SECRET_ONE",
"valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890123:secret:secret_id:EXAMPLE_SECRET_ONE::"
},
{
"name": "EXAMPLE_SECRET_TWO",
"valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890123:secret:secret_id:EXAMPLE_SECRET_TWO::"
},
{
"name": "EXAMPLE_SECRET_THREE",
"valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890123:secret:secret_id:EXAMPLE_SECRET_THREE::"
}
],
"stopTimeout": 100,
"logConfiguration": {},
"systemControls": []
}
The vpp export command supports exporting secrets to AWS Secrets Manager using a JSON format that can be read by the AWS CLI secretsmanager put-secret-value. Your Lambda application can then access the secrets using the native Lambda integration with AWS Secrets Manager.
We highly recommend using the Lambda Secret Extension instead of storing secrets in Lambda's Environment Variables to minimize your exposure risk.
Below is an example of vpp export command to export secrets to AWS Secrets Manager:
# vpp export --help
# Usage: vpp export [options] <file>
# For Lambda (via AWS Secrets Manager):
# -o, --output json
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=json --env=staging secrets.json
aws secretsmanager put-secret-value --secret-id your-secret-id --secret-string "$(cat secrets.json)"
# deploy your Lambda after...
aws lambda update-function-code --function-name your-function --zip-file fileb://main.zip
The vpp export command supports exporting secrets in JSON format, which Terraform can read as a .tfvars.json variable file. Below is an example of the vpp export command to export secrets as a Terraform JSON variable file:
# vpp export --help
# Usage: vpp export [options] <file>
# For Terraform:
# -o, --output json
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=json --env=staging secrets.tfvars.json # file name must ends with .tfvars.json
terraform apply -var-file="secrets.tfvars.json" # use it in terraform
The vpp export command supports exporting secrets to Pulumi Configuration that you can access using Config.requireSecret (secrets) and Config.require (variables) in your Pulumi code.
Since the pulumi config set-all command doesn't support reading an input file, vpp exports a shell script that wraps the pulumi config set-all command with the secret values. You can then run the script to set pulumi config values before running the pulumi up. The following is an example of vpp export command to export secrets to Pulumi:
- bash / sh / zsh
- fish
- powershell
# vpp export --help
# Usage: vpp export [options] <file>
# For Pulumi:
# -o, --output pulumi
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=pulumi --env=staging pulumi-config.sh
# pulumi-config.sh contains 'pulumi config set-all' command to set pulumi config
bash pulumi-config.sh
pulumi up -y
# vpp export --help
# Usage: vpp export [options] <file>
# For Pulumi:
# -o, --output pulumi
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=pulumi --env=staging pulumi-config.fish
# pulumi-config.fish contains 'pulumi config set-all' command to set pulumi config
fish pulumi-config.fish
pulumi up -y
# vpp export --help
# Usage: vpp export [options] <file>
# For Pulumi:
# -o, --output pulumi
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=pulumi --env=staging pulumi-config.ps1
# pulumi-config.ps1 contains 'pulumi config set-all' command to set pulumi config
pwsh pulumi-config.ps1
pulumi up -y
The vpp export command supports exporting secrets in JSON format that can be read by the Wrangler secret:bulk command. The following is an example of vpp export command to export secrets to Cloudflare Workers:
# vpp export --help
# Usage: vpp export [options] <file>
# For Cloudflare Workers/Wrangler:
# -o, --output json
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=json --env=staging secrets.json
wrangler deploy
wrangler secret:bulk secrets.json
The vpp export command supports exporting secrets as Fly.io KEY=VALUE pair that can be read by Flyctl secrets import. The following is an example of vpp export command to export secrets to Fly.io:
# vpp export --help
# Usage: vpp export [options] <file>
# For Fly.io:
# -o, --output fly.io
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=fly.io --env=staging secrets.flyio
fly deploy
fly secrets import < secrets.flyio
The vpp export command supports exporting secrets in JSON format that can be loaded directly by your application or imported to your hosting platform.
# vpp export --help
# Usage: vpp export [options] <file>
# For JSON:
# -o, --output json
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for example --exclude CI_
vpp export --exclude=CI_ --output=json --env=staging secrets.json
The vpp export command supports exporting secrets in YAML format that can be loaded directly by your application or imported to your hosting platform.
# vpp export --help
# Usage: vpp export [options] <file>
# For YAML:
# -o, --output yaml
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include
# CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for
# example --exclude CI_
# --yaml-template <template> [OPTIONAL] YAML template used to create YAML file
# --yaml-key <path> [OPTIONAL] YAML Key to insert the config in YAML template, for
# example: data/env
vpp export --exclude=CI_ --output=yaml --yaml-template template.yml --yaml-key 'app/secrets' --env=staging secrets.yml
The YAML exporter supports reading a YAML template (--yaml-template
) and set the secrets into the specified location (--yaml-key
). One application for this is to assign secrets to a custom Kubernetes Secrets definition. The following is an example of using a YAML template:
# Example template:
app:
test:
name: test
demo:
name: demo
# Run a command:
# vpp export --exclude=CI_ --output=yaml --yaml-template template.yml --yaml-key 'app/test/secrets' --env=staging secrets.json
# Output YAML:
app:
test:
name: test
secrets:
SECRET_ONE: abcde
SECRET_TWO: demo
SECRET_THREE: example'
demo:
name: demo
If no template is provided, secrets will be exported at the root of the yaml document.
The vpp export command supports exporting secrets in various format, such as JSON, YAML, Kubernetes Secrets, etc. You may select one that is most suitable for your hosting platform, for example if your hosting platform supports importing secrets from a JSON file, you can use the JSON output format to export secret for it.
The following is an example of exporting secrets as JSON:
# vpp export --help
# Usage: vpp export [options] <file>
# Options:
# -o, --output <format> (choices: "json", "yaml", "k8s", "fly.io", "github", "pulumi")
# -e, --env <env> target environment
# --include <includePrefix...> only export secrets that match provided prefix, for example --include
# CI_
# --exclude <excludePrefix...> exclude secrets that match provided prefix from being exported, for
# example --exclude CI_
# --yaml-template <template> for -o yaml: YAML template used to create YAML file
# --yaml-key <path> for -o yaml: YAML Key to insert the config in YAML template, for
# example: data/env
# --k8s-secret-name <name> for -o k8s: Kubernetes secret name
# --k8s-secret-namespace <namespace> for -o k8s: Kubernetes secret namespace
# -h, --help display help for command
vpp export --exclude=CI_ --output=json --env=staging secrets.json
If you can't find any suitable export format, please let us know by raising a feature request here.
3. Integrate with CICD
After having a suitable vpp export command for your app, you can start integrating it with your CICD pipelines.
- Github Actions
- Bitbucket Pipeline
- Gitlab Pipeline
The following is an example of GitHub Actions pipeline for deploying Kubernetes app using Vault++ secrets.
name: Deploy Kubernetes App
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
- run: aws eks update-kubeconfig --name ${{ steps.vpp.outputs.CI_EKS_CLUSTER }} --region ${{ steps.vpp.outputs.CI_AWS_REGION }}
- id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- run: |
docker build -t $ECR_REGISTRY/my-api:$IMAGE_TAG .
docker push $ECR_REGISTRY/my-api:$IMAGE_TAG
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
# Export secrets as Kubernetes Opaque Secret and run kubectl apply to make it available for your Deployment.
# Exclude secrets with CI_ prefix from the export.
- run: |
vpp export --exclude=CI_ --output=k8s --k8s-secret-name=my-api-secret --env=${{ inputs.environment || 'staging' }} .tmp-api-secrets.yaml
kubectl apply -f .tmp-api-secrets.yaml
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: |
sed -i.bak "s|DOCKER_IMAGE|$ECR_REGISTRY/my-api:$IMAGE_TAG|g" manifests/my-api-deployment.yaml
kubectl apply -f manifests/my-api-deployment.yaml
kubectl apply -f manifests/my-api-service.yaml
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
The following is an example of GitHub Actions pipeline for deploying ECS app using Vault++ secrets.
name: Deploy ECS App
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
- id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- run: |
docker build -t $ECR_REGISTRY/my-api:$IMAGE_TAG .
docker push $ECR_REGISTRY/my-api:$IMAGE_TAG
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- run: |
vpp export --exclude=CI_ --output=json --env=${{ inputs.environment || 'staging' }} secrets.json
aws secretsmanager put-secret-value --secret-id ${{ steps.vpp.outputs.CI_SECRETS_ID }} --secret-string "$(cat secrets.json)"
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: |
sed -i.bak "s|DOCKER_IMAGE|$ECR_REGISTRY/my-api:$IMAGE_TAG|g" ecs/task-definition.json
aws ecs register-task-definition --family ${{ steps.vpp.outputs.CI_TASK_DEFINITION }} --cli-input-json file://ecs/task-definition.json
aws ecs update-service --force-new-deployment --cluster ${{ steps.vpp.outputs.CI_CLUSTER_NAME }} --service ${{ steps.vpp.outputs.CI_SERVICE_NAME }} --task-definition ${{ steps.vpp.outputs.CI_TASK_DEFINITION }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
The following is an example of GitHub Actions pipeline for deploying Lambda app using Vault++ secrets.
name: Deploy Lambda App
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- run: |
vpp export --exclude=CI_ --output=json --env=${{ inputs.environment || 'staging' }} secrets.json
aws secretsmanager put-secret-value --secret-id ${{ steps.vpp.outputs.CI_SECRETS_ID }} --secret-string "$(cat secrets.json)"
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: |
zip main.zip main.py
aws lambda update-function-code --function-name ${{ steps.vpp.outputs.CI_LAMBDA_NAME }} --zip-file fileb://main.zip
The following is an example of GitHub Actions pipeline for deploying Terraform app using Vault++ secrets.
name: Deploy Terraform App
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
# Export secrets as a JSON file. The file name must end with .tfvars.json for Terraform to accept.
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --output=json --env=${{ inputs.environment || 'staging' }} .tmp-api-secrets.tfvars.json
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: terraform apply -auto-approve -input=false -var-file=".tmp-api-secrets.tfvars.json"
The following is an example of GitHub Actions pipeline for deploying Pulumi app using Vault++ secrets.
name: Deploy Pulumi App
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pulumi/actions@v6
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to Pulumi
- run: pulumi login
env:
PULUMI_ACCESS_TOKEN: ${{ steps.vpp.outputs.CI_PULUMI_ACCESS_TOKEN }}
PULUMI_CONFIG_PASSPHRASE: ${{ steps.vpp.outputs.CI_PULUMI_CONFIG_PASSPHRASE }}
# Export a script to set Pulumi config containing secrets.
# Exclude secrets with CI_ prefix from the export.
- run: |
vpp export --exclude=CI_ --output=pulumi --env=${{ inputs.environment || 'staging' }} pulumi-config.sh
bash pulumi-config.sh
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: pulumi up -y
The following is an example of GitHub Actions pipeline for deploying Cloudflare Workers using Vault++ secrets.
name: Deploy Cloudflare Workers
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Export secrets as a JSON file for wrangler secret:bulk command
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --output=json --env=${{ inputs.environment || 'staging' }} secrets.json
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Deploy Workers
- run: |
wrangler deploy
wrangler secret:bulk secrets.json
env:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
CLOUDFLARE_API_TOKEN: ${{ steps.vpp.outputs.CI_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ steps.vpp.outputs.CI_CLOUDFLARE_ACCOUNT_ID }}
The following is an example of GitHub Actions pipeline for deploying Fly.io Apps using Vault++ secrets.
name: Deploy Fly.io
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Export secrets as a Fly.io KEY=VALUE file for 'fly secrets import'.
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --output=fly.io --env=${{ inputs.environment || 'staging' }} secrets.flyio
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Deploy Fly.io
- run: |
fly deploy
fly secrets import < secrets.flyio
env:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
FLY_API_TOKEN: ${{ steps.vpp.outputs.CI_FLY_API_TOKEN }}
The following is an example of exporting secrets as JSON in a GitHub Actions pipeline.
name: Export JSON Secrets
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
# Export secrets as a JSON file named 'secrets.json'
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --output=json --env=${{ inputs.environment || 'staging' }} secrets.json
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: make deploy
The following is an example of exporting secrets as YAML in a GitHub Actions pipeline.
name: Export YAML Secrets
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=${{ inputs.environment || 'staging' }} secrets.yml
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: make deploy
The following is an example of exporting secrets in a GitHub Actions pipeline.
name: Export Secrets
on:
push:
branches:
- main
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
# If you are not on GitHub paid plans, you can remove the following line.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# We will touch more on ${{ inputs.environment || 'staging' }} in the next step.
#
# Exporting to $GITHUB_OUTPUT will make secrets available as steps.vpp.outputs.XXXX to subsequent steps
# You can also export to $GITHUB_ENV to make secrets available as environment variables for subsequent steps
- id: vpp
run: vpp export --include CI_ -o github --env=${{ inputs.environment || 'staging' }} $GITHUB_OUTPUT
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
# Example Login to AWS
- uses: aws-actions/configure-aws-credentials@v4
with:
# accessing CICD secrets using ${{ steps.<step-id>.outputs.<SECRET_KEY> }}
aws-access-key-id: ${{ steps.vpp.outputs.CI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ steps.vpp.outputs.CI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ steps.vpp.outputs.CI_AWS_REGION }}
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- run: vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=${{ inputs.environment || 'staging' }} secrets.yml
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
- run: make deploy
You may notice the use of ${{ inputs.environment || 'staging' }}
in the pipeline above. Vault++ will provide inputs.environment
to your pipeline (as shown in the next step) so it knows which environment needs to be deployed. You can specify a default value in case you trigger the pipeline using another method, such as on push. In this example, the default value will be staging.
The following is an example of Bitbucket Pipeline for deploying Kubernetes app using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# $CI_ECR_REGISTRY is from vpp above
- docker build -t $CI_ECR_REGISTRY/my-api:$BITBUCKET_COMMIT .
- pipe: atlassian/aws-ecr-push-image:2.4.2
variables:
# Example of using secrets in CI from vpp above
AWS_ACCESS_KEY_ID: $CI_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $CI_AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $CI_AWS_DEFAULT_REGION
IMAGE_NAME: $CI_ECR_REGISTRY/my-api:$BITBUCKET_COMMIT
# Export secrets as Kubernetes Opaque Secret and run kubectl apply to make it available for your Deployment.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=k8s --k8s-secret-name=my-api-secret --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .tmp-api-secrets.yaml
- pipe: atlassian/aws-eks-kubectl-run:3.0.0
variables:
AWS_ACCESS_KEY_ID: $CI_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $CI_AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $CI_AWS_DEFAULT_REGION
CLUSTER_NAME: $CI_CLUSTER_NAME
KUBECTL_COMMAND: 'apply'
RESOURCE_PATH: '.tmp-api-secrets.yaml'
- sed -i.bak "s|DOCKER_IMAGE|$CI_ECR_REGISTRY/my-api:$BITBUCKET_COMMIT|g" manifests/my-api-deployment.yaml
- pipe: atlassian/aws-eks-kubectl-run:3.0.0
variables:
AWS_ACCESS_KEY_ID: $CI_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $CI_AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $CI_AWS_DEFAULT_REGION
CLUSTER_NAME: $CI_CLUSTER_NAME
KUBECTL_COMMAND: 'apply'
RESOURCE_PATH: 'manifests/my-api-deployment.yaml'
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying ECS app using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install the AWS CLI
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# set AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# $CI_ECR_REGISTRY is from vpp above
- docker build -t $CI_ECR_REGISTRY/my-api:$BITBUCKET_COMMIT .
- pipe: atlassian/aws-ecr-push-image:2.4.2
variables:
# Example of using secrets in CI from vpp above
IMAGE_NAME: $CI_ECR_REGISTRY/my-api:$BITBUCKET_COMMIT
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.json
- aws secretsmanager put-secret-value --secret-id $CI_SECRETS_ID --secret-string "$(cat secrets.json)"
- sed -i.bak "s|DOCKER_IMAGE|$ECR_REGISTRY/my-api:$IMAGE_TAG|g" ecs/task-definition.json
- pipe: atlassian/aws-ecs-deploy:1.12.2
variables:
CLUSTER_NAME: $CI_CLUSTER_NAME
SERVICE_NAME: $CI_SERVICE_NAME
TASK_DEFINITION: ecs/task-definition.json
FORCE_NEW_DEPLOYMENT: 'true'
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying Lambda app using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install the AWS CLI
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# set AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.json
- aws secretsmanager put-secret-value --secret-id $CI_SECRETS_ID --secret-string "$(cat secrets.json)"
- zip main.zip main.py
- pipe: atlassian/aws-lambda-deploy:1.12.0
variables:
FUNCTION_NAME: $CI_LAMBDA_NAME
COMMAND: 'update'
ZIP_FILE: 'main.zip'
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying Terraform app using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install the Terraform CLI
- curl "https://releases.hashicorp.com/terraform/1.10.3/terraform_1.10.3_linux_amd64.zip" -o terraform.zip && unzip terraform.zip && mv terraform /usr/local/bin/
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a JSON file. The file name must end with .tfvars.json for Terraform to accept.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .tmp-api-secrets.tfvars.json
- terraform apply -auto-approve -input=false -var-file=".tmp-api-secrets.tfvars.json"
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying Pulumi app using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install the Pulumi CLI
- curl -L "https://github.com/pulumi/pulumi/releases/download/v3.144.1/pulumi-v3.144.1-linux-x64.tar.gz" -o pulumi.tar.gz && tar -xvzf pulumi.tar.gz -C /usr/local/bin/ --strip-components=1
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Example login to pulumi with credentials from VPP
- PULUMI_ACCESS_TOKEN=$CI_PULUMI_ACCESS_TOKEN PULUMI_CONFIG_PASSPHRASE=$CI_PULUMI_CONFIG_PASSPHRASE pulumi login
# Export a script to set Pulumi config containing secrets.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=pulumi --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT pulumi-config.sh
- bash pulumi-config.sh
- pulumi up -y
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying Cloudflare Workers using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting Cloudflare credentials from exported vpp secrets above
- export CLOUDFLARE_API_TOKEN=$CI_CLOUDFLARE_API_TOKEN
- export CLOUDFLARE_ACCOUNT_ID=$CI_CLOUDFLARE_ACCOUNT_ID
# Export secrets as a JSON file for wrangler secret:bulk command
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.json
- npx wrangler deploy
# Set secrets from VPP
- npx wrangler secret:bulk secrets.json
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of Bitbucket Pipeline for deploying Fly.io Apps using Vault++ secrets.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install flyctl CLI
- curl -L https://fly.io/install.sh | sh && export PATH="$HOME/.fly/bin:$PATH"
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting Fly credentials from exported vpp secrets above
- export FLY_API_TOKEN=$CI_FLY_API_TOKEN
# Export secrets as a Fly.io KEY=VALUE file for 'fly secrets import'.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=fly.io --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.flyio
# Example deploy Fly.io
- fly deploy
# Set secrets from VPP
- fly secrets import < secrets.flyio
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of exporting secrets as JSON in a Bitbucket Pipeline.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a JSON file named 'secrets.json'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.json
- make deploy
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of exporting secrets as YAML in a Bitbucket Pipeline.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.yml
- make deploy
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
The following is an example of exporting secrets in a Bitbucket Pipeline.
template:
task-definition: &task-definition
variables:
- name: action
default: sync
allowed-values:
- sync
- rotate
# You can reference *deploy-step anywhere in your existing YAML, including existing pipelines that you already have
deploy: &deploy-step
script:
# Install VPP
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ -o shell --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=$BITBUCKET_DEPLOYMENT_ENVIRONMENT secrets.yml
- make deploy
image: atlassian/default-image:4
pipelines:
custom:
deploy-app-staging:
- <<: *task-definition
- step:
deployment: staging
<<: *deploy-step
deploy-app-prod:
- <<: *task-definition
- step:
deployment: prod
<<: *deploy-step
# your other pipelines...
Bitbucket Pipelines doesn't support dynamic deployments (such as deployment: $dynamic
). Therefore, in the example above, each deployment (e.g., staging and prod) will need to have its own task (e.g., deploy-app-staging and deploy-app-prod).
The following is an example of GitLab Pipeline for deploying Kubernetes app using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: image-containing-aws-kubectl:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example using CI_ secrets exported from the previous step
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
- aws eks update-kubeconfig --name $CI_CLUSTER_NAME
- docker build -t $CI_ECR_REGISTRY/my-api:$CI_COMMIT_SHORT_SHA .
- docker push $CI_ECR_REGISTRY/my-api:$CI_COMMIT_SHORT_SHA
# Export secrets as Kubernetes Opaque Secret and run kubectl apply to make it available for your Deployment.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=k8s --k8s-secret-name=my-api-secret --env=$VPP_ENVIRONMENT .tmp-api-secrets.yaml
- kubectl apply -f .tmp-api-secrets.yaml
- sed -i.bak "s|DOCKER_IMAGE|$CI_ECR_REGISTRY/my-api:$CI_COMMIT_SHORT_SHA|g" manifests/my-api-deployment.yaml
- kubectl apply -f manifests/my-api-deployment.yaml
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying ECS app using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example using CI_ secrets exported from the previous step
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
- docker build -t $CI_ECR_REGISTRY/my-api:$CI_COMMIT_SHORT_SHA .
- docker push $CI_ECR_REGISTRY/my-api:$CI_COMMIT_SHORT_SHA
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$VPP_ENVIRONMENT secrets.json
- aws secretsmanager put-secret-value --secret-id $CI_SECRETS_ID --secret-string "$(cat secrets.json)"
- sed -i.bak "s|DOCKER_IMAGE|$ECR_REGISTRY/my-api:$IMAGE_TAG|g" ecs/task-definition.json
- aws ecs register-task-definition --family $CI_TASK_DEFINITION --cli-input-json file://ecs/task-definition.json
- aws ecs update-service --force-new-deployment --cluster $CI_CLUSTER_NAME --service $CI_SERVICE_NAME --task-definition $CI_TASK_DEFINITION
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying Lambda app using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example using CI_ secrets exported from the previous step
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as JSON and import it to AWS Secrets Manager.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$VPP_ENVIRONMENT secrets.json
- aws secretsmanager put-secret-value --secret-id $CI_SECRETS_ID --secret-string "$(cat secrets.json)"
- zip main.zip main.py
- aws lambda update-function-code --function-name $CI_LAMBDA_NAME --zip-file fileb://main.zip
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying Terraform app using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example using CI_ secrets exported from the previous step
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a JSON file. The file name must end with .tfvars.json for Terraform to accept.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$VPP_ENVIRONMENT .tmp-api-secrets.tfvars.json
- terraform apply -auto-approve -input=false -var-file=".tmp-api-secrets.tfvars.json"
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying Pulumi app using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example using CI_ secrets exported from the previous step
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Example login to pulumi with credentials from VPP
- PULUMI_ACCESS_TOKEN=$CI_PULUMI_ACCESS_TOKEN PULUMI_CONFIG_PASSPHRASE=$CI_PULUMI_CONFIG_PASSPHRASE pulumi login
# Export a script to set Pulumi config containing secrets.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=pulumi --env=$VPP_ENVIRONMENT pulumi-config.sh
- bash pulumi-config.sh
- pulumi up -y
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying Cloudflare Workers using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting Cloudflare credentials from exported vpp secrets above
- export CLOUDFLARE_API_TOKEN=$CI_CLOUDFLARE_API_TOKEN
- export CLOUDFLARE_ACCOUNT_ID=$CI_CLOUDFLARE_ACCOUNT_ID
# Export secrets as a JSON file for wrangler secret:bulk command
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$VPP_ENVIRONMENT secrets.json
- npx wrangler deploy
# Set secrets from VPP
- npx wrangler secret:bulk secrets.json
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of GitLab Pipeline for deploying Fly.io Apps using Vault++ secrets.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting Fly credentials from exported vpp secrets above
- export FLY_API_TOKEN=$CI_FLY_API_TOKEN
# Export secrets as a Fly.io KEY=VALUE file for 'fly secrets import'.
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=fly.io --env=$VPP_ENVIRONMENT secrets.flyio
# Example deploy Fly.io
- fly deploy
# Set secrets from VPP
- fly secrets import < secrets.flyio
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of exporting secrets as JSON in a GitLab Pipeline.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a JSON file named 'secrets.json'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --output=json --env=$VPP_ENVIRONMENT secrets.json
- make deploy
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of exporting secrets as YAML in a GitLab Pipeline.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=$VPP_ENVIRONMENT secrets.yml
- make deploy
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
The following is an example of exporting secrets in a GitLab Pipeline.
.deploy:
# if you encountered an error: 'vpp: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by vpp)'
# it means your docker image has GLIBC version below 2.27. You will need to update GLIBC in your image
# to be greater or equal than 2.27.
image: your-cicd-image:latest
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# You can store credentials for your CICD pipeline using the same Application in Vault++.
# You can use a prefix, for example CI_, to easily filter the secrets.
#
# The following will exports secrets with CI_ prefix:
- vpp export --include CI_ --output=shell --env=$VPP_ENVIRONMENT .ci-secrets.sh
# And this will make the exported secrets available as environment variables.
- source .ci-secrets.sh
# Example of setting AWS credentials from exported vpp secrets above
- export AWS_ACCESS_KEY_ID=$CI_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$CI_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$CI_AWS_DEFAULT_REGION
# Export secrets as a YAML file named 'secrets.yml'
# Exclude secrets with CI_ prefix from the export.
- vpp export --exclude=CI_ --yaml-template template.yml --yaml-key 'app/secrets' --output=yaml --env=$VPP_ENVIRONMENT secrets.yml
- make deploy
vpp:
extends: .deploy
environment:
name: $VPP_ENVIRONMENT
rules:
- if: $VPP_ACTION
# Example re-using .deploy to an existing git push pipeline
example-on-push:
extends: .deploy
environment:
name: staging
variables:
VPP_ENVIRONMENT: staging
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
4. Enable sync
Next, we will enable automatic sync, so that every time you update secrets in Vault++, the pipeline will be triggered, and your app will be redeployed with the new secrets.
- Github Actions
- Bitbucket Pipeline
- Gitlab Pipeline
-
Add a new
workflow_dispatch
trigger to your current pipeline as follows:.github/workflows/example-app.yamlname: Deploy App
on:
push:
branches:
- main
# Workflow dispatch allows you to trigger this pipeline from your Actions tab on your GitHub project page.
# It also allows Vault++ to trigger this pipeline using a webhook.
workflow_dispatch:
inputs:
action:
required: true
type: choice
options:
- sync # 'sync' is what we want to trigger now
- rotate # we will integrate secret rotations in the next guide!
# This is where your CICD pipeline gets ${{ inputs.environment || 'staging' }} from.
environment:
# 'type: environment' is only available on GitHub paid plans.
# If you do not have access to it, you can change it into a 'type: choice', for example:
# type: choice
# options:
# - staging
# - prod
type: environment
required: true
jobs:
deploy:
name: Build and Deploy App
# Environment is only available on GitHub paid plans.
environment: ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install the vpp cli
- uses: vaultplusplus/setup@latest
## rest of the pipeline...Then commit and push your changes.
-
Go to Vault++, select your application and go to the Settings tab.
-
Find the CI Integrations section and click the Add () button.
-
Select GitHub Actions and follow the instructions to install the Vault++ GitHub App to your GitHub account.
-
Select the target repository, the workflow you just created, and the target ref (branch or tag). Then click the Save () button.
-
Click the Update Trigger button (showing as 0 ENVIRONMENTS) and enable all your live Environments.
-
Go to Vault++, select your application and go to the Settings tab.
-
Find the CI Integrations section and click the Add () button.
-
Select Bitbucket Pipeline and follow the instructions to link Vault++ to your Bitbucket Account.
-
Select the target repository, the workflow you just created, and the target ref (supported refs: <branch>, tag/<name>, named_branch/<name>, and bookmark/<name>).
-
Click the Save () button.
-
Click the Update Trigger button (showing as 0 ENVIRONMENTS) and enable the corresponding environment (for example enable staging for deploy-app-staging pipeline).
-
Add other live environments by clicking the Add () button and selecting your Bitbucket account from the list.
-
Go to Vault++, select your application and go to the Settings tab.
-
Find the CI Integrations section and click the Add () button.
-
Select GitLab Pipeline and follow the instructions to link Vault++ to your GitLab Account.
-
Select the target repository and the target ref (branch or tag). Then click the Save () button.
-
Click the Update Trigger button (showing as 0 ENVIRONMENTS) and enable all your live Environments.
Congratulations! 🎉 Your application is now secured end-to-end with Vault++! In the next guide, you will learn how to prevent leaks with Vault++ Pre-commit Check.