0

thx for any help.

I'm using AWS-CodePipline with AWS-CodeBuild(for my Dockerfile and save it in ECR). So far it is working. But I don't get how I get my environment variables in the project. So I connected my Github account with CodePipline and I didn't pushed my envs to Github for security. So now I have on Github a env-file like:

config/prod.env

ACCESS_TOKEN_SECRET=
CSRF_TOKEN_SECRET=
ACCESS_TOKEN_PASSWORD=
REFRESH_TOKEN_SECRET=
CLUDINARY_API=
CLUDINARY_API_SECRET=
CLUDINARY_API_NAME=
GOOGLE_AUDIENCE=
ORIGIN=
GOOGLE_TOKEN=
DATABASE_URL=
NODE_ENV=
FORGOTTEN_PASSWORD=
YAHOO_PASSWORD=

Now on AWS-CodeBilder is a section for environment variables(Image from AWS-Doc). enter image description here

Now I have the feeling this is not the right place for env's. Because if I put all my variables inside the fields I get the error:

ValidationException
1 validation error detected: Value at 'pipeline.stages.2.member.actions.1.member.configuration' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 1000, Member must have length greater than or equal to 1]

On Example:

Name: ACCESS_TOKEN_SECRET
Value: My_SUPER_PASSWORD

If I'm using just a few variables I don't get an error but for all variables I get the error(dosen't matter of the env-combination). What I'm doing wrong? How can I get my env-variables to my Docker-Image in ECR with CodeBuild & CodePipline?

2
  • What is your code that produces the error you reported? Commented Feb 21, 2021 at 22:47
  • I'm getting the error in aws if I put my variables in the environment variables section at CodeBuild. Commented Feb 22, 2021 at 2:21

1 Answer 1

2

To pass variables from Code Build Project, you need to set env: section in buildspec.yml file, for example

env:
  variables:
    Execution_ID: $Execution_ID
    Commit_ID: $Commit_ID
Sign up to request clarification or add additional context in comments.

2 Comments

Thx for your answere but where do you define $Execution_ID and $Commit_ID?
In Code Build Project, as you did

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.