Class: AWSCDK::ElasticLoadBalancingv2::ListenerAction
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::ElasticLoadBalancingv2::ListenerAction
- Includes:
- IListenerAction
- Defined in:
- elastic_load_balancingv2/listener_action.rb
Overview
What to do when a client makes a request to a listener.
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).
Direct Known Subclasses
AWSCDK::ElasticLoadBalancingv2Actions::AuthenticateCognitoAction
Class Method Summary collapse
-
.authenticate_jwt(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Authenticate using JWT validation.
-
.authenticate_oidc(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).
-
.fixed_response(status_code, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Return a fixed response.
-
.forward(target_groups, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Forward to one or more Target Groups.
- .jsii_overridable_methods ⇒ Object
-
.redirect(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Redirect to a different URI.
-
.weighted_forward(target_groups, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Forward to one or more Target Groups which are weighted differently.
Instance Method Summary collapse
- #_next ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction?
-
#add_rule_action(action_json) ⇒ void
Sets the Action for the
ListenerRule. -
#bind(scope, listener, associating_construct = nil) ⇒ void
Called when the action is being used in a listener.
-
#initialize(default_action_json, _next = nil) ⇒ ListenerAction
constructor
Create an instance of ListenerAction.
-
#render_actions ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty>
Render the listener default actions in this chain.
-
#render_rule_actions ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListenerRule::ActionProperty>
Render the listener rule actions in this chain.
-
#renumber(actions) ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty>
Renumber the "order" fields in the actions array.
Constructor Details
#initialize(default_action_json, _next = nil) ⇒ 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.
30 31 32 33 34 35 |
# File 'elastic_load_balancingv2/listener_action.rb', line 30 def initialize(default_action_json, _next = nil) default_action_json = default_action_json.is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty.new(**default_action_json.transform_keys(&:to_sym)) : default_action_json Jsii::Type.check_type(default_action_json, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5DZm5MaXN0ZW5lci5BY3Rpb25Qcm9wZXJ0eSJ9")), "defaultActionJson") Jsii::Type.check_type(_next, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5MaXN0ZW5lckFjdGlvbiJ9")), "next") unless _next.nil? Jsii::Object.instance_method(:initialize).bind(self).call(default_action_json, _next) end |
Class Method Details
.authenticate_jwt(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Authenticate using JWT validation.
You can configure ALB to verify JSON Web Tokens (JWT) provided by clients for secure service-to-service (S2S) or machine-to-machine (M2M) communications.
ALB validates the token signature and requires mandatory claims: 'iss' (issuer) and 'exp' (expiration). Additionally, if present, ALB validates 'nbf' (not before) and 'iat' (issued at time) claims.
60 61 62 63 64 |
# File 'elastic_load_balancingv2/listener_action.rb', line 60 def self.authenticate_jwt() = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::AuthenticateJwtOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5BdXRoZW50aWNhdGVKd3RPcHRpb25zIn0=")), "options") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "authenticateJwt", []) end |
.authenticate_oidc(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Authenticate using an identity provider (IdP) that is compliant with OpenID Connect (OIDC).
71 72 73 74 75 |
# File 'elastic_load_balancingv2/listener_action.rb', line 71 def self.authenticate_oidc() = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::AuthenticateOidcOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5BdXRoZW50aWNhdGVPaWRjT3B0aW9ucyJ9")), "options") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "authenticateOidc", []) end |
.fixed_response(status_code, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Return a fixed response.
83 84 85 86 87 88 |
# File 'elastic_load_balancingv2/listener_action.rb', line 83 def self.fixed_response(status_code, = nil) Jsii::Type.check_type(status_code, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "statusCode") = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::FixedResponseOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5GaXhlZFJlc3BvbnNlT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "fixedResponse", [status_code, ]) end |
.forward(target_groups, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Forward to one or more Target Groups.
96 97 98 99 100 101 |
# File 'elastic_load_balancingv2/listener_action.rb', line 96 def self.forward(target_groups, = nil) Jsii::Type.check_type(target_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lbGFzdGljbG9hZGJhbGFuY2luZ3YyLklBcHBsaWNhdGlvblRhcmdldEdyb3VwIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "targetGroups") = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::ForwardOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5Gb3J3YXJkT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "forward", [target_groups, ]) end |
.jsii_overridable_methods ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'elastic_load_balancingv2/listener_action.rb', line 37 def self.jsii_overridable_methods { :_next => { kind: :property, name: "next", is_optional: true }, :add_rule_action => { kind: :method, name: "addRuleAction", is_optional: false }, :bind => { kind: :method, name: "bind", is_optional: false }, :render_actions => { kind: :method, name: "renderActions", is_optional: false }, :render_rule_actions => { kind: :method, name: "renderRuleActions", is_optional: false }, :renumber => { kind: :method, name: "renumber", is_optional: false }, } end |
.redirect(options) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
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".
124 125 126 127 128 |
# File 'elastic_load_balancingv2/listener_action.rb', line 124 def self.redirect() = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::RedirectOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5SZWRpcmVjdE9wdGlvbnMifQ==")), "options") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "redirect", []) end |
.weighted_forward(target_groups, options = nil) ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction
Forward to one or more Target Groups which are weighted differently.
136 137 138 139 140 141 142 |
# File 'elastic_load_balancingv2/listener_action.rb', line 136 def self.weighted_forward(target_groups, = nil) target_groups = target_groups.is_a?(Array) ? target_groups.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::WeightedTargetGroup.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : target_groups Jsii::Type.check_type(target_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lbGFzdGljbG9hZGJhbGFuY2luZ3YyLldlaWdodGVkVGFyZ2V0R3JvdXAifSwia2luZCI6ImFycmF5In19")), "targetGroups") = .is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::ForwardOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5Gb3J3YXJkT3B0aW9ucyJ9")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction", "weightedForward", [target_groups, ]) end |
Instance Method Details
#_next ⇒ AWSCDK::ElasticLoadBalancingv2::ListenerAction?
145 146 147 |
# File 'elastic_load_balancingv2/listener_action.rb', line 145 def _next() jsii_get_property("next") end |
#add_rule_action(action_json) ⇒ void
This method returns an undefined value.
Sets the Action for the ListenerRule.
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)
157 158 159 160 161 |
# File 'elastic_load_balancingv2/listener_action.rb', line 157 def add_rule_action(action_json) action_json = action_json.is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::CfnListenerRule::ActionProperty.new(**action_json.transform_keys(&:to_sym)) : action_json Jsii::Type.check_type(action_json, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5DZm5MaXN0ZW5lclJ1bGUuQWN0aW9uUHJvcGVydHkifQ==")), "actionJson") jsii_call_method("addRuleAction", [action_json]) end |
#bind(scope, listener, associating_construct = nil) ⇒ void
This method returns an undefined value.
Called when the action is being used in a listener.
169 170 171 172 173 174 |
# File 'elastic_load_balancingv2/listener_action.rb', line 169 def bind(scope, listener, associating_construct = nil) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(listener, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5JQXBwbGljYXRpb25MaXN0ZW5lciJ9")), "listener") Jsii::Type.check_type(associating_construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "associatingConstruct") unless associating_construct.nil? jsii_call_method("bind", [scope, listener, associating_construct]) end |
#render_actions ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty>
Render the listener default actions in this chain.
179 180 181 |
# File 'elastic_load_balancingv2/listener_action.rb', line 179 def render_actions() jsii_call_method("renderActions", []) end |
#render_rule_actions ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListenerRule::ActionProperty>
Render the listener rule actions in this chain.
186 187 188 |
# File 'elastic_load_balancingv2/listener_action.rb', line 186 def render_rule_actions() jsii_call_method("renderRuleActions", []) end |
#renumber(actions) ⇒ Array<AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty>
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 in Listener so that we give
users the opportunity to override by subclassing and overriding render_actions.
200 201 202 203 204 |
# File 'elastic_load_balancingv2/listener_action.rb', line 200 def renumber(actions) actions = actions.is_a?(Array) ? actions.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ElasticLoadBalancingv2::CfnListener::ActionProperty.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : actions Jsii::Type.check_type(actions, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lbGFzdGljbG9hZGJhbGFuY2luZ3YyLkNmbkxpc3RlbmVyLkFjdGlvblByb3BlcnR5In0sImtpbmQiOiJhcnJheSJ9fQ==")), "actions") jsii_call_method("renumber", [actions]) end |