Workaround Solutions
Stop and Restart in a Different Subnet:
If you have another subnet in your VPC that is configured to auto-assign public IP addresses, you can stop your instance and change its subnet. When you start the instance again in the new subnet that has auto-assign public IP enabled, it will get a public IP.
To change the subnet of an EC2 instance, you will need to:
Stop the instance.
Detach its root volume.
Attach the volume to a new instance in a subnet that assigns public IPs automatically.
Start the new instance.
Re-launch the Instance:
Another straightforward approach is to simply launch a new instance and make sure to enable "Auto-assign Public IP" or launch it in a subnet that has this feature enabled by default. This can be easier than moving instances between subnets but requires setting up the new instance to match the old one.