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

Deployment fails if Serverless Application Name is Non Alphanumeric #16

Open
ubaniabalogun opened this issue Jun 24, 2020 · 4 comments
Open

Comments

@ubaniabalogun
Copy link
Contributor

Serverless deployment with the plugin fails when the serverless application name is non-alphanumeric. For example, the below serverless.yaml would not successfully deploy when the plugin is configured

service: example-service

plugins:
- serverless-fargate-plugin

custom:
  fargate:
    clusterName: Test

It will fail with error

 Error: The CloudFormation template is invalid: Template format error: Resource name example-serviceTestClust is non alphanumeric.

This is likely happening because the plugin is concatenating the raw service name with the clusterName property to form the namePrefix as linked below and serverless is attempting to use that namePrefix as the Resource name for the Cloudformation (CF) stack.

super(options, stage, `${serviceName}${options.clusterName}`, tags);

CF however, requires alphanumeric names for Resource Names.

Raising this as an issue as non-alphanumeric service names above are valid in serverless.yaml files, and shouldn't be used to prefix strings that may be used as Resource Names in CF.

A couple of ways I can think of addressing this are:
a) Auto substituting non-alphanumeric values in the namePrefix to make it alphanumeric before use (this could break existing deployments using the plugin)
b) Introducing a usePrefix flag that defaults to true but can be set to false if a user doesn't want clusterName prefixed

If either of those options sounds appealing or you have alternative options you'd like to explore, please let me know and I'd be happy to take a swing at creating a PR for the fix

@dazza-codes
Copy link

👍 and go further

  • allow the options to completely define the cluster name without any prefix or suffix

@jameswoodley
Copy link

This has just bitten me too, all my services are {{basename}}-whateveritsdoing - so I always have hyphens in the service name

@tezqa
Copy link

tezqa commented Jun 4, 2021

Someone on board? I really need to get this improvement.

@gwdp
Copy link
Contributor

gwdp commented Jun 7, 2021

Hey guys, please, check https://github.com/hybridless/serverless-ecs-plugin, will actively support you there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants