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 Antwort
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
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen