0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

aws ec2 の使い方 (aws-cli)

Last updated at Posted at 2022-07-05

インスタンスがひとつの場合の InstanceId の調べ方

go_list.sh
aws ec2 describe-instances > tmp01.json
jq .Reservations[0].Instances[0].InstanceId tmp01.json

インスタンスのスタート

go_start.sh
aws ec2 start-instances --instance-ids i-0f619596fcebda123

インスタンスのストップ

go_stop.sh
aws ec2 stop-instances --instance-ids i-0f619596fcebda123

実行中のインスタンスのパブリックIPアドレスを調べる方法

get_state.sh
jq .Reservations[0].Instances[0].InstanceId $1
jq .Reservations[0].Instances[0].State $1
jq .Reservations[0].Instances[0].PublicIpAddress $1

実行方法

./get_state.sh instance.json

実行結果

$ ./get_state.sh instance.json 
"i-0f619596fcebda123"
{
  "Code": 16,
  "Name": "running"
}
"13.230.15.58"

次のバージョンで確認しました。

$ aws --version
aws-cli/2.7.27 Python/3.9.11 Linux/5.19.4-arch1-1 exe/x86_64.arch prompt/off
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?