JSCODE Logo
블로그후기멘토진
회사명 : JSCODE대표 : 박재성사업자 등록번호 : 244-22-01557통신판매업 : 제 2023-인천미추홀-0381 호
학원 명칭 : 제이에스코드(JSCODE)원격학원학원설립ㆍ운영 등록번호 : 제6063호

서울특별시 구로구 경인로 20가길 11(오류동, 아델리아)

Copyright ⓒ 2025 JSCODE - 최상위 현업 개발자들의 프로그래밍 교육 All rights reserved.

이용약관개인정보처리방침
← 블로그 목록으로 돌아가기

[실습] AWS CLI로 S3 파일 동기화하기

JSCODE 시니
JSCODE 시니
2026. 04. 09.
author
JSCODE 시니
category
Jenkins CI/CD
createdAt
Apr 9, 2026 12:57 PM
isPublic
isPublic
series
Jenkins를 활용한 CI/CD 입문 (with.AWS)
slug
syncing-s3-files-using-aws-cli
type
post
updatedAt

✅ 1. AWS CLI로 S3 파일 동기화 하기

  • 우리는 현재 index.html 파일만을 S3에 업로드하고 있지만, 실제로는 빌드의 결과물인 build 폴더를 S3에 업로드해야 배포를 진행할 수 있다.
  • 배포를 진행할 때마다, 버킷을 비워야 하고 새로운 파일을 버킷에 추가해야 한다.
  • 이 작업을 보다 쉽게 수행하기 위해 AWS CLI가 제공하는 S3 sync 기능을 사용해보자
sync — AWS CLI 2.34.16 Command Reference
Use the AWS CLI 2.34.16 to run the s3 sync command.
sync — AWS CLI 2.34.16 Command Reference
https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
notion image
  • 해당 구문을 사용하면 내 폴더와 S3 간의 싱크(동기화)를 맞출 수 있다.
stage('Build') { agent { docker { image 'mcr.microsoft.com/playwright:v1.39.0-jammy' reuseNode true } } steps { sh ''' echo '빌드 시작..' node --version npm --version npm ci npm run build ''' } } stage('AWS') { agent { docker { image 'amazon/aws-cli' reuseNode true args "--entrypoint=''" } } environment { AWS_S3_BUCKET = '본인 버킷명' } steps { withCredentials([usernamePassword(credentialsId: 'my-aws', passwordVariable: 'AWS_SECRET_ACCESS_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) { sh ''' aws --version aws s3 sync build s3://$AWS_S3_BUCKET ''' } } }
  • sync는 빌드 이후에 이루어져야 하기 때문에 AWS 스테이지를 반드시 Build 이후로 이동시킨다.
  • 또한 build의 결과물을 가지고 sync를 수행해야 하기 때문에, 같은 노드를 사용해야 한다.
  • 따라서 반드시 build와 AWS 단계 모두 reuseNode true 값을 기입해 주어야 한다.
notion image
  • 새로고침 후에 확인해보면 해당 페이지가 잘 배포된 것을 확인할 수 있다.
author
category
Jenkins CI/CD
createdAt
Apr 9, 2026 01:25 PM
isPublic
isPublic
series
Jenkins를 활용한 CI/CD 입문 (with.AWS)
slug
type
series-footer
updatedAt
📎
이 글은 Jenkins를 활용한 CI/CD 입문 (with.AWS) 강의의 수업 자료 중 일부입니다.