Closed takenokoroid closed 3 years ago
CurrentState
の Name
を使えそう?Name
の値は4つ確認
https://github.com/shokkunrf/tetona/blob/c137023bdf08e9bf38f4939da2be59158afcec73/main.go#L26-L29
今のところの方針をまとめるとこんな感じ。
running
が返ってきたら通知log.Fatalln()
しないで通知するstopped
が返ってきたら通知log.Fatalln()
しないで通知するpending
で起動した場合、stopping
で終了した場合はどうなるんだろう...stopping
で起動した場合、pending
で終了した場合はどうなるんだろう...pending
で起動した場合、stopping
で終了した場合についてCurrentState
が pending
で、PreviousState
が stopped
or pending
だったら既に起動準備中ってことにしよう(起動コマンドの場合)stopping
で起動した場合、pending
で終了した場合についてstoppingで起動 --> エラーになる
An error occurred (IncorrectInstanceState) when calling the StartInstances operation: The instance 'i-xxxxxxxxxxxxxxxxx' is not in a state from which it can be started.
pendingで終了 --> できる
{
"StoppingInstances": [
{
"CurrentState": {
"Code": 64,
"Name": "stopping"
},
"InstanceId": "i-xxxxxxxxxxxxxxxxx",
"PreviousState": {
"Code": 0,
"Name": "pending"
}
}
]
}
IPアドレスはこれで取れそう
$ aws ec2 describe-instances --instance-ids i-xxxxxxxxxxxxxxxxx --query 'Reservations[].Instances[].{publicip:PublicIpAddress}'
こうなる
[
{
"publicip": "1.1.1.1"
}
]
なぜ
Discordからの起動・停止のレスポンスがないと不安になる。 また、インスタンス起動ごとにIPが変わるため、IPを通知しないと接続できない。
希望通知内容