How do i send a method to a Specific stage in Cloudformation API Gatewy

0

Hi please how to send a api resource method to a specific stage and remove some method in a stage using cloud Formation

1 Answer
1
Accepted Answer

To help you related to add or remove some method in a specific stage in api gateway using cloudformation template, use this template

AWSTemplateFormatVersion: 2010-09-09
Description: Send a method to a specific stage and remove some methods in a stage API Gateway
Resources:
  ApiGatewayRestApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: MyRestApi
  ApiGatewayMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      HttpMethod: POST
      Path: /myresource
      RestApiId: !Ref ApiGatewayRestApi
      StageName: Prod
  ApiGatewayStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      Name: Prod
      RestApiId: !Ref ApiGatewayRestApi
      MethodSettings:
        - HttpMethod: POST
          ResourcePath: /myresource
          StageName: Prod
          # Remove the methods that you don't want to use in the Prod stage
          RemoveMethod: true

Above template helps you to create an API Gateway REST API with a POST method called /myresoure. The method is configured to be used in the prod stage of the API. The ApiGatewayStage resource then removes the POST method from the Prod stage

answered 8 months ago
  • Thank you i have multiple resouces how do i specify this resource to this stage and that resource to that stage

  • And Please after Removing can remove the block of code that did that

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions