DEV Community

Cover image for How to connect AWS Elastic IP with Laravel Forge
Buddhi Eashwarage
Buddhi Eashwarage

Posted on

How to connect AWS Elastic IP with Laravel Forge

As you know when Forge provisioning a server in AWS EC2, the instance get allocated private and public IP addresses automatically by AWS itself.

But if we restart the server from Forge side or AWS side Forge cannot figure it out the newly allocated public IP to the server since it has been changed, and Forge side doesn't have any reference of the latest IP address.

Therefore, as a workaround we can first allocate an Elastic IP from AWS side first. And then add a reference to that in Forge side.

Let's see how to do that.

  1. Creating and allocating an Elastic IP from AWS side.

Search for Elastic IP in the AWS console or search for EC2.

If you search by EC2, go to the EC2 dashboard and in the left panel bottom area you can see the Elastic IPs option.

Then you can choose 'Allocate Elastic IP' option, and select an Elastic IP from Amazon's pool of IPv4 addresses.

After that you'll be on 'Elastic IP addresses' dashboard area where you can connect the newly created Elastic IP to the EC2 instance.

So select the Elastic IP address from the list of addresses, and select 'Associate Elastic IP address'. You can follow the onscreen steps, and select the desired EC2 instance and allocate the IP.

All done from the AWS side. Now let's move into Forge side. There you need to select the relevant server from the Forge dashboard. Once you're inside the server, you'll see a left menu. Then select the most bottom option which is 'Meta', and it's related to metadata of the server. Once you scroll down a little bit you can see an option call 'Server Metadata'. For the 'IP Address'(Not the 'Private IP Address') field you can add the Elastic IP address which you newly created.

That's it!

Top comments (0)