Adjusting to Serverless Components

My project is in its infancy, so starting with Serverless Components seemed like a good idea, but I’m struggling a fair bit. Here are two of my current issues:

Using the aws-api-gateway or api components, I can’t get the domain to stick, receiving a randomized URL instead. I’ve got the domain in Route53, and the website component is using it as expected, but not on the API. The backend component in the backend-monolith template works just fine.

I’m also having to set the region for all components individually. Setting it under provider doesn’t seem to work, nor does setting the AWS_REGION in .env. This is what I’m having to do:

frontend:
  component: '@serverless/website`
  inputs:
    region: us-west-2
    [ other stuff ]

api:
  component: '@serverless/api'
  inputs:
    name: blah
    region: us-west-2
    [ other stuff ]

It isn’t a huge deal, but…repetition.

I think I’m getting a handle on API stuff. Reading through the code for the backend component is helping. It doesn’t look like the api component can handle being passed a domain.

I’m currently trying to add a domain to the backend-microservices example template. I’m so close to getting it to work. I’m getting the following:

  DEBUG ─ Deploying authorizers if any for API ID jw8evch217.

  error:
  TypeError: endpoint.authorizer.split is not a function
    at createAuthorizer (/home/markfox/.serverless/components/registry/npm/@serverless/aws-api-gateway@4.1.0/node_modules/@serverless/aws-api-gateway/utils.js:429:48)
    at createAuthorizers (/home/markfox/.serverless/components/registry/npm/@serverless/aws-api-gateway@4.1.0/node_modules/@serverless/aws-api-gateway/utils.js:476:36)
    at AwsApiGateway.default (/home/markfox/.serverless/components/registry/npm/@serverless/aws-api-gateway@4.1.0/node_modules/@serverless/aws-api-gateway/serverless.js:78:23)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

  3s › restApi › TypeError: endpoint.authorizer.split is not a function

Here is the serverless.yml:

name: backend-microservices

restApi:
  component: '@serverless/aws-api-gateway'
  inputs:
    endpoints:
      - path: /users
        method: POST
        function: ${createUser}
        authorizer: ${auth}
      - path: /users
        method: GET
        function: ${getUser}
        authorizer: ${auth}

domain:
  component: '@serverless/domain'
  inputs:
    privateZone: false
    domain: blah.com
    subdomains:
      api: ${restApi}

createUser:
  component: '@serverless/function'
  inputs:
    code: ./src
    handler: index.createUser

getUser:
  component: '@serverless/function'
  inputs:
    code: ./src
    handler: index.getUser

auth:
  component: '@serverless/function'
  inputs:
    code: ./src
    handler: index.auth

Any ideas?

Somewhat solved
The aws-api-gateway component has a slightly different requirement on the inputs than the api component, which is what the microservices template provided as my starting point. I should have changes the functions and authorizers to include the arn. So {createUser.arn} and {auth.arn}.

Now I’ve just got an issue with the domain: Invalid stage identifier specified. So close.