Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(elasticloadbalancingv2-actions): update integ tests #21642

Merged
merged 3 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 54 additions & 4 deletions packages/@aws-cdk/aws-elasticloadbalancingv2-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,58 @@ read [Prepare to use Amazon
Cognito](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html#cognito-requirements).
Here's an example:

[Example of using AuthenticateCognitoAction](test/integ.cognito.lit.ts)
```ts
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true,
});

> NOTE: this example seems incomplete, I was not able to get the redirect back to the
Load Balancer after authentication working. Would love some pointers on what a full working
setup actually looks like!
const userPool = new cognito.UserPool(this, 'UserPool');
const userPoolClient = new cognito.UserPoolClient(this, 'Client', {
userPool,

// Required minimal configuration for use with an ELB
generateSecret: true,
authFlows: {
userPassword: true,
},
oAuth: {
flows: {
authorizationCodeGrant: true,
},
scopes: [cognito.OAuthScope.EMAIL],
callbackUrls: [
`https://${lb.loadBalancerDnsName}/oauth2/idpresponse`,
],
},
});
const cfnClient = userPoolClient.node.defaultChild as cognito.CfnUserPoolClient;
cfnClient.addPropertyOverride('RefreshTokenValidity', 1);
cfnClient.addPropertyOverride('SupportedIdentityProviders', ['COGNITO']);

const userPoolDomain = new cognito.UserPoolDomain(this, 'Domain', {
userPool,
cognitoDomain: {
domainPrefix: 'test-cdk-prefix',
},
});

lb.addListener('Listener', {
port: 443,
certificates: [certificate],
defaultAction: new actions.AuthenticateCognitoAction({
userPool,
userPoolClient,
userPoolDomain,
next: elbv2.ListenerAction.fixedResponse(200, {
contentType: 'text/plain',
messageBody: 'Authenticated',
}),
}),
});

new CfnOutput(this, 'DNS', {
value: lb.loadBalancerDnsName,
});

```
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"jest": "^27.5.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"20.0.0"}
Loading