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 réponse
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
répondu il y a 3 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions