Class ListenerAction
What to do when a client makes a request to a listener.
Implements
Namespace: Amazon.CDK.AWS.ElasticLoadBalancingV2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ListenerAction : DeputyBase, IListenerAction
Syntax (vb)
Public Class ListenerAction
Inherits DeputyBase
Implements IListenerAction
Remarks
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).
ExampleMetadata: infused
Examples
ApplicationListener listener;
ApplicationTargetGroup myTargetGroup;
listener.AddAction("DefaultAction", new AddApplicationActionProps {
Action = ListenerAction.AuthenticateOidc(new AuthenticateOidcOptions {
AuthorizationEndpoint = "https://example.com/openid",
// Other OIDC properties here
ClientId = "...",
ClientSecret = SecretValue.SecretsManager("..."),
Issuer = "...",
TokenEndpoint = "...",
UserInfoEndpoint = "...",
// Next
Next = ListenerAction.Forward(new [] { myTargetGroup })
})
});
Synopsis
Constructors
ListenerAction(CfnListener.IActionProperty, ListenerAction) | Create an instance of ListenerAction. |
ListenerAction(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
ListenerAction(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
Next |
Methods
AddRuleAction(CfnListenerRule.IActionProperty) | Sets the Action for the |
AuthenticateOidc(IAuthenticateOidcOptions) | Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC). |
Bind(Construct, IApplicationListener, IConstruct) | Called when the action is being used in a listener. |
FixedResponse(Double, IFixedResponseOptions) | Return a fixed response. |
Forward(IApplicationTargetGroup[], IForwardOptions) | Forward to one or more Target Groups. |
Redirect(IRedirectOptions) | Redirect to a different URI. |
RenderActions() | Render the listener default actions in this chain. |
RenderRuleActions() | Render the listener rule actions in this chain. |
Renumber(CfnListener.IActionProperty[]) | Renumber the "order" fields in the actions array. |
WeightedForward(IWeightedTargetGroup[], IForwardOptions) | Forward to one or more Target Groups which are weighted differently. |
Constructors
ListenerAction(CfnListener.IActionProperty, ListenerAction)
Create an instance of ListenerAction.
public ListenerAction(CfnListener.IActionProperty defaultActionJson, ListenerAction next = null)
Parameters
- defaultActionJson CfnListener.IActionProperty
- next ListenerAction
Remarks
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.
ListenerAction(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected ListenerAction(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
ListenerAction(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected ListenerAction(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
Next
Methods
AddRuleAction(CfnListenerRule.IActionProperty)
Sets the Action for the ListenerRule
.
protected virtual void AddRuleAction(CfnListenerRule.IActionProperty actionJson)
Parameters
- actionJson CfnListenerRule.IActionProperty
Action for
ListenerRule
.
Remarks
This method is required to set a dedicated Action to a ListenerRule
when the Action for the CfnListener
and the Action for the CfnListenerRule
have different structures. (e.g. AuthenticateOidcConfig
)
AuthenticateOidc(IAuthenticateOidcOptions)
Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).
public static ListenerAction AuthenticateOidc(IAuthenticateOidcOptions options)
Parameters
- options IAuthenticateOidcOptions
Returns
Remarks
Bind(Construct, IApplicationListener, IConstruct)
Called when the action is being used in a listener.
public virtual void Bind(Construct scope, IApplicationListener listener, IConstruct associatingConstruct = null)
Parameters
- scope Constructs.Construct
- listener IApplicationListener
- associatingConstruct Constructs.IConstruct
FixedResponse(Double, IFixedResponseOptions)
Return a fixed response.
public static ListenerAction FixedResponse(double statusCode, IFixedResponseOptions options = null)
Parameters
- statusCode System.Double
- options IFixedResponseOptions
Returns
Remarks
Forward(IApplicationTargetGroup[], IForwardOptions)
Forward to one or more Target Groups.
public static ListenerAction Forward(IApplicationTargetGroup[] targetGroups, IForwardOptions options = null)
Parameters
- targetGroups IApplicationTargetGroup[]
- options IForwardOptions
Returns
Remarks
Redirect(IRedirectOptions)
Redirect to a different URI.
public static ListenerAction Redirect(IRedirectOptions options)
Parameters
- options IRedirectOptions
Returns
Remarks
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:
For example, you can change the path to "/new/#{path}", the hostname to "example.#{host}", or the query to "#{query}&value=xyz".
RenderActions()
Render the listener default actions in this chain.
public virtual CfnListener.IActionProperty[] RenderActions()
Returns
RenderRuleActions()
Render the listener rule actions in this chain.
public virtual CfnListenerRule.IActionProperty[] RenderRuleActions()
Returns
CfnListenerRule.IActionProperty[]
Renumber(CfnListener.IActionProperty[])
Renumber the "order" fields in the actions array.
protected virtual CfnListener.IActionProperty[] Renumber(CfnListener.IActionProperty[] actions)
Parameters
- actions CfnListener.IActionProperty[]
Returns
Remarks
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
.
WeightedForward(IWeightedTargetGroup[], IForwardOptions)
Forward to one or more Target Groups which are weighted differently.
public static ListenerAction WeightedForward(IWeightedTargetGroup[] targetGroups, IForwardOptions options = null)
Parameters
- targetGroups IWeightedTargetGroup[]
- options IForwardOptions
Returns