Migrate to ipv4 to ipv6 for AWS Ec2

Please note that it is not a good idea to fully migrate to IPV6 since only google accepts IPV6 only mail. The rest of the big ones such as outlook, msn, proton, icloud and yahoo will fail to connect. Their prefrence is IPV4 to limit spam. However if you wish to save on ipv4 there is a way to tell postfix to prefer ipv6 and thus use ipv6 whenever possible.
Here is how:

First make sure you are assigned an IPV6 address on AWS. I am not familiar with the IPV6 assignement process for AWS. Read and once you are assigned both ipv4 and ipv6 address on your box, make sure both have proper PTR records (reverse dns).

Test you box is working with IPV6 by pinging google’s ipv6 like this

ping -6 google.com.

If the ping is OK you are good to proceed with telling postfix to send via IPV6.

sudo nano /etc/postfix/main.cf

smtp_address_preference= ipv6

This entry tells postfix to prefer ipv6 over ipv4. Test ipv6 by sending yourself an email on a gmail account. Open your gmail account and if you receive the message press Show Original to see the headers. Inspect the headers and look for your IPV6 address SPF: PASS with IPV6 ADRESS.If there is IPV4 address try again posfix might have decided to send it over IPV4 anyway.

I do not recomend the following since you will be able to send to IPV6 capable servers only, but if you wish to send only via IPV6 edit

sudo nano /etc/postfix/main.cf

inet_protocols = ipv6