@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-28T21:34:26.355Z") public class ListenerAction extends software.amazon.jsii.JsiiObject implements IListenerAction
Some actions can be combined with other ones (specifically, you can perform authentication before serving the request).
Multiple actions form a linked chain; the chain must always terminate in a (weighted)forward, fixedResponse or redirect action.
If an action supports chaining, the next action can be indicated
by passing it in the next
property.
(Called ListenerAction
instead of the more strictly correct
ListenerAction
because this is the class most users interact
with, and we want to make it not too visually overwhelming).
Example:
ApplicationListener listener; ApplicationTargetGroup myTargetGroup; listener.addAction("DefaultAction", AddApplicationActionProps.builder() .action(ListenerAction.authenticateOidc(AuthenticateOidcOptions.builder() .authorizationEndpoint("https://example.com/openid") // Other OIDC properties here .clientId("...") .clientSecret(SecretValue.secretsManager("...")) .issuer("...") .tokenEndpoint("...") .userInfoEndpoint("...") // Next .next(ListenerAction.forward(List.of(myTargetGroup))) .build())) .build());
IListenerAction.Jsii$Default, IListenerAction.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
ListenerAction(CfnListener.ActionProperty actionJson,
ListenerAction next)
Create an instance of ListenerAction.
|
protected |
ListenerAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
ListenerAction(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
static ListenerAction |
authenticateOidc(AuthenticateOidcOptions options)
Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).
|
void |
bind(Construct scope,
IApplicationListener listener)
Called when the action is being used in a listener.
|
void |
bind(Construct scope,
IApplicationListener listener,
IConstruct associatingConstruct)
Called when the action is being used in a listener.
|
static ListenerAction |
fixedResponse(java.lang.Number statusCode)
Return a fixed response.
|
static ListenerAction |
fixedResponse(java.lang.Number statusCode,
FixedResponseOptions options)
Return a fixed response.
|
static ListenerAction |
forward(java.util.List<? extends IApplicationTargetGroup> targetGroups)
Forward to one or more Target Groups.
|
static ListenerAction |
forward(java.util.List<? extends IApplicationTargetGroup> targetGroups,
ForwardOptions options)
Forward to one or more Target Groups.
|
protected ListenerAction |
getNext() |
static ListenerAction |
redirect(RedirectOptions options)
Redirect to a different URI.
|
java.util.List<CfnListener.ActionProperty> |
renderActions()
Render the actions in this chain.
|
protected java.util.List<CfnListener.ActionProperty> |
renumber(java.util.List<CfnListener.ActionProperty> actions)
Renumber the "order" fields in the actions array.
|
static ListenerAction |
weightedForward(java.util.List<? extends WeightedTargetGroup> targetGroups)
Forward to one or more Target Groups which are weighted differently.
|
static ListenerAction |
weightedForward(java.util.List<? extends WeightedTargetGroup> targetGroups,
ForwardOptions options)
Forward to one or more Target Groups which are weighted differently.
|
protected ListenerAction(software.amazon.jsii.JsiiObjectRef objRef)
protected ListenerAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
protected ListenerAction(CfnListener.ActionProperty actionJson, ListenerAction next)
The default class should be good enough for most cases and should be created by using one of the static factory functions, but allow overriding to make sure we allow flexibility for the future.
actionJson
- This parameter is required.next
- public static ListenerAction authenticateOidc(AuthenticateOidcOptions options)
options
- This parameter is required.public static ListenerAction fixedResponse(java.lang.Number statusCode, FixedResponseOptions options)
statusCode
- This parameter is required.options
- public static ListenerAction fixedResponse(java.lang.Number statusCode)
statusCode
- This parameter is required.public static ListenerAction forward(java.util.List<? extends IApplicationTargetGroup> targetGroups, ForwardOptions options)
targetGroups
- This parameter is required.options
- public static ListenerAction forward(java.util.List<? extends IApplicationTargetGroup> targetGroups)
targetGroups
- This parameter is required.public static ListenerAction redirect(RedirectOptions options)
A URI consists of the following components: protocol://hostname:port/path?query. You must modify at least one of the following components to avoid a redirect loop: protocol, hostname, port, or path. Any components that you do not modify retain their original values.
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".
options
- This parameter is required.public static ListenerAction weightedForward(java.util.List<? extends WeightedTargetGroup> targetGroups, ForwardOptions options)
targetGroups
- This parameter is required.options
- public static ListenerAction weightedForward(java.util.List<? extends WeightedTargetGroup> targetGroups)
targetGroups
- This parameter is required.public void bind(Construct scope, IApplicationListener listener, IConstruct associatingConstruct)
scope
- This parameter is required.listener
- This parameter is required.associatingConstruct
- public void bind(Construct scope, IApplicationListener listener)
scope
- This parameter is required.listener
- This parameter is required.public java.util.List<CfnListener.ActionProperty> renderActions()
renderActions
in interface IListenerAction
protected java.util.List<CfnListener.ActionProperty> renumber(java.util.List<CfnListener.ActionProperty> actions)
We don't number for 0 or 1 elements, but otherwise number them 1...#actions so ELB knows about the right order.
Do this in ListenerAction
instead of in Listener
so that we give
users the opportunity to override by subclassing and overriding renderActions
.
actions
- This parameter is required.protected ListenerAction getNext()