By using AWS re:Post, you agree to the Terms of Use

AWS CDK - how can I retrieve the ID of my primary network interface?


In AWS CDK I am creating an EC2 instance. CDK automatically creates a default primary network interface for this instance. How can I access this network interface's id? I'd need this in the output.

1 Answer

The challenge here is that the ENI identifier isn't known until it is created which happens during stack creation, not when CDK is executin (which is when the CloudFormation template is being written).

Why do you need the identifier? What are you trying to do?

profile picture
answered 6 months ago
  • I know that the the actual ENI identifier isn't known during execution - that's OK. I'd need the value as an Output. Why do I need it? I want to use the identifier to attach secondary IP addresses to it via CLI .

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