How to add secondary IP to AWS instance during launch or existing instance?


I am trying to add a secondary private IP to aws instance during launch or after launch.
Both options are available on AWS console. And that is also auto assigned mode.

But with Terraform, it seems only possible way to create aws_network_interface with private_ips_count attribute and create EC2 with it.

Is there any way to handle it within aws_instance itself?

What about secondary_private_ips?

secondary_private_ips doesn’t offer auto assigned private ips.
I have to explicitly define the ip addresses, which increasing another effort to maintain secondary ip list.

I am not sure if there any way to maintain ip list, which can handle repetition error