awsdocs/aws-cdk-guide

addRedirectResponse is deprecated in @aws-cdk/aws-elasticloadbalancingv2.ApplicationListener

Closed this issue · 3 comments

addRedirectResponse is deprecated but I don't understand how to use addAction. Would be great to have an example.

Something like:

  listener.addAction("DefaultAction", {
    action: elbv2.ListenerAction.redirect(
    {
      host: 'www.example.com',
      permanent: true
    })
  });

You could also pass it as the defaultAction prop when adding the listener, rather than adding it to the listener afterward:

  const listener = lb.addListener('Listener', {
    port: 80,
    open: true,
    defaultAction: elbv2.ListenerAction.redirect(
    {
      host: 'www.example.com',
      permanent: true
    })
  });

@jeznag Does that help? There's some additional information in the module's README at https://docs.aws.amazon.com/cdk/api/latest/docs/aws-elasticloadbalancingv2-readme.html (search for addAction()).

I'm going to go ahead and close this. @jeznag please feel free to reopen if you want to continue discussing this.