Skip to content

feat(elbv2): full Action support#7741

Merged
mergify[bot] merged 20 commits into
masterfrom
huijbers/elbv2-actions
May 18, 2020
Merged

feat(elbv2): full Action support#7741
mergify[bot] merged 20 commits into
masterfrom
huijbers/elbv2-actions

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented May 1, 2020

Commit Message

feat(elbv2): full Action support

Add support for more complex Action setups. Adds authentication
using OIDC or Cognito, and proper support for fixed responses,
redirects, and weighted TargetGroup forwarding and stickiness.

Fixes #2563, fixes #6310, fixes #6308.

End Commit Message


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add support for more complex Action setups. Adds authentication
using OIDC or Cognito, and proper support for fixed responses,
redirects, and weighted TargetGroup forwarding and stickiness.

Fixes #2563, fixes #6310, fixes #6308.
@rix0rrr rix0rrr requested a review from a team May 1, 2020 15:17
@rix0rrr rix0rrr self-assigned this May 1, 2020
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label May 1, 2020
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 5eb4f09
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 57a7531
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put these files under a fixtures directory perhaps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh whoops. This shouldn't have been committed.

/**
* Default action to take for requests to this listener
*
* This allows full control of the default Action of the load balancer,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This allows full control of the default Action of the load balancer,
* This allows full control of the default action of the load balancer,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called "default action"? Is there a non-default one? Why not just action

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default action is the one that doesn't have any conditions.

Comment thread packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts Outdated
Comment thread packages/@aws-cdk/aws-elasticloadbalancingv2/README.md Outdated
/**
* Forward to one or more Target Groups which are weighted differently
*/
public static weightedForward(options: WeightedForwardOptions): ApplicationListenerAction {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this just an option to forward?

*
* Must be a 2xx, 4xx or 5xx response code.
*/
readonly statusCode: number;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a positional argument (e.g. fixedResponse(200) and the rest as options)

/**
* The list of target groups to forward to
*/
readonly targetGroups: IApplicationTargetGroup[];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a positional argument

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that actually makes sense.

*
* @experimental
*/
export interface WeightedForwardOptions {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a different type from ForwardOptions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One just takes a list of target groups (common case), the other one takes a list of structures of targetgroups and weights (more complex, only when you need it).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b5c7da1
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0479616
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@rix0rrr rix0rrr requested review from a team and eladb May 6, 2020 08:56
Copy link
Copy Markdown
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments so far. To be continued...

@@ -0,0 +1,2 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up on incoming PRs - #7880 and #6869


Here's an example:

[Example of using AuthenticateCognitoAction](test/integ.cognito.lit.ts)
Copy link
Copy Markdown
Contributor

@nija-at nija-at May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on our documentation page?
Would be nice to put a small code snippet inline, along with the link to the full example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess. That's a feature request to jsii at the moment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we can still add an inline example manually.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried this example and it seems not to work for me while trying to use this with ApplicationLoadBalancedFargateService

Comment on lines +14 to +17
/**
* The Amazon Cognito user pool.
*/
readonly userPool: cognito.IUserPool;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the userpool domain and userpool clients can get you the underlying user pool. Might need to add a getter in the cognito module.

It's probably not correct to pass domain and clients of a different user pool from this, so omitting this might reduce human error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering whether a better solution is to make the client optional and automatically generate it if not supplied, as its configuration is quite finicky.

But for now, I just want to get this out there and start collecting feedback and bug reports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, IUserPool definitely does not have a method to get all clients (could it even?), nor does an IUserPoolClient have a way to get the UserPool associated with it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does an IUserPoolClient have a way to get the UserPool associated with it.

This is the first use case, so we'll need to add it.

I am wondering whether a better solution is to make the client optional and automatically generate it if not supplied, as its configuration is quite finicky.

I like it. Let's do this.

Comment thread packages/@aws-cdk/aws-elasticloadbalancingv2-actions/lib/cognito-action.ts Outdated
to the Target Groups yourself (or access one of the other ELB routing features).

Using `addAction()` gives you access to some of the features of an Elastic Load
Balancer that the convenience methods don't:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Balancer that the convenience methods don't:
Balancer that the other two convenience methods don't:

Comment thread packages/@aws-cdk/aws-elasticloadbalancingv2/README.md
*/
export class ListenerAction implements IListenerAction {
/**
* Authenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Authenticate using an identity provide (IdP) that is compliant with OpenID Connect (OIDC)
* Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC)

@rix0rrr rix0rrr requested a review from a team May 14, 2020 09:09
rix0rrr and others added 2 commits May 14, 2020 11:13
…to-action.ts

Co-authored-by: Niranjan Jayakar <nija@amazon.com>
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 1bbf524
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: fc1f76b
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Copy Markdown
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest breaking similar PRs in the future into smaller chunks that can be reviewed.
It did feel like this could be broken up or at least an initial slimmed down PR that sets up the right patterns, followed on by ones that can build this up.

Comment on lines +257 to +270
* You can reuse URI components using the following reserved keywords:
*
* - `#{protocol}`
* - `#{host}`
* - `#{port}`
* - `#{path}` (the leading "/" is removed)
* - `#{query}`
*
* For example, you can change the path to "/new/#{path}", the hostname to
* "example.#{host}", or the query to "#{query}&value=xyz".
*
* @experimental
*/
export interface RedirectOptions {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to provide a property called url and parses out these, besides having to define each of these explicitly.

Comment on lines +260 to +264
// I'd like to throw here but there might be existing programs that happen
// to work even though they followed an illegal call pattern. Just add a warning.
if (this.action) {
this.node.addWarning('An Action already existed on this ListenerRule and was replaced. Configure exactly one default Action.');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow why you're not throwing here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more explanation.

Comment on lines +135 to +137
if (props.defaultAction && props.defaultTargetGroups) {
throw new Error('Specify at most one of \'defaultAction\' and \'defaultTargetGroups\'');
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't find tests. sorry, if they're somewhere and I just can't spot them. I blame the PR size 😉

Comment on lines +166 to +171
public bindToListener(scope: Construct, listener: IApplicationListener, associatingConstruct?: IConstruct) {
// Empty on purpose
Array.isArray(scope);
Array.isArray(listener);
Array.isArray(associatingConstruct);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call this bind() like we usually do in other places?

Also why not abstract?

https://github.com/aws/aws-cdk/search?q=%22bind%22&unscoped_q=%22bind%22

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is empty on purpose, for most of the actions.

@rix0rrr rix0rrr requested review from a team and nija-at May 14, 2020 13:32
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 585b5c8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@rix0rrr
Copy link
Copy Markdown
Contributor Author

rix0rrr commented May 15, 2020

I know the build is broken, will fix it with the next round of change requests (or on approval)

@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label May 18, 2020
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3fec181
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 468b2e9
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: aa21a3a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 35da020
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 34e397a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0d03153
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c635d49
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0e408f0
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c7665dd
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 18, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify Bot merged commit 2939105 into master May 18, 2020
@mergify mergify Bot deleted the huijbers/elbv2-actions branch May 18, 2020 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS.

Projects

None yet

5 participants