hobbes
hobbes

Reputation: 467

How do I get a secondary IPv4 address from an EC2 Instance using Cloudformation

I am building some EC2 instances in AWS using CloudFormation. One of the EC2 host have 2 network interfaces with IP addresses configured on different subnets.

I am able to obtain the IP address on the primary network interface using Cloudformation with: !Sub ${SomeEC2.PrivateIp}

However, I need the secondary private IP address. How do I call the second network interface IP address using Cloudformation, and the !Sub function?

Upvotes: 0

Views: 584

Answers (1)

Marcin
Marcin

Reputation: 238051

How do I call the second network interface IP address using Cloudformation, and the !Sub function?

Sadly, you can't do it using plain CloudFormation (CFN). You would have to develop your own custom resource. The resource would be in the form of a lambda function, which would take instance id as a parameter, and then use AWS SDK to obtained the second IP address. The address would be returned to your CFN stack for further processing.

Upvotes: 1

Related Questions