Having trouble to delete CloudFormation

1

I have trouble deleting AWS stack, using both java SDK and AWS cli.

MVP:

AWSTemplateFormatVersion: "2010-09-09"
Metadata:
    Generator: "former2"
Description: ""

Resources:
    EC2KeyPair:
        Type: "AWS::EC2::KeyPair"
        Properties:
            PublicKeyMaterial: "foo"
            KeyName: "bar"
            KeyType: "rsa"

Deletion attempt KeyPair throws internal error and ends with DELETE_FAILED. After attempting to delete resource for the second time it is succesfull (resource has been fully initalized before first attempt).

Deletion is attempted with least access rights possible (ec2:* ,cloudformation:* ... ), when attempted with admin access delete works on first try.

質問済み 2年前348ビュー
2回答
0

Hi There

Is this key attached to an EC2 instance? is it possible the EC2 instance is not fully terminated before you are attempting to delete the key?

profile pictureAWS
エキスパート
Matt-B
回答済み 2年前
  • there is no EC2 instance being created. YAML snippet from question can be uploaded as is using aws cloudformation deploy command

0

When deletion fails (usually 3 after attempts that take a while), on some resources, the Cloudformaiton stack will delete successfully, even though the reasouce is still there.

If it works with admin, but not with the least privileges role, you correctly assume that this is IAM related.

Usually Cloudformaiton to needs read (ec2:Get*, ec2:List*, ec2:Describe*) permission and manage tags (ec2:DeleteTags and ec2:CreateTags) not only the ec2:DeleteKeyPair permission.

Hope it helps!

profile picture
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ