목차
1. AWS 콘솔
2. AWS CLI
•
AWS 서비스를 명령어로 조작할 수 있게 해주는 통합 툴
설치 및 확인
1) 설치
2) 설치 확인
c:\\>aws --version
aws-cli/1.22.43 Python/3.6.0 Windows/10 botocore/1.23.43
Shell
복사
CLI1에서 CLI2로 변경하기
[ec2-user@ip-172-31-7-61 bin]$ sudo yum remove awscli
[ec2-user@ip-172-31-7-61 bin]$ sudo curl "<https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip>" -o "awscliv2.zip"
[ec2-user@ip-172-31-7-61 bin]$ sudo unzip awscliv2.zip
[ec2-user@ip-172-31-7-61 bin]$ sudo ./aws/install
Shell
복사
CLI로 AWS 계정 접속
c:\\>aws configure
AWS Access Key ID [None]: ---
AWS Secret Access Key [None]: ---
Default region name [None]: ap-northeast-2
Default output format [None]: json
Shell
복사
여러 계정 관리(계정 profile 설정 및 확인)
# profile 설정
C:\\Users\\llhb3>aws configure --profile test01
AWS Access Key ID [None]: ---
AWS Secret Access Key [None]: ---
Default region name [None]: ap-northeast-2
Default output format [None]: text
# 현재 사용하고 있는 profile 확인
C:\\Users\\llhb3>aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************SZGR shared-credentials-file
secret_key ****************Xeyk shared-credentials-file
region ap-northeast-2 config-file ~/.aws/config
# profile 지정하여 명령어 사용
C:\\Users\\llhb3>aws ec2 describe-security-groups --profile test01
SECURITYGROUPS launch-wizard-3 created 2022-01-27T00:07:39.523+09:00 sg-05ca4
bc31562d5fe6 launch-wizard-3 268179759224 vpc-0e2424100f3f8cb0e
IPPERMISSIONS 22 tcp 22
IPRANGES 0.0.0.0/0
IPPERMISSIONSEGRESS -1
IPRANGES 0.0.0.0/0
Shell
복사
설정파일 저장소
•
Config 파일 및 Credentials 파일은 사용자 폴더 내부에 있는 .aws 폴더에 저장
# config 파일
[default]
region = ap-northeast-2
output = json
[profile test01]
region = ap-northeast-2
output = text
# credentials 파일
[default]
aws_access_key_id = ---
aws_secret_access_key = ---
[test01]
aws_access_key_id = ---
aws_secret_access_key = ---
Shell
복사
리소스 조작 명령어
aws <서비스 이름><리소스 조작 명령어>
c:\\>aws ec2 describe-security-groups
{
"SecurityGroups": [
{
"Description": "launch-wizard-3 created 2022-01-27T00:07:39.523+09:0
0",
"GroupName": "launch-wizard-3",
"IpPermissions": [
{
"FromPort": 22,
"IpProtocol": "tcp",
"IpRanges": [
{
"CidrIp": "0.0.0.0/0",
"Description": ""
...이하생략...
JavaScript
복사
--query 옵션
•
쿼리 이름(명령어 출력 항목)은 계층 구조로 되어있음
•
AWS CLI 명령어 레퍼런스를 참고해서 계층구조와 출력할 항목을 --query 옵션으로 지정
•
‘’로 감싸고 ,로 구분해서 여러 개 지정 가능
•
JSON, Table 형식으로 출력 시 쿼리 이름에 키를 붙여야 함
•
--filters 옵션에 비해 복잡하나 연산자와 함수를 지원하므로 확장성이 높음
--filters 옵션
•
•
“”로 감싸고 ,로 구분해서 여러 개 지정 가능
•
Name에 필터 이름, Values에 필터 이름에 대응하는 조건 작성
// t2.medium 또는 m3.medium 유형이고, Project 태그에 AWS Training이 적혀있는 인스턴스 참조
aws ec2 describe-instance --filters "Name=instance-type,Value=t2.medium,m3.medium" "Name=tag:Project,Values=AWS Training"
Plain Text
복사