S3에 명령어로 배포하기

jiji·2023년 10월 18일

AWS

목록 보기
5/6
post-thumbnail

AWS Command Line Interface

1. 설치

https://aws.amazon.com/ko/cli/

  • windows 64비트 설치

  • 설치 후 터미널 재실행

C:\Users\user>aws
		↓
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: the following arguments are required: command

2. 리액트를 배포할 계정으로 로그인

> aws configure --profile 계정명
> AWS Access Key ID [None]:
> AWS Secret Access Key ID [None]:
> Default region name [None]: s3가 있는 리전의 이름(서울,  ap-northeast-2)
> Default output format [None]: json

3. 명령어로 업로드하기

  1. 배포할 리액트 앱이 있는 프로젝트 열기
  2. 터미널에스 프로젝트가 있는 디렉토리로 이동
  3. 새로 react 앱 빌드하기
    > npm run build
  4. aws의 s3에 연결, 빌드폴더 안에 s3 버킷에 이 계정의 권한으로 넣겠다.
    > aws s3 sync ./build s3:// (업로드 할 버킷의 이름) --profile= (사용장 계정명)

3-2. 긴 명령어 줄이는 방법

package.json -> "scripts" : 긴 단어를 하나로 표현할 수 있음

"scripts": {
  	...,
	"deploy" : 위 명령어 입력
}
  • 명령어 입력 방법
> npm run build
> npm run deploy

0개의 댓글