たぬき( @tanuki_tzp )です。
Internet Monitorを作成して、色々確認してみた後に消そうとしたらワンクッションありました。
モニターが消せない
test-monitorを消したくなったので、コンソールのアクションから消してみました。
エラーが出ます。
CLIでも試してみます。
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor get-monitor --monitor-name test-monitor
{
"MonitorName": "test-monitor",
"MonitorArn": "arn:aws:internetmonitor:ap-northeast-1:0123456789012:monitor/test-monitor",
"Resources": [
"arn:aws:ec2:ap-northeast-1:0123456789012:vpc/vpc-08b566c26b91e8e74"
],
"Status": "ACTIVE",
"CreatedAt": "2024-05-06T13:00:25+00:00",
"ModifiedAt": "2024-05-06T13:24:36+00:00",
"ProcessingStatus": "COLLECTING_DATA",
"ProcessingStatusInfo": "The monitor is OK and is collecting data-points to produce insights",
"Tags": {},
"InternetMeasurementsLogDelivery": {},
"TrafficPercentageToMonitor": 100
}
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor delete-monitor --monitor-name test-monitor
An error occurred (ValidationException) when calling the DeleteMonitor operation: monitor test-monitor must be in inactive state before deletion
やはり消せませんでした。
対処法
エラー文を読むと、どうやらActive状態のモニターは消せないようです。
そのため、削除する前に一度無効化してあげる必要があります。
コンソール
対象のモニターを選択し、アクションから「無効化」を選択します。
無効化されました。
この状態で再度削除を試すと、削除承認後にはモニターが正常に削除され、確認できなくなくなりました。
AWS CLI
AWS CLIでの無効化コマンドは下記です。 適宜、"monitor-name"と"region"を読み替えてください。
aws internetmonitor update-monitor --monitor-name <monitor-name> --region <region> --status INACTIVE
実行結果
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor update-monitor --monitor-name test-monitor --status INACTIVE
{
"MonitorArn": "arn:aws:internetmonitor:ap-northeast-1:0123456789012:monitor/test-monitor",
"Status": "PENDING"
}
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor get-monitor --monitor-name test-monitor
{
"MonitorName": "test-monitor",
"MonitorArn": "arn:aws:internetmonitor:ap-northeast-1:0123456789012:monitor/test-monitor",
"Resources": [
"arn:aws:ec2:ap-northeast-1:0123456789012:vpc/vpc-08b566c26b91e8e74"
],
"Status": "INACTIVE",
"CreatedAt": "2024-05-06T13:00:25+00:00",
"ModifiedAt": "2024-05-06T13:36:03+00:00",
"ProcessingStatus": "COLLECTING_DATA",
"ProcessingStatusInfo": "The monitor is OK and is collecting data-points to produce insights",
"Tags": {},
"InternetMeasurementsLogDelivery": {},
"TrafficPercentageToMonitor": 100
}
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor delete-monitor --monitor-name test-monitor
[cloudshell-user@ip-10-134-15-18 ~]$ aws internetmonitor get-monitor --monitor-name test-monitor
An error occurred (ResourceNotFoundException) when calling the GetMonitor operation: No resource found for account 0123456789012 and resource monitor/test-monitor
正常に削除されました。
削除後のget-monitorでエラーが出ているのは、対象のモニターを削除したため、モニターの情報を取得できなくなったためです。
おわりに
大したことはしていないのですが、誰も書いていなかったので書いてみました。
誰かのお役に立てれば幸いです。