Skip to main content

Triage and Remediation

Remediation

Using Console

Below are console-only steps to enforce HTTPS for an Elastic Beanstalk (EC2) environment load balancer.

1. Get/Validate an SSL Certificate in ACM

  1. Go to AWS Management ConsoleCertificate Manager (ACM).
  2. Choose Request a certificateRequest a public certificate.
  3. Enter your domain(s), e.g. example.com and www.example.com.
  4. Choose validation method:
    • DNS validation (recommended): ACM gives you CNAME records to add to your DNS (e.g., Route 53 or external).
    • Or Email validation if DNS isn’t an option.
  5. Complete validation. Wait until status is Issued.
Keep the ARN of this certificate handy (you’ll select it in Elastic Beanstalk).

2. Confirm Your EB Environment Uses a Load Balancer

  1. Go to Elastic Beanstalk → select your Application → select your Environment.
  2. In the Environment overview, check the Environment type:
    • Must be Load balanced (either ALB or Classic ELB).
    • If it’s Single instance, you’ll need to create a new Load balanced environment (you can clone config).

3. Attach the SSL Certificate & Add HTTPS Listener

For an Application Load Balancer (ALB) environment (most newer EB envs)

  1. In your environment page, choose Configuration from the left menu.
  2. Under Load balancer, click Edit.
  3. Look at the Listeners section:
    • You should see a listener on Port 80, Protocol HTTP.
  4. Add HTTPS listener:
    1. Click Add listener (or equivalent).
    2. Set:
      • Port: 443
      • Protocol: HTTPS
    3. Under SSL certificate, choose:
      • Choose from ACM → select the certificate you created (ARN).
    4. Under Default rules / Target group, select the existing target group that your HTTP listener uses (so 443 forwards to the same instances/targets as 80).
  5. Save the configuration (e.g., Apply or Save on the page).
  6. Wait for Elastic Beanstalk to update the environment.

For a Classic Load Balancer environment (older EB envs)

  1. From your EB environment Configuration page → under Load balancer, click Edit.
  2. Under Listeners, check existing:
    • You should see a listener HTTP : 80 → HTTP : 80 (front-end to back-end).
  3. Add HTTPS listener:
    1. Add a new listener with:
      • Load Balancer Protocol: HTTPS
      • Load Balancer Port: 443
      • Instance Protocol: HTTP
      • Instance Port: 80
    2. For SSL Certificate, select your ACM certificate.
  4. Save and let EB update the environment.

4. Redirect HTTP (80) to HTTPS (443)

You’ve now enabled HTTPS, but you should force redirect all HTTP traffic to HTTPS.Redirect in your app code / web server configuration:
  • For a typical Node.js / Express app, add middleware:
  • For Apache (PHP, etc.) in .htaccess:
  • For Nginx in a config file in .ebextensions (if you control Nginx): .ebextensions/https-redirect.config:
Deploy the updated application to EB.

Option B – ALB listener rule (if using ALB)

  1. From the environment’s ConfigurationLoad balancer → find the HTTP:80 listener.
  2. Open View rules or Edit rules for the HTTP listener.
  3. Add a rule before the default:
    • Condition: If (e.g., Path is / or /* – or no condition if you want all).
    • Action: Redirect:
      • Protocol: HTTPS
      • Port: 443
      • Status code: HTTP_301.
  4. Save the rules.

5. Test

  1. Browse to: http://your-domain.com.
  2. Confirm:
    • It redirects to https://your-domain.com.
    • The browser shows a valid padlock/secure connection.
  3. Also test direct https://your-domain.com.
This fully enforces HTTPS for your Elastic Beanstalk EC2 environment using the AWS console.
Below are concise, CLI‑only steps to enforce HTTPS on an Elastic Beanstalk environment fronted by an Elastic Load Balancer (ALB / CLB) on EC2.

1. Get your environment & region info

Verify:

2. Get / create an ACM certificate

Request a public certificate (DNS validation):
Note the CertificateArn from the output. Wait until its status is ISSUED:

3. Identify whether your EB environment uses ALB or Classic ELB

Or simply:
Look inside for:
  • aws:elasticbeanstalk:environmentLoadBalancerType = application → ALB
  • Or no such setting / default → usually Classic.

Use Elastic Beanstalk option settings to:
  • Configure HTTPS listener (443) with your ACM certificate
  • Keep HTTP (80) but redirect it to HTTPS
Create a JSON file alb-https-config.json:
Replace:
Apply to the environment:
Wait for the environment to finish updating, then test:
  • http://app.example.com → should 301 redirect to https://app.example.com
  • https://app.example.com → should work with a valid cert

4B. For Classic Load Balancer: HTTPS listener + (optional) HTTP→HTTPS

4B.1 Get the underlying ELB name

From EB:

4B.2 Create/modify HTTPS listener on Classic ELB

Add HTTPS (443) listener using your ACM cert (same region):
If HTTPS already exists, you can update the cert:
Classic ELB does not support redirect rules; so either:
  • Keep port 80 listener and configure your app/web server to redirect to HTTPS, or
  • Remove the HTTP listener (forcing HTTPS only):

5. Confirm security group allows 443 and (optionally) restricts 80

Get the LB’s security group(s):
Allow HTTPS from the internet:
Optionally remove HTTP (80) if you’re not using it:

If you tell me whether your EB environment is using ALB or Classic ELB, I can trim this down to only the exact commands you need.
Below are practical, step‑by‑step instructions to enforce HTTPS for an Elastic Beanstalk environment (EC2) and a minimal Python (boto3) example to apply it programmatically.

1. Prerequisites

  1. Elastic Beanstalk environment already running (Web Server, EC2).
  2. Application Load Balancer (ALB) or Classic ELB created by EB.
  3. ACM certificate in the same region as your Beanstalk environment:
    • Request via console: ACM → Request a certificate → Public → add domain → validate.
    • Note the certificate ARN, e.g.:

2. Enforce HTTPS via Elastic Beanstalk configuration

Option A – Configuration files (.ebextensions / .platform)

For ALB (most modern EB environments):
Create .ebextensions/https-alb.config in your app root:
Then add an HTTP→HTTPS redirect via ALB rules. For EB’s new ALB model, use a platform hook:Create .platform/hooks/postdeploy/01-redirect-http-to-https.sh:
Make it executable:
Deploy the app (eb deploy); EB will:
  • Enable HTTPS listener 443 with your cert.
  • Keep HTTP listener 80 only for redirection.
  • Install redirect rule via the hook script.

3. Python (boto3) – Programmatically enforce HTTPS

Below is an example to:
  1. Find the ALB used by your EB environment.
  2. Ensure HTTPS listener (443) exists with your ACM cert.
  3. Modify HTTP (80) listener to always redirect to HTTPS.
Run this from a machine/CI with:
  • IAM permissions for elasticbeanstalk:*, elasticloadbalancingv2:*, acm:ListCertificates (or at least describe/modify for ALB and EB).
  • Credentials configured (env vars, ~/.aws/credentials, or instance role).

Ensure the load balancer security group:
  • Allows inbound 80/tcp (only if you need redirect) and 443/tcp from the internet.
  • Your EC2 instances’ security group allows inbound from the LB SG on port 80 (if your app listens on 80).

If you tell me your environment type (ALB vs Classic) and platform (e.g., Python 3.12 on AL2), I can adjust the config snippets exactly to that.
This change does not force replacement of the load balancer itself, but adding/modifying listeners momentarily affects how traffic on those ports is handled; plan and apply during a maintenance window if your environment is sensitive.For verification, terraform plan should show:
  • creation (or update) of an HTTP listener on port 80 whose default_action is a redirect to HTTPS on port 443 with status HTTP_301.
  • creation (or confirmation) of an HTTPS listener on port 443 with a valid certificate_arn that forwards to your target group.