question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

${stageVariables.xxxxxx} for lambda function name of serverless event http

See original GitHub issue

This is a (Bug Report / Feature Proposal)

Not sure if this is a feature proposal or maybe I just don’t know if it even exists

Description

We are new to serverless arch and we are trying to setup serverless in our AWS environment for dry run testing. We can’t find a way how to setup ${stageVariables.<string|variable|function|xxxx>} to event http.

When I setup the lambda function name like below:

functions:
  root-lambda:
    handler: index.handler
    name: "${stageVariables.strname}"
    events:
      - http:
         path: /api/v1
         method: get
         integration: lambda
         request:
              passThrough: WHEN_NO_MATCH

I get an error: The CloudFormation template is invalid: Template error: instance of Fn::Sub references invalid resource attribute stageVariables.strname

If I add the “!” for lambda function name, it gives different error:

functions:
  root-lambda:
    handler: index.handler
    name: "${!stageVariables.strname}"
    events:
      - http:
         path: /api/v1
         method: get
         integration: lambda
         request:
              passThrough: WHEN_NO_MATCH
}

I get this error: An error occurred: RootlambdaLogGroup - 1 validation error detected: Value '/aws/lambda/${!stageVariables.strname}' at 'logGroupNamePrefix' failed to satisfy constraint: Member must satisfy regular expression pattern: [\.\-_/#A-Za-z0-9]+.

serverless -v 1.24.1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ollamhcommented, Aug 15, 2019

@sebastian-fredriksson-bernholtz, Unfortunately no, at the end we stick with the solution I described… I’ll check my code base and try to recuperate the solution in serverless.yml

1reaction
Salinncommented, Mar 18, 2019

@neverendingqs here is an example of what I believe @markjayniel was trying to do. Would be interested to know if this is supported or not as I haven’t found much on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with stages for HTTP APIs - Amazon API Gateway
You can reference stage variables in a similar way to specify a Lambda function name or an AWS role ARN. When specifying a...
Read more >
AWS Lambda Functions - Serverless Framework
A Lambda Function URL is a simple solution to create HTTP endpoints with AWS Lambda. Function URLs are ideal for getting started with...
Read more >
HTTP API (API Gateway v2) - Serverless Framework
The Serverless Framework documentation for AWS Lambda, API Gateway, EventBridge, DynamoDB and much more.
Read more >
AWS Lambda Guide - Serverless.yml Reference
Name : data-protection-policy. # KMS key ARN to use for encryption for all functions. kmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash.
Read more >
REST API (API Gateway v1) - Serverless Framework
To create HTTP endpoints as Event sources for your AWS Lambda Functions, use the Serverless Framework's easy AWS API ... authorizer: xxx:xxx:Lambda-Name ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found