DRYな備忘録

Don't Repeat Yourself.

【AWS】Stack deletion failed: The following resource(s) failed to delete: [AWSEBSecurityGroup].

問題

awsのElasticbeanstalkで、Rebuild Envが失敗する。Eventsなどを見ると、以下のログが吐かれていた。

ERROR   Stack deletion failed: The following resource(s) failed to delete: [AWSEBSecurityGroup, AWSEBLoadBalancerSecurityGroup].

ERROR   Deleting security group named: sg-decdb8kk failed Reason: resource sg-decdb8kk has a dependent object

ERROR   Deleting security group named: sg-a7cdb8k2 failed Reason: resource sg-a7cdb8k2 has a dependent object

ちゃんと読む限り、とにかく、EBによって自動生成されたSecurity Groupが、なんらかの理由で削除できないようだ。

なぜ削除できないのか調べる

AWS Console -> VPC -> Security Groups -> nameで検索 -> Delete Security Group

これを押すと、削除できるなら「削除する?」というダイアログ、なんらかの理由で削除できないなら「こういう理由で削除できない」というダイアログが出るはずなので、それをちゃんと読む。

This security group is referenced by another security group

どうやら、このSecurityGroupは、他のSecurity Groupから参照されているようだ。

ダイアログ内にClick here to view your security groups.という青色リンクがあるので、そこに飛んで見ると、飛んだ先のSecurity GroupのInbound Rulesで、当該Security Groupが登録されていた。

これを Edit -> ×ボタン -> Save して、参照するRuleを削除すると、この当該Security Groupは削除可能になる。

This security group is an attribute of one or more network interfaces

and cannot be deleted until you delete the network interface, or change its attributes.

どうやら、このSecurityGroupは、あるNetwork Interfaceのattributeであるようだ。

ダイアログ内にClick here to view your network interfaces.という青いリンクがあるので、そこに飛んで見ると、飛んだ先にあるNetwork InterfaceのSecurityGroupsに、当該Security Groupが登録されていた。

右上の Actions -> Change Security Groups を選択する

f:id:otiai10:20151001190512p:plain

今登録されているSecurity Groupsが網掛けになっているリストが現れるので、削除したい当該SecurityGroupのみを選択せず、既存のSecurityGroupを選択して、Saveをした。

(ここのUIがマジでconfusingで、Shift押しながらだと範囲選択、Command押しながらで、複数飛び飛び選択ができる。これに気づくのに体感30分くらいかかった)

これで、当該SecurityGroupは削除可能になる。

あらためて、Rebuild Environment

治った。

DRY