Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codebuild_build.sh fails on accessing AWS configuration when the user folder contains a space #546

Closed
ryanm1-digital opened this issue Jul 7, 2022 · 1 comment

Comments

@ryanm1-digital
Copy link

Describe the bug
If the path to the aws credentials contains a space then then when the container executes an aws command (e.g. accessing the parameter store) the console presents the following error:

MissingRegion: could not find region configuration

To Reproduce
Following the official documentation here to create the env:

docker pull public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:3.0
docker pull public.ecr.aws/codebuild/local-builds:latest

Local Config:

User folder: C:\Users\Joe Blogs\ <-- ***space in name***
AWS Credentials located at: C:\Users\Joe Blogs\.aws <-- ***space in name***

Local buildspec.yml:

version: 0.2

env:  

  parameter-store:
    TestVar: "TEST_VAR"

phases:
  install:
    commands:
      - echo Testing...

Running the script with the following parameters:

./codebuild_build.sh -i public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:3.0 -a artifacts -m -c 

This produces the following error:

Phase complete: DOWNLOAD_SOURCE State: FAILED
Phase context status code: Decrypted Variables Error Message: MissingRegion: could not find region configuration
Runtime error (*clienterr.PhaseContextError: MissingRegion: could not find region configuration)

See the Environment tab in the docker container created by the above command to see that the following environment variable was created:

name: AWS_CONFIGURATION
value: //C/Users/Joe Blogs/.aws

Expected behavior
The container should be able to find the aws credentials even if the environment variable generated as part of the docker run command contains a space.

Platform (please complete the following information):
Windows 10.19044
Git 2.35.0.windows.1
Docker 20.10.17

Logs

$ ./codebuild_build.sh -i public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:3.0 -a artifacts -m -c
Build Command:

winpty docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:3.0" -e "ARTIFACTS=//Artifacts" -e "SOURCE=//C/Users/Joe Blogs/Documents/GitHub/My.Project" -e "AWS_CONFIGURATION=//C/Users/Joe Blogs/.aws" -e "MOUNT_SOURCE_DIRECTORY=TRUE" -e "INITIATOR=Joe Blogsl" public.ecr.aws/codebuild/local-builds:latest

Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1  | [Container] 2022/07/07 16:24:57 Waiting for agent ping
agent_1  | [Container] 2022/07/07 16:24:58 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2022/07/07 16:24:59 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2022/07/07 16:24:59 CODEBUILD_SRC_DIR=/codebuild/output/src814819326/src
agent_1  | [Container] 2022/07/07 16:24:59 YAML location is /codebuild/output/srcDownload/src/buildspec.yml
agent_1  | [Container] 2022/07/07 16:24:59 Processing environment variables
agent_1  | [Container] 2022/07/07 16:24:59 Decrypting parameter store environment variables
agent_1  | [Container] 2022/07/07 16:24:59 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2022/07/07 16:24:59 Phase context status code: Decrypted Variables Error Message: MissingRegion: could not fin
d region configuration
agent_1  | [Container] 2022/07/07 16:24:59 Runtime error (*clienterr.PhaseContextError: MissingRegion: could not find region configur
ation)

Additional context
Copying the .aws folder to the C; drive and modifying line 154 of the script to the following value allows the container to find the credentials and confirms this bug is related to spaces in the path.

configuration_file_path=$(allOSRealPath "C:/.aws")
@subinataws
Copy link
Contributor

CodeBuild local isn't fully supported on Windows. Resolving this ticket in favor of #328, which tracking similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants