0

I am trying to deploy VPC, subnets etc but I am getting the above error. I am not sure why I am getting this error. Here is the part of the template(yml) file where I am getting this error.

  NATGateway:
    Type: AWS::EC2::NatGateway
    Properties:
     AllocationId: !GetAtt ElasticIPAddress.AllocationId
     SubnetId: !Ref PublicSubnetA
     Tags:
     - Key: Name
       Value: !Sub NAT-${AWS::StackName}

thanks in Advance.

Amjad
  • 93
  • 2
  • 9
  • 1
    Do you have a resource called `ElasticIPAddress` ? ... – Paolo Jun 17 '22 at 11:52
  • No, It's not defined anywhere in the template. How can I get AllocationId then? – Amjad Jun 17 '22 at 11:57
  • 1
    `!GetAtt` is used to *reference* another resource in the template. you cannot reference a non-existing resource which is why you are getting the error. If you want to create an Elastic IP Address, then you need to add that to your template https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html – Paolo Jun 17 '22 at 11:58
  • After Adding this ** ElasticIPAddress: DependsOn: AttachGateway Type: AWS::EC2::EIP Properties: Domain: VPC** it worked, Thanks @Paolo – Amjad Jun 17 '22 at 12:21

0 Answers0