Skip to content

Commit

Permalink
fix(elasticloadbalancingv2): ALB auth return internal server error (#…
Browse files Browse the repository at this point in the history
…24510)

## Summary
Allow HTTPS outbound traffic for security groups attached to the Application Load Balancer if the Application Load Balancer is configured with an authentication configuration.

## Why is this PR needed?
Application Load Balancer authentication requires HTTPS outbound traffic.
However, the security group attached to the ApplicationLoadBalancer does not allow traffic to the outside, so the code as described in the documentation will not work by itself.
<img width="593" alt="image" src="https://user-images.githubusercontent.com/49480575/223705838-a047e14c-95f5-4c8e-9003-0bbdf6b9d281.png">

This issue is also documented.
https://aws.amazon.com/premiumsupport/knowledge-center/elb-configure-authentication-alb/?nc1=h_ls

## Related issues
Following opened issues were fixed by #21939, but related this PR.
Closes  #19035 #18944.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
WinterYukky authored May 5, 2023
1 parent 6e73e66 commit 75212eb
Show file tree
Hide file tree
Showing 37 changed files with 9,406 additions and 164 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { execSync } from 'child_process';

const url = process.env.TEST_URL;
const setupBrowser = async () => {
execSync('HOME=/tmp npm install puppeteer-core @sparticuz/chromium --omit=dev --no-package-lock --no-save --prefix /tmp');
const puppeteer = require('/tmp/node_modules/puppeteer-core');
const chromium = require('/tmp/node_modules/@sparticuz/chromium');
const browser = await puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(),
headless: chromium.headless,
});
return browser;
};

export const handler: AWSLambda.Handler = async (_event) => {
const browser = await setupBrowser();
const page = await browser.newPage();
await page.goto(url, {
waitUntil: ['load', 'networkidle0'],
timeout: 30000,
});
await page.type("div.visible-lg input[name='username']", process.env.TEST_USERNAME);
await page.type("div.visible-lg input[name='password']", process.env.TEST_PASSWORD);
await page.click("div.visible-lg input[type='submit']");
const body = await page.waitForSelector('body');
const textContent = await body.evaluate((el: any) => el.textContent);
return textContent;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const handler: AWSLambda.Handler;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { execSync } from 'child_process';

const url = process.env.TEST_URL;
const setupBrowser = async () => {
execSync('HOME=/tmp npm install puppeteer-core @sparticuz/chromium --omit=dev --no-package-lock --no-save --prefix /tmp');
const puppeteer = require('/tmp/node_modules/puppeteer-core');
const chromium = require('/tmp/node_modules/@sparticuz/chromium');
const browser = await puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(),
headless: chromium.headless,
});
return browser;
};

export const handler: AWSLambda.Handler = async (_event) => {
const browser = await setupBrowser();
const page = await browser.newPage();
await page.goto(url, {
waitUntil: ['load', 'networkidle0'],
timeout: 30000,
});
await page.type("div.visible-lg input[name='username']", process.env.TEST_USERNAME);
await page.type("div.visible-lg input[name='password']", process.env.TEST_PASSWORD);
await page.click("div.visible-lg input[type='submit']");
const body = await page.waitForSelector('body');
const textContent = await body.evaluate((el: any) => el.textContent);
return textContent;
};

Large diffs are not rendered by default.

Loading

0 comments on commit 75212eb

Please sign in to comment.