It is frequently useful to know the name of a generated resource in the Serverless Framework when building for AWS. I had been struggling with this when I needed to refer to a generated resource in a separate CloudFormation section. After much searching I found a very useful trick that is probably already well documented but I’ll add my small bit of amplification here.
Finding the Generated CloudFormation
Serverless works by generating a CloudFormation template based on the serverless.yml
file. This generated file is accessible in a hidden subdirectory of the directory that contains the serverless.yml
file if you run the package
command. For me that looks like this:
sls package
less .serverless/cloudformation-template-update-stack.json
Default Names
Based on my fairly standard serverless.yml
file these are the default names for a couple of important resources.
AWS::IAM::Role | IamRoleLambdaExecution |
AWS::ApiGateway::RestApi | ApiGatewayRestApi |