Hi,
I copied the code in this link: https://github.com/serverless/serverless/blob/master/docs/providers/aws/events/apigateway.md#share-api-gateway-and-api-resources, but i get different endpoints and restApiId’s. Can anyone check what i could have done wrong? here are my 2 services:
service: notes-app-mono-notes
plugins:
- serverless-webpack
- serverless-offline
custom:
stage: ${opt:stage, self:provider.stage}
webpack:
webpackConfig: …/…/webpack.config.js
includeModules: true
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1
environment:
tableName:
${file(…/database/serverless.yml):custom.tableName}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- ‘Fn::ImportValue’: ${self:custom.stage}-NotesTableArn
functions:
get:
# Defines an HTTP API endpoint that calls the main function in get.js
# - path: url path is /notes/{id}
# - method: GET request
handler: get.main
events:
- http:
path: notes/{id}
method: get
cors: true
authorizer: aws_iam
resources:
Resources:
MyApiGW:
Type: AWS::ApiGateway::RestApi
Properties:
Name: MyApiGW
Outputs:
apiGatewayRestApiId:
Value:
Ref: MyApiGW
Export:
Name: MyApiGateway-restApiId
apiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- MyApiGW
- RootResourceId
Export:
Name: MyApiGateway-rootResourceId
service: notes-app-mono-billing
plugins:
- serverless-webpack
- serverless-offline
custom:
stage: {opt:stage, self:provider.stage}
webpack:
webpackConfig: ../../webpack.config.js
includeModules: true
environment: {file(env.yml):${self:custom.stage}, file(env.yml):default}
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1
apiGateway:
restApiId:
‘Fn::ImportValue’: MyApiGateway-restApiId
restApiRootResourceId:
‘Fn::ImportValue’: MyApiGateway-rootResourceId
environment:
stripeSecretKey: ${self:custom.environment.stripeSecretKey}
functions:
billing:
handler: billing.main
events:
- http:
path: billing
method: post
cors: true
authorizer: aws_iam
I noticed in cloudfront that my notes service has different service endpoint and apiGatewayRestApiId. Is this supposed to happen?
Service endpoint: https://exttceymxb.execute-api.us-east-1.amazonaws.com/dev
apiGatewayRestApiId: e10zsltayj
Thank you