Open axel3rd opened 1 year ago
Workaround: Using Extended Authentication (com.amazonaws:aws-java-sdk-core
as dependency) and overrides AWS_CREDENTIAL_PROFILES_FILE
environment variable is working fine (DefaultAWSCredentialsProviderChain includes ProfileCredentialsProvider where override is possible due to CredentialsEnvVarOverrideLocationProvider).
=> If CI integration provides AWS_SHARED_CREDENTIALS_FILE configuration, this snippet is working fine:
AWS_CREDENTIAL_PROFILES_FILE=$AWS_SHARED_CREDENTIALS_FILE mvn docker:push -Ddocker.plugin.version=0.43.0 -Ddocker.plugin.image=$ECR_URI -X
Description
io.fabric8:docker-maven-plugin could be used on CI pipeline which execute jobs/builds on some AWS EC2, which doesn't belong to your project.
Often, CI integration offers a way (plugin, ...) to provide a "Docker support", to handle the Docker authentication (~
config.json
file withauths
key).This AWS EC2 can have IAM profile (a common one could be at min the SSM profile to be able to "connect" to EC2 via AWS Console for admin), which has no permission(s) for your AWS project account (and ECR push).
In this case (since https://github.com/fabric8io/docker-maven-plugin/issues/1177), the EC2 instance roles is used for ECR authentication, which isn't authorized for your ECR push.
The Docker authentication isn't used, and there isn't a proper way to disable it (skipExtendedAuth doesn't work).
The workaround could be to "enforce" an AWS authentication (
AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
) but you lost "Docker support" facilities provided by CI Docker integration.Request
It would perhaps be preferable that "project Docker Authentication" is used (if exist) before any AWS authentication (EC2 Role, ...) which belong to hostname which execute build.
Otherwise, offer a way to disable it properly (part of
-Ddocker.skip.extendedAuth=true
?).Info
0.29.0
<->0.42.0
mvn -v
) :Docker version 23.0.1, build a5ee5b1
Reproduction (pure command line)
Consider some end-user context and AWS authentication for following 'aws ecr get-login-password' command:
Create a generic & variabilized
pom.xml
for following command line tests:Prepare Docker image tag:
Define Docker authentication (in tmp dir for fresh context usage) and unset any AWS credentials used for 'aws ecr get-login-password' (this part in done by CI Docker integration, here in command line for reproduction):
Validate plugin behavior before AWS role usage (<= 0.28.0):
Proof that AWS role used before Docker authentication (>= 0.29.0):
Proof that currently cannot be skipped: