A custom ansible module for modifying “Enable/Disable auto-assign public IP” attribute to automatically request a public IP address for instances launched into the provided subnet
To modify your subnet’s public IP addressing behavior through AWS console:
- Open the Amazon VPC console at https://console.aws.amazon.com/vpc/.
- In the navigation pane, choose Subnets.
- Select your subnet, choose Subnet Actions, and then Modify Auto-Assign Public IP.
- The Enable Auto-assign Public IP check box, if selected, requests a public IP address for all instances launched into the selected subnet. Select or clear the check box as required, and then choose Save.
- Read this for more info
Or use below custom Ansible module:
Note: at the time of writing this post, there was no such option in ansible module, “ec2_vpc”, to modify auto-assign public attribute of a subnet