How can I add a new path on an existing apigateway using a cloudformation template

0

The next template create a apigateway, path, method and trgiger with lambda but i need re-use a apigateway exist and add the new path

Resources: PetStore: Type: 'AWS::ApiGateway::RestApi' Properties: Name: 'PetStore'

MyApiResource: Type: 'AWS::ApiGateway::Resource' Properties: RestApiId: "et3ca7fgs7" ParentId: !GetAtt PetStore.RootResourceId PathPart: stack

MyApiMethod: Type: "AWS::ApiGateway::Method" Properties: AuthorizationType: NONE HttpMethod: POST ResourceId: !Ref MyApiResource RestApiId: "et3ca7fgs7"
Integration: IntegrationHttpMethod: "POST" Type: "AWS_PROXY" Uri: "value arn"

FiltrosAPIPermission: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction FunctionName: "arn lambda" Principal: apigateway.amazonaws.com SourceArn: "arn apigatewat"

1 Answer
0

You must export the Rest API ID at the end of the current Cloudformation Template where the API Gateway is being created:

Outputs:

 VPC:
   Description: Demo
   Value: !Ref PetStore
   Export:
          Name: PetStoreRestApiID

Then in the new Cloudformation template you must create a API Gateway Resource and reference the Rest API ID from the previous Cloudformation template:

Resources:

NewPathInAPI:
"Type" : "AWS::ApiGateway::Resource"
 Properties:
  .
  .
  .
  RestApiId:
    Fn::ImportValue:
      PetStoreRestApiID
AWS
vtjean
answered 3 months ago

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

Relevant content