Expand my Community achievements bar.

Access Cloud Manager environment variables into Docker

Avatar

Level 2

I’m trying to make some configurable docker keys from Cloud Manager Environment.

How can I pass environment configurations (secrets) from Cloud Manager to Docker file?

9 Replies

Avatar

Community Advisor

You can download the environment variables as a JSON file from the API provided by adobe:

https://cloudmanager.adobe.io/api/program/{programId}/environment/{environmentId}/variables

After that, you can easily store them in Docker.

 

Reference: https://developer.adobe.com/experience-cloud/cloud-manager/reference/api/#operation/getEnvironmentVa... 

I think the question is more about how to NOT need to hardcode them in DockerFile. 
I don't want to hardcode them in the code and push them to the git repository. 

Can we access the above API from the docker instance that is created with the selenium tests in Cloud Manager? Without needing to place a "SECRET_KEY" inside the docker instance or anywhere in the code. It should come from the Cloud Manager configurations (environment) 

Avatar

Level 2

So what I need is to access those secret variables while running the ui.test docker container in Cloud Manager pipeline.

Avatar

Employee Advisor

Can you please give some context what you mean with "Docker file"? Where in the context of Cloud Manager do you use a Docker file?

Avatar

Level 2

I will try to be more explicit, so I am not able to read the configured Cloud Manager environment variable  when doing the docker-compose up in the Custom UI testing step. I have tried different places to access them:

- in the pom.xml file of the ui.tests (ui-tests-docker-execution profile - docker compose - environmentVariables <VARIABLE_NAME>${env.VARIABLE_NAME}</VARIABLE_NAME>)

- in the docker compose yaml file as environment

- in the dockerfile as ENV

Avatar

Employee Advisor

I am referring to the official documentation.

I understand it in a way, that it is the customer's responsibility to create the container; and that CM will startup the container. It's not that your maven build will start it up directly using some plugin or so.

 

For the environment variables it is stated "The following environment variables will be passed to your Docker image at run time."

That means that CM will inject these environment variables in your runtime, so that the code there can read them.

 

Now re-reading your post I assume that you want to run the same container for testing purposes on your local machine. Is this correct?

 

In that case you need to provide them as environment variables to your command (see the docker documentation, or the docs for docker compose). 

 

 

 

Avatar

Level 2

Following this official documentation, I should be able to set some secret environment variables in CM and access them at runtime by adding them in the pom.xml file (docker compose profile) under the existing ones.

Simulating this on local host by exporting these variables and then building and running the docker image would actually list them.

Trying the same in CM, would not list these already configured env vars that should be available at runtime in that pipeline. 

Avatar

Level 1

Did you manage to fix it or any news in this? We're having a similar problem. Tried setting an env var via CLI commands unfortunately build profile is not pulling it.

Avatar

Level 1

Hey @mmarascu, have you managed to solve this issue? I'm facing pretty much the same issue right now.