3
votes

I have a simple cloudformation script that builds a Server ("AWS::EC2::Instance") and an Elastic IP ("AWS::EC2::EIP") which it attaches to that server.

The subnet has an igw attached.

I also have UserData defined within the Properties of the Server. The problem is that until the EIP attaches to the Server, there is no internet connectivity. Since this is an internet-facing subnet and I don't have a NAT box/gateway configured, is there a best practice for delaying UserData until the EIP attaches?

There is a dependency issue here: Server is created, EIP is created and attach to server ("InstanceId":{"Ref":"Server"}), so I don't believe I can DependsOn with the EIP.

1

1 Answers

3
votes

Can you add DependsOn for the EC2 creation till EIP is created. Having a Ref to EIP doesnt guarantee that the instance will wait till EIP is created.