## ElasticBeanstalk CLI 명령어
https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/
elasticbeanstalk — AWS CLI 1.22.64 Command Reference
Note: You are viewing the documentation for an older major version of the AWS CLI (version 1). AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. F
docs.aws.amazon.com
## S3 로 파일 업로드 성공
## cars-api-v26.jar --> ElasticBeanstalk 으로 배포 실패
## .gitlab-ci.yml (오류발생)
- 새로운 애플리케이션 버전 생성
- 환경 업데이트
variables:
ARTIFACT_NAME: cars-api-v$CI_PIPELINE_IID.jar
APP_NAME: cars-api
stages:
- build
- test
- deploy
build:
stage: build
image: openjdk:12-alpine
script:
- ./gradlew build
- mv ./build/libs/cars-api.jar ./build/libs/$ARTIFACT_NAME
artifacts:
paths:
- ./build/libs/
smoke test:
stage: test
image: openjdk:12-alpine
before_script:
- apk --no-cache add curl
script:
- java -jar ./build/libs/$ARTIFACT_NAME &
- sleep 30
- curl http://localhost:5000/actuator/health | grep "UP"
deploy:
stage: deploy
image:
name: amazon/aws-cli
entrypoint: [""]
script:
- aws configure set region ap-northeast-2
- aws s3 cp ./build/libs/$ARTIFACT_NAME s3://$S3_BUCKET/$ARTIFACT_NAME
- aws elasticbeanstalk create-application-version --application-name $APP_NAME --version-label $CI_PIPELINE_IID --source-bundle S3Bucket=$S3_BUCKET,S3Key=$ARTIFACT_NAME
- aws elasticbeanstalk update-environment --application-name $APP_NAME --environment-name "production" --version-label=$CI_PIPELINE_IID
## .gitlab-ci.yml (오류해결) 및 IAM 권한 추가 필요
variables:
ARTIFACT_NAME: cars-api-v$CI_PIPELINE_IID.jar
APP_NAME: cars-api
stages:
- build
- test
- deploy
build:
stage: build
image: openjdk:12-alpine
script:
- ./gradlew build
- mv ./build/libs/cars-api.jar ./build/libs/$ARTIFACT_NAME
artifacts:
paths:
- ./build/libs/
smoke test:
stage: test
image: openjdk:12-alpine
before_script:
- apk --no-cache add curl
script:
- java -jar ./build/libs/$ARTIFACT_NAME &
- sleep 30
- curl http://localhost:5000/actuator/health | grep "UP"
deploy:
stage: deploy
image:
name: amazon/aws-cli
entrypoint: [""]
script:
- aws configure set region ap-northeast-2
- aws s3 cp ./build/libs/$ARTIFACT_NAME s3://$S3_BUCKET/$ARTIFACT_NAME
- aws elasticbeanstalk create-application-version --application-name $APP_NAME --version-label $CI_PIPELINE_IID --source-bundle S3Bucket=$S3_BUCKET,S3Key=$ARTIFACT_NAME
- aws elasticbeanstalk update-environment --application-name $APP_NAME --environment-name Carsapi-env --version-label $CI_PIPELINE_IID
=======================================
'[AWS] > GITLAB' 카테고리의 다른 글
sed 명령어 (0) | 2022.03.02 |
---|---|
65장. Assignment solution (오류 해결) (0) | 2022.03.02 |
62장. GitLab CI에서 AWS S3로 파일을 업로드하는 방법 (0) | 2022.03.01 |
[AWS] GitLab CICD Pipelines with AWS EC2 and S3 (0) | 2022.02.28 |
61장. GitLab 그룹 설정 (0) | 2022.02.24 |
댓글