My docker file needs to connect to aws codeartifact to add a source to Nuget before the rest of the image can be built. As of now everytime the build gets to:
RUN aws codeartifact login --tool dotnet --domain mydomain --domain-owner $account_id --repository myrepo
the docker build fails and prints the error: Could not connect to the endpoint URL: "https://codeartifact.us-east2.amazonaws.com/v1/authorization-token?domain=mydomain&domain-owner=<account_id>".
The first part of my DockerFile is this:
FROM amazon/aws-cli:latest
ARG AWS_DEFAULT_REGION
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_SESSION_TOKEN
RUN echo $AWS_DEFAULT_REGION
RUN echo $AWS_ACCESS_KEY_ID
RUN echo $AWS_SECRET_ACCESS_KEY
RUN echo $AWS_SESSION_TOKEN
WORKDIR /app
RUN aws codeartifact login --tool dotnet --domain mydomain --domain-owner <account_id> --repository myrepo
I pass the build args in through the command line too. I also run docker build with --network=host --build-args etc.
.
Nothing is working. I greatly appreciate any suggestions. Thank you!!
CodePudding user response:
The correct endpoint for code artefact is
codeartifact.us-east-2.amazonaws.com
https://docs.aws.amazon.com/general/latest/gr/codeartifact.html
and the error shows codeartifact.us-east2.amazonaws.com
So seems like the region arg/env is not correct and it -
is missingin the region variable.
Try something
ENV="us-east-2"
RUN aws codeartifact login --tool dotnet --domain mydomain --domain-owner <account_id> --repository myrepo