0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Elastic BeanstalkでALB固定レスポンスを扱う方法

Last updated at Posted at 2020-01-23

Elastic Beanstalkでは直接ALB固定レスポンスを扱う方法はありません。
Beanstalkで利用しているALB側で設定しても、例えば環境をクローンすると消えてしまいます。

そういう時は.ebextensionsのconfigファイルを使ってCloud Formationを実行しましょう。

特定のパスで{"message":"fixed"}を返却するサンプル

.ebextensions/fixed-response.config
Resources:
  fixedResponseRequestListenerRule:
    Type: AWS::ElasticLoadBalancingV2::ListenerRule
    Properties: 
      Actions: 
        -   Type: fixed-response
            FixedResponseConfig:
              StatusCode: 200
              ContentType: "application/json"
              MessageBody: '{"message": "fixed"}'
      Conditions: 
        -   Field: path-pattern
            PathPatternConfig:
              Values: 
                - "/api/fixedresponse"
      ListenerArn: { "Ref" : "AWSEBV2LoadBalancerListener" }
      Priority: 1000

以下は任意です

  • fixedResponseRequestListenerRuleという名前
  • priorityの値
  • MessageBodyの値

関連する記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?