Nowadays I am working about CloudFormation in AWS. It’s a really time consumer IAC tool. Maybe the reason that I blame it like that is that I am newbie about AWS. But honestly I tried Terraform and I feel better while using it.
In this blog post, I’ll talk about how to create NATGateway by using CloudFormation. That example stole huge amount of my time. Yes I know first attempt is always like that.
Requirements for creating NATGateway
- Creating EIP
- Associating it with NATGateway
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Parameters: Environment: Type: String InfraSubnetId: Type: String Resources: NatGatewayEIP: Type: "AWS::EC2::EIP" Properties: Domain: vpc NatGateway: Type: "AWS::EC2::NatGateway" Properties: # NOTIFICATION if you get error that at below probably referred AllocationId by using !Ref just change your line with other # AllocationId: !Ref NatGatewayEIP AllocationId: !Sub '${NatGatewayEIP.AllocationId}' SubnetId: !Ref InfraSubnetId #It should be public Subnet # Dont forget to change your route table after that Description: > Natgateway Stack |
Error:
Elastic IP address [XXX.XXX.XXX.XXX] could not be associated with this NAT gateway
For more
- https://github.com/lox/ecsy/blob/d6d6cefdc46e0b2830ada795d08aa19aa9af4848/templates/src/network-stack.yml
- Thanks that guy about example 🙂
- Note for myself: RTFM