AWS::ElasticLoadBalancingV2::ListenerRule FixedResponseConfig - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

This is the new Amazon CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the Amazon CloudFormation User Guide.

AWS::ElasticLoadBalancingV2::ListenerRule FixedResponseConfig

Specifies information required when returning a custom HTTP response.

Syntax

To declare this entity in your Amazon CloudFormation template, use the following syntax:

JSON

{ "ContentType" : String, "MessageBody" : String, "StatusCode" : String }

YAML

ContentType: String MessageBody: String StatusCode: String

Properties

ContentType

The content type.

Valid Values: text/plain | text/css | text/html | application/javascript | application/json

Required: No

Type: String

Minimum: 0

Maximum: 32

Update requires: No interruption

MessageBody

The message.

Required: No

Type: String

Minimum: 0

Maximum: 1024

Update requires: No interruption

StatusCode

The HTTP response code (2XX, 4XX, or 5XX).

Required: Yes

Type: String

Pattern: ^(2|4|5)\d\d$

Update requires: No interruption

Examples

The following example creates a listener rule with an action that returns the specified HTTP response under the specified condition.

YAML

myListenerRule: Type: AWS::ElasticLoadBalancingV2::ListenerRule Properties: Actions: - Type: fixed-response FixedResponseConfig: ContentType: text/plain MessageBody: "Hello world" StatusCode: 200 Conditions: - Field: path-pattern Values: - /my-path/* ListenerArn: !Ref myListener Priority: 10

JSON

{ "myListenerRule": { "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", "Properties": { "Actions": [ { "Type": "fixed-response", "FixedResponseConfig": { "ContentType": "text/plain", "MessageBody": "Hello world", "StatusCode": 200 } } ], "Conditions": [ { "Field": "path-pattern", "Values": [ "/my-path/*" ] } ], "ListenerArn": { "Ref": "myListener" }, "Priority": 10 } } }