Deploying multiple Serverless Framework apis to the same AWS API Gateway

By default, each Serverless project you deploy will create a new API Gateway. In most cases this works fine, but for larger projects you may need to split your apis across multiple smaller Serverless projects, each with their own serverless.yml that can be deployed independently.

The Serverless docs describe how to do this here. In each additional Serverless project where you want to add additional apis to an existing API Gateway, you need to specify 2 additional properties in your Serverless.yml, apiGateway and restApiRootResourceId:

provider:
  name: aws
  apiGateway:
    restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework
    restApiRootResourceId: xxxxxxxxxx # Root resource, represent as / path

apiGateway – this is the 11 character id for your API Gateway that you want to add resources to. You can get this from the console and it’s the prefix in your api gw url, e.g. https://aaaaaaaaaaa.execute-api.us-west-1.amazonaws.com/dev

The id for the root resource is where in your api path structure you want to add your new resource to, either the id of the root / or one of the existing paths beneath the root.

This id value I don’t think is visible in the console, but you can get it a list of all the resources in your API Gateway including the ids of each of the existing resources, with:

aws apigateway get-resources --rest-api-id aaaaaaaaaaa --region us-west-2

It will give a response that looks like:

{
    "items": [
        {
            "id": "bbbbbb",
            "parentId": "aaaaaaaaaa",
            "pathPart": "example1",
            "path": "/example1",
            "resourceMethods": {
                "GET": {}
            }
        },
        {
            "id": "aaaaaaaaaa",
            "path": "/"
        }
    ]
}

In this example I have a root / with id = aaaaaaaaa and a resource bbbbbb for /example1.

In this case if I pass aaaaaaaaaa as the value for restApiRootResourceId then my new resource will be added to /, or passing bbbbbb it will be added as a resource under /example1

Enabling AWS API Gateway CloudWatch logging

I deployed a new Lamdba with API Gateway, and when I tried turning on the CloudWatch logging for this API Gateway from the console:

… I got this error that I haven’t seen before:

Turns out per the steps on this page, you need to create an IAM role with API Gateway as the Trusted Entity, and attach the managed policy ‘AmazonAPIGatewayPushToCloudWatchLogs’ :

Add the ARN for the role you created to the Settings for the API you are working with here:

Done!

Are all my typical apps available for Apple M1 Silicon?

My 2015 MacBook Pro has recently developed a slightly bulging battery, so while I’m slightly annoyed that this means it’s the premature end of the road for my 2015 MBP 5 years after I got it new, but 5 years is still I good run for a laptop.

Before I jump all in on an order for one of the new M1 MBPs, I’m curious whether the apps I typically use are available for the M1 cpu. It’s also worth keeping in mind that just as Apple used Rosetta to bridge the gap when they transitioned from PowerPC architecture to Intel, Rosetta 2 provides that same emulation bridge to run most x86 MacOS apps on M1 if there isn’t a native version.

OpenJDK

First up a Java JDK. I also just found this site which tells you if an app is available for M1, so I think this is going to be the quick answer for all my questions. Yes, Azul have an OpenJDK build for M1: https://doesitarm.com/app/openjdk/

Eclipse IDE

Yes – if installed via installer: https://doesitarm.com/app/eclipse-ide/

VS Code

Yes – native M1 builds since February: https://code.visualstudio.com/updates/v1_54#_apple-silicon

Docker

Yes – native build available since April: https://www.docker.com/blog/released-docker-desktop-for-mac-apple-silicon/

VirtualBox

Possibly one of the only apps that may not get ported to ARM since it only support x86 based VMs and doesn’t emulate other CPUs: https://forums.virtualbox.org/viewtopic.php?f=8&t=98742 . Interestingly Parallels 17 does have an M1 ARM version, and implies it will run Windows 7+ and Linux VMs, so presumably they’re doing some x86 emulation. This might be worth a look: https://www.parallels.com/

Evernote

No native version, but x86 version runs under Rosetta 2: https://isapplesiliconready.com/app/Evernote