- IAM 建立 User 並給他相對應的權限
- 拿到 User 的 Secret Credentials
註: AWS 參考文件
$ pip install awscli更詳細的步驟,可以參考 AWS CLI 安裝手冊
$ aws configure
AWS Access Key ID [None]: AWS_ACCESS_KEY_ID
AWS Secret Access Key [None]: AWS_SECRECT_ACCESS_KEY
Default region name [None]: ap-northeast-1
Default output format [None]: ENTER- 上傳測試檔到 S3
- 取得公開下載網址
$ ./benchmark.sh EC2_TYPE MEDIA_ON_S3_URL註: EC2_TYPE : t2.micro or c4.large, See EC2 Instance Type
$ aws ec2 create-key-pair --key-name MyKeyPair --query "KeyMaterial" --output text > MyKeyPair.pem$ aws ec2 run-instances --image-id ami-0c11b26d --count 1 --instance-type t2.micro --key-name MyKeyPair $ aws ec2 describe-instances --instance-ids i-a518e53b --query "Reservations[0].Instances[0].PublicIpAddress"
"52.199.86.109"
$ ssh -i MyKeyPair.pem ubuntu@52.199.86.109$ aws ec2 terminate-instances --instance-ids i-a518e53b
{
"TerminatingInstances": [
{
"CurrentState": {
"Code": 32,
"Name": "shutting-down"
},
"PreviousState": {
"Code": 16,
"Name": "running"
},
"InstanceId": "i-a518e53b"
}
]
} $ aws ec2 delete-key-pair --key-name MyKeyPair