Class ListenerAction
- All Implemented Interfaces:
IListenerAction
,software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
AuthenticateCognitoAction
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());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IListenerAction
IListenerAction.Jsii$Default, IListenerAction.Jsii$Proxy
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ListenerAction
(CfnListener.ActionProperty actionJson) Create an instance of ListenerAction.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) -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
(Number statusCode) Return a fixed response.static ListenerAction
fixedResponse
(Number statusCode, FixedResponseOptions options) Return a fixed response.static ListenerAction
forward
(List<? extends IApplicationTargetGroup> targetGroups) Forward to one or more Target Groups.static ListenerAction
forward
(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.Render the actions in this chain.protected List<CfnListener.ActionProperty>
renumber
(List<CfnListener.ActionProperty> actions) Renumber the "order" fields in the actions array.static ListenerAction
weightedForward
(List<? extends WeightedTargetGroup> targetGroups) Forward to one or more Target Groups which are weighted differently.static ListenerAction
weightedForward
(List<? extends WeightedTargetGroup> targetGroups, ForwardOptions options) Forward to one or more Target Groups which are weighted differently.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
ListenerAction
protected ListenerAction(software.amazon.jsii.JsiiObjectRef objRef) -
ListenerAction
protected ListenerAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
ListenerAction
@Stability(Stable) protected ListenerAction(@NotNull CfnListener.ActionProperty actionJson, @Nullable ListenerAction next) Create an instance of ListenerAction.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.
- Parameters:
actionJson
- This parameter is required.next
-
-
ListenerAction
Create an instance of ListenerAction.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.
- Parameters:
actionJson
- This parameter is required.
-
-
Method Details
-
authenticateOidc
@Stability(Stable) @NotNull public static ListenerAction authenticateOidc(@NotNull AuthenticateOidcOptions options) Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).- Parameters:
options
- This parameter is required.- See Also:
-
fixedResponse
@Stability(Stable) @NotNull public static ListenerAction fixedResponse(@NotNull Number statusCode, @Nullable FixedResponseOptions options) Return a fixed response.- Parameters:
statusCode
- This parameter is required.options
-- See Also:
-
fixedResponse
Return a fixed response.- Parameters:
statusCode
- This parameter is required.- See Also:
-
forward
@Stability(Stable) @NotNull public static ListenerAction forward(@NotNull List<? extends IApplicationTargetGroup> targetGroups, @Nullable ForwardOptions options) Forward to one or more Target Groups.- Parameters:
targetGroups
- This parameter is required.options
-- See Also:
-
forward
@Stability(Stable) @NotNull public static ListenerAction forward(@NotNull List<? extends IApplicationTargetGroup> targetGroups) Forward to one or more Target Groups.- Parameters:
targetGroups
- This parameter is required.- See Also:
-
redirect
Redirect to a different URI.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".
- Parameters:
options
- This parameter is required.- See Also:
-
weightedForward
@Stability(Stable) @NotNull public static ListenerAction weightedForward(@NotNull List<? extends WeightedTargetGroup> targetGroups, @Nullable ForwardOptions options) Forward to one or more Target Groups which are weighted differently.- Parameters:
targetGroups
- This parameter is required.options
-- See Also:
-
weightedForward
@Stability(Stable) @NotNull public static ListenerAction weightedForward(@NotNull List<? extends WeightedTargetGroup> targetGroups) Forward to one or more Target Groups which are weighted differently.- Parameters:
targetGroups
- This parameter is required.- See Also:
-
bind
@Stability(Stable) public void bind(@NotNull Construct scope, @NotNull IApplicationListener listener, @Nullable IConstruct associatingConstruct) Called when the action is being used in a listener.- Parameters:
scope
- This parameter is required.listener
- This parameter is required.associatingConstruct
-
-
bind
@Stability(Stable) public void bind(@NotNull Construct scope, @NotNull IApplicationListener listener) Called when the action is being used in a listener.- Parameters:
scope
- This parameter is required.listener
- This parameter is required.
-
renderActions
Render the actions in this chain.- Specified by:
renderActions
in interfaceIListenerAction
-
renumber
@Stability(Stable) @NotNull protected List<CfnListener.ActionProperty> renumber(@NotNull List<CfnListener.ActionProperty> actions) Renumber the "order" fields in the actions array.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 inListener
so that we give users the opportunity to override by subclassing and overridingrenderActions
.- Parameters:
actions
- This parameter is required.
-
getNext
-