Creating two resources in CF stack of VPCGatewayAttachment with same vpc-id and gateway-id fails

0

Creating two resources in CF stack of VPCGatewayAttachment with same vpc-id and gateway-id fails

Below is the template used to create CF stack:

Resources:

InetGwAttachment:

Properties:
  InternetGatewayId: !Ref 'InternetGateway'
  VpcId: !Ref 'CustomerVpc'
Type: AWS::EC2::VPCGatewayAttachment

InternetGateway:

Properties:
  Tags:
    - Key: Name
      Value: !Join
        - ' '
        - - FS
          - !Ref 'OrgId'
    - Key: OrgId
      Value: !Ref 'OrgId'
Type: AWS::EC2::InternetGateway

NatAttachment:

Properties:
  InternetGatewayId: !Ref 'InternetGateway'
  VpcId: !Ref 'CustomerVpc'
Type: AWS::EC2::VPCGatewayAttachment

Getting create NatAttachment failed vpc-123343434xxx|IGW already exists in stack arn:aws:cloudformation:us-west-2:1234xxx:stack/OrgId-xxxxxxx/a7d61140-3628-11ee-xxxx

Earlier this used to work. Have started seeing this recently.

asked 9 months ago179 views
1 Answer
0

I see in your template, you are trying to attach IGW at two places without any difference in those two bloacks.

Two resources InetGwAttachment and NatAttachment of same resource type AWS::EC2::VPCGatewayAttachment. If you compare these two blocks InetGwAttachment and NatAttachment, there is no difference at all and NatAttachment block is duplicate, which is why you are getting this error.

Am I missing something here, within same stack, if you'll attempt to duplicate the action, it'll error out with the message like "Resource already exist". Can you add complete template here.

If I am not getting it right, please mention here in comment section, I'd certainly dig further and assist you.

Abhishek

profile pictureAWS
EXPERT
answered 9 months ago
  • Do you have that template which ran successfully in March. Or are you saying template was exact this same?

  • Hi Abhishek,

    Thanks for the response. Actually, this used to work. With different resource name for the same, it use to create different logical Ids. Is this recent change in AWS side to not allow duplicate? Below is the snapshot for the same template. We have been using same template for some reason (needed to duplicate the resource name InetGwAttachment & NatAttachment). Last successfult stack creation was in March. Post that we started seeing this issue. Logical ID. Physical ID Type Status InetGwAttachment OrgId-InetG-KP3ZYM6FNL1W AWS::EC2::VPCGatewayAttachment CREATE_COMPLETE - InternetGateway igw-021d35da453c8e84a AWS::EC2::InternetGateway CREATE_COMPLETE - NatAttachment OrgId-NatAt-1KX43OIYE3SNQ AWS::EC2::VPCGatewayAttachment CREATE_COMPLETE -

    As, I dont have cloud trail logs of 90 days before, couldn't check exactly what happened during successful creation. but, now I could see error logs resource already exists and it fails stack creation.

  • Template is same. No change. But suddenly started failing with this error. I am assuming AWS side some changes went in. Maybe earlier it was silent reject or it was allowed to have two different logical Ids for exact same resource. And now, it has started failing the stack creation.

  • I understand you started seeing this problem all at sudden but to best of my experience working with cloudformation, this should always fail with the error message, resource already exists. I hear your concern but at the same time I'm wondering and thinking of options, how would this work earlier.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions