π‘ AWS CLIλ AWS μλΉμ€λ₯Ό κ΄λ¦¬νλ ν΅ν© λꡬμ λλ€.
λꡬ νλλ§ λ€μ΄λ‘λ νμ¬ κ΅¬μ±νλ©΄ μ¬λ¬ AWS μλΉμ€λ₯Ό λͺ λ Ήμ€μμ μ μ΄νκ³ μ€ν¬λ¦½νΈλ‘ μλν ν μ μμ΅λλ€.
AWS CLI λͺ λ Ή νμ νμΈ
λͺ
λ Ήμ΄ μ‘΄μ¬νμ§ μκ±°λ Parameter validation failed
λ¬Έμμμ μ¬μ©ν μ μλ λ§€κ°λ³μ()λ₯Ό μΈμνμ§ λͺ»νλ€λ μ€λ₯λ₯Ό μμ νλ κ²½μ° λͺ
λ Ή νμμ΄ μλͺ»λμ μλ μλ€.
--debug μ΅μ μ μ¬μ©
μ΄ μ΅μ
μ μ¬μ©νλ©΄ CLIκ° λͺ
λ Ήμ μ²λ¦¬νλλ° νμν λͺ¨λ λ¨κ³μ λν μΈλΆ μ 보λ₯Ό μΆλ ₯
ν©λλ€.
μΆλ ₯μ μΈλΆ μ 보λ μ€λ₯κ° λ°μν μμ μ κ²°μ νλ λ° λμμ΄ λ μ μμΌλ©° μ€λ₯κ° μμλ μμΉμ λν λ¨μλ₯Ό μ 곡ν©λλ€.
μ΅μ μ ν¬ν¨νλ©΄ --debug κ°μ μΈλΆ μ λ³΄κ° ν¬ν¨λ©λλ€.
stderr μ§λ¨ μ λ³΄λ§ λ³΄λ΄λ €λ©΄ 2> debug.txtλ₯Ό μΆκ°ν©λλ€. μ¬κΈ°μ debug.txtλ λλ²κ·Έ νμΌμ μ¬μ©ν μ΄λ¦μ λλ€.
$ aws servicename commandname options --debug 2> debug.txt
$ aws s3 cp options --debug 2> debug.txt
μΆλ ₯κ³Ό stderr μ§λ¨ μ 보 λ λ€ λ³΄λ΄λ €λ©΄ &> debug.txtλ₯Ό μΆκ°ν©λλ€. μ¬κΈ°μ debug.txtλ λλ²κ·Έ νμΌμ μ¬μ©ν μ΄λ¦μ λλ€.
$ aws servicename commandname options --debug &> debug.txt
$ aws s3 cp options --debug &> debug.txt
λ€μμΒ --debugμ΅μ
μ Profileμ λν΄μ μ¬μ©ν λμ μ¬μ©νμ§ μμ λμ λͺ
λ Ή μ€νμ μμ
λλ€.
aws configure --profile [ProfileName] #κ·Έλ° λ€μ μ¬μ©μ Access Keyλ Secret Key μ€μ
- μ¬μ© X
```bash
$ aws iam list-groups --profile [ProfileName]
{
"Groups": [
{
"Path": "/",
"GroupName": "MyTestGroup",
"GroupId": "AGPA0123456789EXAMPLE",
"Arn": "arn:aws:iam::123456789012:group/MyTestGroup",
"CreateDate": "2019-08-12T19:34:04Z"
}
]
}
$ aws iam list-groups --profile [ProfileName] --debug
2019-08-12 12:36:18,305 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.16.215 Python/3.7.3 Linux/4.14.133-113.105.amzn2.x86_64 botocore/1.12.205
2019-08-12 12:36:18,305 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['iam', 'list-groups', '--debug']
2019-08-12 12:36:18,305 - Main2019-08-12 12:36:18,320 - MainThread - botocore.load2019-08-12 12:36:18,326 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.iam.list-groups: calling handler <function add_generate_skeleton at 0x7fdf1737eae8>
.
.
.
2019-08-12 12:36:18,343 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
POST
/
content-type:application/x-www-form-urlencoded; charset=utf-8
host:iam.amazonaws.com
x-amz-date:20190812T193618Z
content-type;host;x-amz-date
5f776d91EXAMPLE9b8cb5eb5d6d4a787a33ae41c8cd6eEXAMPLEca69080e1e1f
2019-08-12 12:36:18,344 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20190812T193618Z
20190812/us-east-1/iam/aws4_request
ab7e367eEXAMPLE2769f178ea509978cf8bfa054874b3EXAMPLE8d043fab6cc9
2019-08-12 12:36:18,344 - MainThread - botocore.auth - DEBUG - Signature:
d85a0EXAMPLEb40164f2f539cdc76d4f294fe822EXAMPLE18ad1ddf58a1a3ce7
b'<ListGroupsResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">\n <ListGroupsResult>\n <IsTruncated>false</IsTruncated>\n <Groups>\n <member>\n <Path>/</Path>\n <GroupName>MyTestGroup</GroupName>\n <Arn>arn:aws:iam::123456789012:group/MyTestGroup</Arn>\n <GroupId>AGPA1234567890EXAMPLE</GroupId>\n <CreateDate>2019-08-12T19:34:04Z</CreateDate>\n </member>\n </Groups>\n </ListGroupsResult>\n <ResponseMetadata>\n <RequestId>74c11606-bd38-11e9-9c82-559da0adb349</RequestId>\n </ResponseMetadata>\n</ListGroupsResponse>\n'
2019-08-12 12:36:18,665 - MainThread - botocore.hooks - DEBUG - Event needs-retry.iam.ListGroups: calling handler <botocore.retryhandler.RetryHandler object at 0x7fdf16e9a780>
2019-08-12 12:36:18,665 - MainThread - botocore.retryhandler - DEBUG - No retry needed.
2019-08-12 12:36:18,665 - MainThread - botocore.hooks - DEBUG - Event after-call.iam.ListGroups: calling handler <function json_decode_policies at 0x7fdf189b1d90>
{
"Groups": [
{
"Path": "/",
"GroupName": "MyTestGroup",
"GroupId": "AGPA123456789012EXAMPLE",
"Arn": "arn:aws:iam::123456789012:group/MyTestGroup",
"CreateDate": "2019-08-12T19:34:04Z"
}
]
}
cli_history νμΌ μ€μ μ μ¬μ©νμ¬ AWS CLI λͺ λ Ή κΈ°λ‘ λ‘κ·Έλ₯Ό νμ±ν ν μ μμ΅λλ€. μ΄ μ€μ μ νμ±ννλ©΄ AWS CLIκ° awsλͺ λ Ή κΈ°λ‘μ κΈ°λ‘ν©λλ€.
$ aws configure set cli_history enabled
μ΅μ μ ν¬ν¨νλ©΄ βdebugκ°μ μΈλΆ μ λ³΄κ° ν¬ν¨λ©λλ€.
π μ΄ μ 보λ₯Ό μ¬μ©νμ¬ λ§€κ°λ³μ λ°μ΄ν° λ° API νΈμΆμ΄ μμλλ‘ μλνλμ§ νμΈν λ€μ λͺ λ Ήμ΄ μ€ν¨νλ νλ‘μΈμ€ λ¨κ³λ₯Ό μΆλ‘ ν μ μμ΅λλ€.
μ΄ μ€λ₯λ μ΄μ 체μ κ° AWS CLI λͺ
λ Ήμ μ°Ύμ μ μμμ μλ―Έ
ν©λλ€. μ€μΉκ° λΆμμ νκ±°λ μ
λ°μ΄νΈκ° νμν μν©μΌ μ μμ΅λλ€.
κ°λ₯ν μμΈ(1): μ€μΉλ λ²μ λ³΄λ€ μ΅μ AWS CLI κΈ°λ₯μ μ¬μ©νλ €κ³ νκ±°λ νμμ΄ μλͺ»λμμ΅λλ€.
μμ μ€λ₯ ν μ€νΈ:
$ aws s3 copy
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: argument subcommand: Invalid choice, valid choices are:
ls | website
cp | mv
....
λͺ λ Ή νμμ΄ μλͺ»λμκ±°λ κΈ°λ₯μ΄ λ¦΄λ¦¬μ€λκΈ° μ μ μ΄μ λ²μ μ μ¬μ© μ€μΈ κ²½μ° λ€μν μ€λ₯κ° λ°μν μ μμ΅λλ€.
κ°λ₯ν μμΈ(2): μ€μΉ ν ν°λ―Έλμ λ€μ μμν΄μΌ ν©λλ€.
μμ μ€λ₯ ν μ€νΈ:
$ aws --version
command not found: aws
AWS CLIλ₯Ό μ²μ μ€μΉνκ±°λ μ λ°μ΄νΈ ν ν λͺ λ Ήμ μ°Ύμ μ μλ κ²½μ° awsμ λ°μ΄νΈλ₯Ό μΈμνλλ‘ ν°λ―Έλμ λ€μ μμν΄μΌ ν μ μμ΅λλ€.
κ°λ₯ν μμΈ(3): AWS CLIμ κΆνμ΄ μμ΅λλ€(Linux)
ν΄κ²° λ°©λ²
$ sudo chmod -R 755 /usr/local/aws-cli/
κ°λ₯ν μμΈ(4):Β PATH
μ€μΉ μ€μ μ΄μ 체μ κ° μ
λ°μ΄νΈλμ§ μμμ΅λλ€ .
$ aws --version
command not found: aws
PATH
νκ²½ λ³μμ μΆκ°ν΄μΌ ν μ μμ΅λλ€.μ¬μ©μ λλ ν°λ¦¬μμ μ Έμ νλ‘νμΌ μ€ν¬λ¦½νΈλ₯Ό μ°Ύμ΅λλ€. μ΄λ€ μ Έμ κ°μ§κ³ μλμ§ λͺ¨λ₯΄λ κ²½μ° echo $SHELL μ μ€νν©λλ€.
$ ls -a ~
. .. .bash_logout .bash_profile .bashrc Desktop Documents Downloads
λ΄λ³΄λ΄κΈ° λͺ λ Ήμ νλ‘ν μ€ν¬λ¦½νΈμ μΆκ° νμΈμ. λ€μ λͺ λ Ήμ νμ¬ PATHλ³μμ λ‘컬 binμ μΆκ°ν©λλ€.
export PATH=/usr/local/bin:$PATH
νμ¬ μΈμ μ μ λ°μ΄νΈλ νλ‘νμΌμ λ€μ λ‘λν©λλ€.
source ~/.bash_profile
βAWS βversionβ
λͺ
λ Ήμ΄ μ€μΉν λ²μ κ³Ό λ€λ₯Έ λ²μ μ λ°νν¨
ν°λ―Έλμ΄ AWS CLIμ λν΄ μμκ³Ό λ€λ₯Έ PATH
λ₯Ό λ°νν μ μμ΅λλ€.
κ°λ₯ν ν΄κ²°λ°©μ: μ€μΉ ν ν°λ―Έλμ λ€μ μμν΄μΌ ν¨
awsλͺ
λ Ήμ μλͺ»λ λ²μ μ΄ νμλλ κ²½μ°Β PATH
μ
λ°μ΄νΈλ₯Ό μΈμνλλ‘ ν°λ―Έλμ μ¬μμν΄μΌ μΈμν μ μμ΅λλ€.
κ°λ₯ν μμΈ: μ¬λ¬ λ²μ μ AWS CLIκ° μμ
AWS CLIλ₯Ό μ
λ°μ΄νΈνλ©΄μ κΈ°μ‘΄ μ€μΉμ λ€λ₯Έ μ€μΉ λ°©λ²μ μ¬μ©ν κ²½μ° μ¬λ¬ λ²μ μ΄ μ€μΉλ μ μμ΅λλ€.
μλ₯Ό λ€μ΄ Linux λλ macOSμμ νμ¬ μ€μΉμ pipλ₯Ό μ¬μ©νμ§λ§ .pkg μ€μΉ νμΌμ μ¬μ©νμ¬ μ
λ°μ΄νΈλ₯Ό μλν κ²½μ° νΉν μ΄μ λ²μ μ κ°λ¦¬ν€λ PATHμ μΆ©λμ΄ λ°μν μ μμ΅λλ€.
π‘ μ΄ λ¬Έμ λ₯Ό ν΄κ²°νλ €λ©΄ λͺ¨λ λ²μ μ CLIλ₯Ό μ κ±° ν μλ‘ μ€μΉλ₯Ό μνν©λλ€.
AWS CLIλ₯Ό μ κ±°ν ν βaws --versionβ λͺ λ Ήμ΄ λ²μ μ λ°νν¨
μ΄λ λκ° μμ€ν μ΄λκ°μ AWS CLIκ° μμ§ μ€μΉλμ΄ μλ κ²½μ° λ°μν©λλ€.
κ°λ₯ν μμΈ: μ κ±° ν ν°λ―Έλμ λ€μ μμν΄μΌ ν¨
aws --versionλͺ λ Ήμ΄ μ¬μ ν μλνλ κ²½μ° ν°λ―Έλ μ λ°μ΄νΈλ₯Ό μΈμνλλ‘ ν°λ―Έλμ λ€μ μμν΄μΌ ν μ μμ΅λλ€.
κ°λ₯ν μμΈ: μμ€ν μ μ¬λ¬ λ²μ μ AWS CLIκ° μκ±°λ μλ AWS CLIλ₯Ό μ€μΉνλ λ° μ¬μ©ν κ²κ³Ό λμΌν μ κ±° λ°©λ²μ μ¬μ©νμ§ μμ
CLIλ₯Ό μ€μΉνλλ° μ¬μ©ν κ²κ³Ό λ€λ₯Έ λ°©λ²μ μ¬μ©νμ¬ μ κ±°νκ±°λ μ¬λ¬ λ²μ μ μ€μΉν κ²½μ° CLIκ° μ¬λ°λ₯΄κ² μ κ±°λμ§ μμ μ μμ΅λλ€. μ΄ λ¬Έμ λ₯Ό ν΄κ²°νλ €λ©΄ μ€μΉμ μ¬μ©ν κ²κ³Ό λμΌν λ°©λ²μ μ¬μ©νμ¬ AWS CLIλ₯Ό μ κ±°ν©λλ€.
$ aws --version
command not found: aws
π‘ μΆλ ₯μ μ¬μ ν λ²μ μ΄ λμ΄λμ΄ μλ κ²½μ° AWS CLIκ° λ€λ₯Έ λ°©λ²μ μ¬μ©νμ¬ μ€μΉλμκ±°λ μ¬λ¬ λ²μ μ΄ μμ κ°λ₯μ±μ΄ ν½λλ€. AWS CLIλ₯Ό μ€μΉνλλ° μ¬μ©ν λ°©λ²μ λͺ¨λ₯΄λ κ²½μ° λ²μ μΆλ ₯μ΄ νμλμ§ μμ λκΉμ§ μ΄μ 체μ μ ν΄λΉνλ CLIλ²μ 1, λ²μ 2μ κ° μ κ±° λ°©λ² μ§μΉ¨μ λ°λ¦ λλ€.
κ°λ₯ν μμΈ: AWS CLI νλ‘κ·Έλ¨ νμΌμ 'μ€ν' κΆνμ΄ μμ
μ¬μ©μμ λν μ€ν κΆνμ μΆκ°νλ €λ©΄ λ€μ λͺ
λ Ήμ μ€νν©λλ€. μ΄λ /bin/aws
λ₯Ό μ¬μ©μ μ»΄ν¨ν°μ νλ‘κ·Έλ¨ κ²½λ‘λ‘ λ°κΎΈμμμ€.
$ chmod +x /bin/aws
κ°λ₯ν μμΈ: IAM μ격 μ¦λͺ
μ μμ
μ μνν μ μλ κΆνμ΄ μμ
μ€λ₯ ν μ€νΈ μ:
$ aws s3 ls
An error occurred (AcessDenied) when calling the ListBuckets operation: Access denied.
κ°λ₯ν μμΈ: CLIκ° μλͺ»λ 보μ μΈμ¦ μ 보 λλ μμκ³Ό λ€λ₯Έ μμΉμ 보μ μΈμ¦ μ 보λ₯Ό μ½μ΅λλ€.
AWS CLIκ° μμκ³Ό λ€λ₯Έ μμΉμμ 보μ μΈμ¦ μ 보λ₯Ό μ½κ³ μκ±°λ ν€ νμ΄ μ λ³΄κ° μ¬λ°λ₯΄μ§ μμ μ μμ΅λλ€. aws configure list
λ₯Ό μ€ννμ¬ μ΄λ€ μ격 μ¦λͺ
μ μ¬μ©νκ³ μλμ§ νμΈν μ μμ΅λλ€.
μ격 μ¦λͺ νμΈλ°©λ² μμ
κΈ°λ³Έ νλ‘νμΌμ μ¬μ©λ μ격 μ¦λͺ μ νμΈνλ λ°©λ²
$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************XYVA shared-credentials-file
secret_key ****************ZAGY shared-credentials-file
region us-west-2 config-file ~/.aws/config
π‘ ν€ νμ΄ μΈλΆ μ 보λ₯Ό νμΈνλ €λ©΄Β
config
λ°Βcredentials
νμΌμ κ²ν ν©λλ€.
λͺ λͺ λ νλ‘νμΌμ μ격 μ¦λͺ μ νμΈνλ λ°©λ²
$ aws configure list --profile [ProfileName]
Name Value Type Location
---- ----- ---- --------
profile saanvi manual --profile
access_key **************** shared-credentials-file
secret_key **************** shared-credentials-file
region us-west-2 config-file ~/.aws/config
μμ νκΈ° - https://junhyeong-jang.tistory.com/27
κ°λ₯ν μμΈ: μ»΄ν¨ν°μ ν΄λ‘μ΄ λκΈ°νλμ§ μμ
μ ν¨ν 보μ μΈμ¦ μ 보λ₯Ό μ¬μ© μ€μ΄λΌλ©΄ ν΄λ‘μ΄ λκΈ°ν λμ§ μμμ μ μμ΅λλ€. Linux of macOSμμ date
λ₯Ό μ€ννμ¬ μκ°μ νμΈν©λλ€.
$ date
λͺ λΆ μμ μμ€ν ν΄λ‘μ΄ μ ννμ§ μμΌλ©΄ ntpdλ₯Ό μ¬μ©νμ¬ λκΈ°νν¨.
π‘ Windowsμμλ μ μ΄νμ λ μ§ λ° μκ° μ΅μ μ μ¬μ©νμ¬ μμ€ν ν΄λ‘μ ꡬμ±νλ€.
μ€λ₯ ν μ€νΈ μ:
$ aws s3 ls
An error occurred (SignatureDoesNotMatch) when calling the ListBuckets operation: The request signature we
calculated does not match the signature you provided. Check your key and signing method.
CLIμμ λͺ
λ Ήμ μ€ννλ©΄ μνΈνλ μμ²μ μλ²μ λ³΄λ΄ μ μ ν μλΉμ€ μμ
μ μνν©λλ€.
μ격 μ¦λͺ
μ΄ μνΈνμ ν¬ν¨λλ©° μ격 μ¦λͺ
μ ν΅ν΄ AWSμμ μμ²νλ μ¬λμ μΈμ¦ν μ μμ΅λλ€.
κ°λ₯ν μμΈ: ν΄λ‘μ΄ AWS μλ²μ λκΈ°νλμ§ μμ
μ¬μ 곡격μΌλ‘λΆν° 보νΈνκΈ° μν΄ μνΈν/μνΈ ν΄λ νλ‘μΈμ€ λμ νμ¬ μκ°μ΄ μ¬μ©λ μ μμ΅λλ€.
ν΄λΌμ΄μΈνΈ λ° μλ²μ μκ°μ΄ νμ©λ μκ°μ λλ κ²½μ° νλ‘μΈμ€κ° μ€ν¨ν μ μκ³ μμ²μ΄ κ±°λΆλλ€.
π‘ μ¬μ곡격μ΄λ? Replay AttackμΌλ‘ μ ν¨ν λ°μ΄ν° μ μ‘μ΄ μ μμ μΌλ‘ λλ λΆμ νκ² λ°λ³΅λκ±°λ μ§μ°λλ λ€νΈμν¬ κ³΅κ²©μ ν ννμ λλ€.
κ°λ₯ν μμΈ: μ΄μ 체μ μμ νΉμ νΉμ λ¬Έμκ° ν¬ν¨λ AWS 보μ ν€λ₯Ό μλͺ» μ²λ¦¬νκ³ μμ
π‘ λ¬Έμ λ₯Ό μΌμΌν€λ νΉμ λ¬Έμκ° ν¬ν¨λμ§ μλ λΉλ° ν€λ₯Ό μ»μΌλ €λ©΄ λΉλ° ν€λ₯Ό λ€μ μμ±νλ κ²μ΄ μ’μ΅λλ€
κ°λ₯ν μμΈ: AWS CLIκ° νλ‘μ μΈμ¦μλ₯Ό μ λ’°νμ§ μμ
μ€λ₯ ν μ€νΈ μ:
$ aws s3 ls
[SSL: CERTIFICATE_ VERIFY_FAILED] certificate verify failed
π‘ AWS CLI λͺ λ Ήμ μ¬μ©νλ©΄Β [SSL: CERTIFICATE_ VERIFY_FAILED] certificate verify failed μ€λ₯ λ©μμ§λ₯Ό λ°κ² λ©λλ€. μ΄λ μ¬μ©μμ νλ‘μ μΈμ¦μκ° μ체 μλͺ λκ³ νμ¬κ° μΈμ¦ κΈ°κ΄(CA)λ‘ μ€μ λ κ²κ³Ό κ°μ μμΈμΌλ‘ μΈν΄ AWS CLIκ° νλ‘μμ μΈμ¦μλ₯Ό μ λ’°νμ§ μκΈ° λλ¬Έμ λ°μν©λλ€.
κ°λ₯ν μμΈ: ꡬμ±μ΄ μ¬λ°λ₯Έ CA λ£¨νΈ μΈμ¦μ μμΉλ₯Ό κ°λ¦¬ν€μ§ μμ
μ€λ₯ ν μ€νΈ μ:
$ aws s3 ls
SSL validation failed for regionname [Errno 2] No such file or directory
π‘ μ΄κ²μ AWS CLIμμ μΈμ¦κΈ°κ΄(CA) λ²λ€ νμΌ μμΉκ° μλͺ» ꡬμ±λμκΈ° λλ¬Έμ λ°μν©λλ€. μ΄ λ¬Έμ λ₯Ό ν΄κ²°νλ €λ©΄ νμ¬ .pem νμΌμ μμΉλ₯Ό νμΈνκ³ ca_bundle κ΅¬μ± νμΌ μ€μ , --ca-bundle λͺ λ Ήμ€ μ΅μ λλ AWS_CA_BUNDLE νκ²½ λ³μλ₯Ό μ¬μ©νμ¬ AWS CLI ꡬμ±μ μ λ°μ΄νΈν©λλ€.
python 3.10μ CLIμμ μ§μνμ§ μμ΅λλ€.