I am using amazon/aws-cli:2.2.40 in a gitlab pipeline to publish a static site on a S3.
deploy_front:
image: amazon/aws-cli:2.2.40
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
stage: publish
script:
- s3 sync ./front/build s3://some-bucket-name
ends up in
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument command: Invalid choice, valid choices are:
accessanalyzer | acm
acm-pca | alexaforbusiness
amp | amplify
amplifybackend | apigateway
....... ..........
I managed to replicate this error by running docker run -it amazon/aws-cli:2.2.40 aws s3
locally. However docker run -it amazon/aws-cli:2.2.40 s3
works so I do not understand why I get the same error no matter what I use in script
. Is it a some escaping issue?
CodePudding user response:
This is due to the amazon/aws-cli
image's entrypoint being: /usr/local/bin/aws
. When you run aws
by itself locally, it'll return the help message and give a 252 exit code. To override the entrypoint, you do so like this:
test:
stage: test
image:
name: amazon/aws-cli
entrypoint: [""]
script:
- aws s3 help
CodePudding user response:
Sometime i have same error and i try with another image called banst/awscli
. I don't remember why aws image no work in gitlab but i solved with the image mentioned.
Regards