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:
import software.amazon.awscdk.services.certificatemanager.*;
Certificate certificate;
ApplicationLoadBalancer lb;
Bucket bucket;
TrustStore trustStore = TrustStore.Builder.create(this, "Store")
.bucket(bucket)
.key("rootCA_cert.pem")
.build();
lb.addListener("Listener", BaseApplicationListenerProps.builder()
.port(443)
.protocol(ApplicationProtocol.HTTPS)
.certificates(List.of(certificate))
// mTLS settings
.mutualAuthentication(MutualAuthentication.builder()
.ignoreClientCertificateExpiry(false)
.mutualAuthenticationMode(MutualAuthenticationMode.VERIFY)
.trustStore(trustStore)
.build())
.defaultAction(ListenerAction.fixedResponse(200, FixedResponseOptions.builder().contentType("text/plain").messageBody("Success mTLS").build()))
.build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.IListenerAction
IListenerAction.Jsii$Default, IListenerAction.Jsii$Proxy -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedListenerAction(CfnListener.ActionProperty defaultActionJson) Create an instance of ListenerAction.protectedListenerAction(CfnListener.ActionProperty defaultActionJson, ListenerAction next) Create an instance of ListenerAction.protectedListenerAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedListenerAction(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddRuleAction(CfnListenerRule.ActionProperty actionJson) Sets the Action for theListenerRule.static ListenerActionauthenticateOidc(AuthenticateOidcOptions options) Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).voidbind(software.constructs.Construct scope, IApplicationListener listener) Called when the action is being used in a listener.voidbind(software.constructs.Construct scope, IApplicationListener listener, software.constructs.IConstruct associatingConstruct) Called when the action is being used in a listener.static ListenerActionfixedResponse(Number statusCode) Return a fixed response.static ListenerActionfixedResponse(Number statusCode, FixedResponseOptions options) Return a fixed response.static ListenerActionforward(List<? extends IApplicationTargetGroup> targetGroups) Forward to one or more Target Groups.static ListenerActionforward(List<? extends IApplicationTargetGroup> targetGroups, ForwardOptions options) Forward to one or more Target Groups.protected ListenerActiongetNext()static ListenerActionredirect(RedirectOptions options) Redirect to a different URI.Render the listener default actions in this chain.Render the listener rule actions in this chain.protected List<CfnListener.ActionProperty>renumber(List<CfnListener.ActionProperty> actions) Renumber the "order" fields in the actions array.static ListenerActionweightedForward(List<? extends WeightedTargetGroup> targetGroups) Forward to one or more Target Groups which are weighted differently.static ListenerActionweightedForward(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, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 defaultActionJson, @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:
defaultActionJson- 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:
defaultActionJson- 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:
-
addRuleAction
Sets the Action for theListenerRule.This method is required to set a dedicated Action to a
ListenerRulewhen the Action for theCfnListenerand the Action for theCfnListenerRulehave different structures. (e.g.AuthenticateOidcConfig)- Parameters:
actionJson- Action forListenerRule. This parameter is required.
-
bind
@Stability(Stable) public void bind(@NotNull software.constructs.Construct scope, @NotNull IApplicationListener listener, @Nullable software.constructs.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 software.constructs.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 listener default actions in this chain.- Specified by:
renderActionsin interfaceIListenerAction
-
renderRuleActions
Render the listener rule actions in this chain.- Specified by:
renderRuleActionsin 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
ListenerActioninstead of inListenerso that we give users the opportunity to override by subclassing and overridingrenderActions.- Parameters:
actions- This parameter is required.
-
getNext
-