Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api gateway will be deleted after use share restapi id with original service #5984

Open
kog-7 opened this issue Mar 31, 2019 · 2 comments
Open

Comments

@kog-7
Copy link

kog-7 commented Mar 31, 2019

This is a Bug Report

Description

apigateway will be deleted after i use share restapi id with original service,this service is for the first lambda service which create the apigateway restapi id

@allanchua101
Copy link
Contributor

allanchua101 commented Apr 14, 2019

Hi @kog-7,

You can fix this problem by deploying your API gateway in a separate service to prevent deletion of it when an attached function is about to be removed:

Gateway as a Service

service: eshop-gateway
provider:
  name: aws
  runtime: nodejs8.10
  region: ap-southeast-1
  stage: prod
resources:
  Resources:
    EShopGW:
      Type: AWS::ApiGateway::RestApi
      Properties:
        Name: EShopGW
  Outputs:
    apiGatewayRestApiId:
      Value:
        Ref: EShopGW
      Export:
        Name: EShopGW-restApiId
    apiGatewayRestApiRootResourceId:
      Value:
        Fn::GetAtt:
          - EShopGW
          - RootResourceId
      Export:
        Name: EShopGW-rootResourceId

Attaching a function

service: eshop-products
provider:
  name: aws
  runtime: nodejs8.10
  region: ap-southeast-1
  stage: prod
  apiGateway:
    restApiId:
      "Fn::ImportValue": EShopGW-restApiId
    restApiRootResourceId:
      "Fn::ImportValue": EShopGW-rootResourceId
functions:
  get-products:
    handler: handler.getProducts
    events:
      - http:
          path: products/list
          method: get

You can view a full sample here

@kog-7
Copy link
Author

kog-7 commented Apr 16, 2019

@allanchua101 Hi, allanchua101 , thanks very much for your help , will try it. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants