i’rying to create a pipeline in gitlab to deploy my app to elastic beanstalk but got An error occurred (InvalidParameterCombination) when calling the CreateApplicationVersion operation: Unable to download from S3 location. Reason: Bad Request. anyone know how to fix this?
gitlab.ci.yml
stages:
- build
- package
- test
- deploy
variables:
APP_VERSION: $CI_PIPELINE_IID
build website:
stage: build
image: node:20-alpine
script:
- yarn install
- yarn build
- echo $APP_VERSION > dist/version.html
artifacts:
paths:
- dist
build docker image:
stage: package
image: docker:26.1.2
services:
- docker:26.1.2-dind
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build -t $CI_REGISTRY_IMAGE -t $CI_REGISTRY_IMAGE:$APP_VERSION .
- docker image ls
- docker push --all-tags $CI_REGISTRY_IMAGE
test docker image:
stage: test
image: curlimages/curl
services:
- name: $CI_REGISTRY_IMAGE:$APP_VERSION
alias: website
script:
- curl http://website/version.html | grep $APP_VERSION
deploy production:
stage: deploy
variables:
APP_NAME: clean-city-dashboard
APP_ENV_NAME: clean-city-dashboard-env
environment: production
image:
name: amazon/aws-cli:2.15.38
entrypoint: [""]
script:
- aws --version
- yum install -y gettext
- export DEPLOY_TOKEN=$(echo $GITLAB_DEPLOY_TOKEN | tr -d "n" | base64)
- envsubst < config/Dockerrun.aws.json > Dockerrun.aws.json
- envsubst < config/auth.json > auth.json
- cat Dockerrun.aws.json
- cat auth.json
- aws s3 cp Dockerrun.aws.json s3://$AWS_S3_BUCKET/Dockerrun.aws.json
- aws s3 cp auth.json s3://$AWS_S3_BUCKET/auth.json
- aws elasticbeanstalk create-application-version --application-name "$APP_NAME" --version-label $APP_VERSION --source-bundle S3Bucket=$AWS_S3_BUCKET,S3Key=Dockerrun.aws.json
- aws elasticbeanstalk update-environment --application-name "$APP_NAME" --version-label $APP_VERSION --environment-name $APP_ENV_NAME
Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "$CI_REGISTRY_IMAGE:$APP_VERSION"
},
"Authentication": {
"Bucket": "$AWS_S3_BUCKET",
"Key": "auth.json"
},
"Ports": [
{
"ContainerPort": 80
}
]
}
auth.json
{
"auths": {
"$CI_REGISTRY": {
"auth": "$DEPLOY_TOKEN"
}
}
}