Environment variables in the agent configuration
Adjust agent configuration
...
- AgentConfig.yaml
...
If you prefer to pass your secrets with environment variables, that's no problem.
Instead of your secret, specify the name of an environment variable in the corresponding field.
...
Code Block | ||
---|---|---|
| ||
type: AWS agentToken: 12:72211049-cfbc-4ba7-9f45-7139a14e302b accessKey: ${env:ACCESS_KEY} secretAccessKey: ${env:SECRET_ACCESS_KEY} region: eu-central-1 stage: test |
Adjust the agent
...
- docker-compose.yml
...
Now you just need to tell Docker to forward the environment variables. To do this, add the following for each environment variable.
...
https://docs.docker.com/engine/swarm/secrets/
Adjust agent configuration
...
- AgentConfig.yaml
...
Docker secrets are mounted into the container as files. In the agent's configuration we just need to enter where it can find it.
https://docs.docker.com/engine/swarm/secrets/#about-secrets
Code Block |
---|
${file:UTF-8:/run/secrets/<secret-name>} |
...
Code Block |
---|
echo "mySecretAccessKey" | docker secret create awsProdSecretAccessKey - |
Adjust the agent
...
- docker-compose.yml
...
After that, we need to make a few changes in docker-compose. First, we need to remove the container_name. This is not supported in Swarm mode.
...