JUST DO IT!

AWS CLI - TIL230518 ๋ณธ๋ฌธ

TIL

AWS CLI - TIL230518

sunhokimDev 2023. 5. 19. 15:25

๐Ÿ“š KDT WEEK 7 DAY 4 TIL

  • AWS CLI

๐ŸŸฅ AWS CLI

AWS ์„œ๋น„์Šค๋ฅผ ํ„ฐ๋ฏธ๋„์—์„œ๋„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋น„์Šค์ด๋‹ค.

pip install awscli

๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ AWS CLI๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

 

AWS CLI๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” user ์ •๋ณด๊ฐ€ ํ•„์š”ํ•˜๋ฏ€๋กœ IAM๋ฅผ ์จ์„œ ํ…Œ์ŠคํŠธ ์‚ฌ์šฉ์ž๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์—ˆ๋‹ค.

 

์‚ฌ์šฉ์ž๊ฐ€ ๋งŒ๋“ค์–ด์ง€๋ฉด ์•ก์„ธ์Šค ํ‚ค, ๋น„๋ฐ€ ์•ก์„ธ์Šค ํ‚ค๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

์•ก์„ธ์Šค ๋ฐ ๋น„๋ฐ€ ์—‘์„ธ์Šค ํ‚ค๊ฐ€ CLI ์œ ์ € ์„ค์ •์— ํ•„์š”ํ•œ ๋‚ด์šฉ์ด๋‹ค.

 

์ด์ œ ํ„ฐ๋ฏธ๋„์—์„œ aws configure ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ๋ฐ›์•˜๋˜ ํ‚ค๋ฅผ ์ž…๋ ฅํ•ด์ค€๋‹ค.

 

ํ•ด๋‹น ํ‚ค๋“ค์„ ์ด์šฉํ•˜์—ฌ ์œ ์ €๋ฅผ ๋“ฑ๋กํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ S3๋ฅผ ์ฝ์–ด์˜ค๋ ค๋ฉด aws s3 ls ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋˜์ง€๋งŒ,

๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ฌ์šฉ์ž๋Š” ๊ถŒํ•œ์ด ์—†์œผ๋ฉด ์•„๋ฌด๊ฒƒ๋„ ํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ S3์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

 

์•„๊นŒ ์‚ฌ์šฉ์ž์—๊ฒŒ AWS์˜ ๊ถŒํ•œ ์ค‘ S3ReadOnlyAccess ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์—ˆ๋‹ค.

 

S3 ๊ถŒํ•œ์ด ์—†์–ด ๊ฑฐ์ ˆ๋‹นํ–ˆ๋‹ค๊ฐ€, ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ•˜๋‹ˆ ์ œ๋Œ€๋กœ ์ฝ์–ด์˜ค๋Š” ๋ชจ์Šต

ReadOnlyAccess ๋ฟ๋งŒ์•„๋‹ˆ๋ผ FullAccess ๊ถŒํ•œ์„ ์ค€๋‹ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์–ด๋กœ S3 ๋ฒ„ํ‚ท์„ ๋งŒ๋“ค์ˆ˜๋„์žˆ๋‹ค.

  • aws s3 mb s3://๋ฒ„ํ‚ท์ด๋ฆ„ : S3 ์ƒˆ ๋ฒ„ํ‚ท ์ƒ์„ฑ
  • aws s3 sync . s3://๋ฒ„ํ‚ท์ด๋ฆ„ : ํ˜„์žฌ ํด๋”์˜ ๋ชจ๋“  ๋‚ด์šฉ์„ ํ•ด๋‹น ๋ฒ„ํ‚ท์— ์ ์žฌ
  • aws s3 rm s3://๋ฒ„ํ‚ท์ด๋ฆ„ --recursive : ํ•ด๋‹น ๋ฒ„ํ‚ท์˜ ๋‚ด์šฉ์„ ํ•˜์œ„ ํด๋”๊นŒ์ง€(--์˜ต์…˜) ๋ชจ๋‘ ์‚ญ์ œ

S3์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋‹ค๋ฅธ ์„œ๋น„์Šค๋“ค๋„ CLI๋กœ ์ œ์–ด๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.

๋‹ค๋ฅธ ์„œ๋น„์Šค ์ง€์›๊ณผ ๋ช…๋ น์–ด๋Š” ์•„๋ž˜ ๋งํฌ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-services.html

 

Using the AWS CLI to work with AWS Services - AWS Command Line Interface

Thanks for letting us know this page needs work. We're sorry we let you down. If you've got a moment, please tell us how we can make the documentation better.

docs.aws.amazon.com

 


์ข…ํ•ฉ ์‹ค์Šต์€ TIL230517์— ํ•ฉ์ณ์„œ ๊ธฐ๋ก