AWS, how can use a load balancer and target group to create a production and development environment when the development environment shouldn't be published to the public?
Hello, Currently, I have configured both the Prod and Dev environments to use a load balancer and target groups where the prod is using HTTP Host Header example.com while the Dev is using dev.example.com and everything is working well.
I haven't published yet but publishing, I will just allow all traffic to port 443 which will publish both prod and dev server but I need my dev server not to be published.
How would I go about this?
It's unclear what you mean by "publish", I assume you mean deploy your infrastructure or similar.
You will need two separate load balancers and associated target groups. The Prod and Dev environments really shouldn't share any infrastructure at all. I usually find it the most convenient to have them in completely separate AWS accounts which not only helps with preventing a Dev environment change from accidently affecting Production, but also allows you to easily track the costs of each environment separately.
To make the Dev environment's load balancer non-public you have a few options. You could make that load balancer an "internal" load balancer (see the Scheme setting), which will make it only available from within the VPC. To access the internal load balancer you would have to have a VPN connection to the VPC, or use an EC2 jump box or something, to allow you access to the load balancer from your computer's web browser.
Otherwise, just make the Dev load balancer public, like the Prod load balancer, but lock down the Dev load balancer's security group such that only your IP address (or your company's IP address) can access it.