I got the answer from AWS support:
The reason why you are seeing that notification is because it is in accordance to your launch configuration (staging-1-deploy) settings. During the creation of a launch configuration, the assignment of public IP addresses to EC2 instances defaults to Only assign a public IP address to instances launched in the default VPC and subnet. (default)
[1]. To support automatic assignment of public IP addresses to your EC2 instances as they are launched, you will have to change the launch configuration settings. Since a launch configuration cannot be edited [2], you can create a new one by copying your current launch configuration. Follow the steps below to achieve this:
- Go to your AWS console, select
Launch Configurations
, select staging-1-codedeploy
- At the bottom of the details, click the grey
Copy Configuration
button on the right.
- Click
Edit Details
link, then click Advanced Details
on the resulting page.
- Go to
IP Address Type
and select the second option, Assign a public IP address to every instance.
- [optional] Change the name of the launch configuration if need be and
- Save launch configuration
You can now proceed to use your new launch configuration for your auto-scaling group and all your EC2 instances will be assigned public IP addresses as desired.
I have attached a few screenshots to show some of the steps described above.