AWS CLI CodeBuild update-project --environment-variable does not work.

0

Dear AWS Seniors/Support Team

I wish to insert a new environment variable into a codebuild project.

So far I only know about aws codebuild update-project --environment file://sample.json. And this is after I extract the json using this: aws codebuild describe-project --name example --query projects[*].environment.environmentVariables > sample.json.

Any reason why the command in the subject doesn't work?

I'm running this command in codepipeline so I don't want to have any secrets exposed.

Thanks and Best Regards,

newbietoaws

asked a month ago41 views
1 Answer
0

Hello.

The command "aws codebuild describe-project" does not exist.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codebuild/index.html

You must use "batch-get-projects" to retrieve CodeBuild project settings.
This is just a guess, but I think you are running a non-existent command called "aws codebuild describe-project" and the correct environment variables are not recorded in "sample.json".
You can execute the following commands.

aws codebuild batch-get-projects --names kobayashi --query "projects"[]."environment" | jq .[] > sample.json
aws codebuild update-project --name kobayashi --environment file://sample.json

By the way, the contents of "sample.json" are as follows.

{
  "type": "LINUX_CONTAINER",
  "image": "aws/codebuild/amazonlinux2-x86_64-standard:5.0",
  "computeType": "BUILD_GENERAL1_SMALL",
  "environmentVariables": [
    {
      "name": "test",
      "value": "test-kobayashi-test-kobayashi",
      "type": "PLAINTEXT"
    },
    {
      "name": "abc",
      "value": "test-kobayashi-test-kobayashi",
      "type": "PLAINTEXT"
    }
  ],
  "privilegedMode": false,
  "imagePullCredentialsType": "CODEBUILD"
}
profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions