Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to automatically truncate and uniquify long generated names #347

Open
tomchiverton opened this issue Jul 17, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@tomchiverton
Copy link

Description

In main Serverless, if a resource name ends up being too long, it's truncated and made unique e.g. 'my-long-name-trunc-H6E8'

Constructs do not appear fo this for their workers, so deployments of projects with "too long" service and/or stage and/or resource (type: queue) names fails.

How to Reproduce

sls deploy --stage the-stage-name

service: something-service

constructs:
    pdf-email-send-queue-no-vpc:
    type: queue
    worker:
        handler: pdfEmail.emailSender

Additional Information

✖ Stack something-service-the-stage-name failed to deploy (218s)
Environment: linux, node 18.16.1, framework 3.19.0 (local) 3.25.1v (global), plugin 6.2.2, SDK 4.3.2
Credentials: Local, "something-serverless-dev" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
CREATE_FAILED: PdfDashemailDashsendDashqueueDashnoDashvpcWorkerLambdaFunction (AWS::Lambda::Function)
Resource handler returned message: "1 validation error detected: Value 'something-service-the-stage-name-pdf-email-send-queue-no-vpcWorker' at 'functionName' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: Lambda, Status Code: 400, Request ID: 44d3a373-b40e-4192-ba9b-9ec1a3a30fb5)" (RequestToken: 8caf219f-3128-0f61-2e61-45ba0b7271a4, HandlerErrorCode: InvalidRequest)
@tomchiverton tomchiverton added the bug Something isn't working label Jul 17, 2023
@fredericbarthelet
Copy link
Collaborator

Thanks for reporting this issue @tomchiverton.
To my knowledge, there is no mechanism to automatically trim long resource name in the Serverless framework packaging process. That is one of the reason for the existence of the name property, available in lambda function definition in the service file definition (see https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions).

The following exemple service file, using solely core serverless framework (not this plugin), results in the exact same error:

# serverless.yml
 
service: myService
 
provider:
  name: aws
  runtime: nodejs14.x
 
functions:
  myVeryVeryLongAndDefinitelyOverTheLimitOfSixtyFourCharsFunctionName:
    handler: handler.index

Could you let me know which trimming logic you're referring to ?

On the other hand, the AWS CDK, used within Lift, to provision all non-Lambda function resources, does indeed handle resource name generation to guarantee those generated strings are within services constraints.

Finally, you can use any property existing within Serverless framework documentation in the worker property of the queue construct. You can therefore refer to worker.name property, defining a short acceptable name, to bypass this problem.

service: something-service

constructs:
    pdf-email-send-queue-no-vpc:
    type: queue
    worker:
        handler: pdfEmail.emailSender
        name: short-name

@tomchiverton
Copy link
Author

I think I was thinking of things like the S3 deploy bucket name being truncated.

That work around is a handy trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants