Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

feat: add custom inputs for lambda name #283

Merged
merged 2 commits into from
Feb 4, 2020
Merged

feat: add custom inputs for lambda name #283

merged 2 commits into from
Feb 4, 2020

Conversation

TechEclipse
Copy link
Contributor

Default name set to this.context.resourceId() by aws-lambda serverless component for both the SSR pages lambda and API lambda. To customise the name:

# serverless.yml
myNextApplication:
  component: serverless-next.js
  inputs:
    name:
      defaultLambda: defaultLambdaName
      apiLambda: apiLambdaName

@samstr
Copy link

samstr commented Jan 27, 2020

This will be a great addition. I need to specify different environments (prod/stage) when deploying. Right now I'm deploying with a single serverless command with no way to change the target

@Podders
Copy link

Podders commented Jan 31, 2020

This will be a great addition. I need to specify different environments (prod/stage) when deploying. Right now I'm deploying with a single serverless command with no way to change the target

@samstr check out the multiple-instance-environment examples in the /packages/serverless-nextjs-component/examples/multiple-instance-environment directory, this allows for stage and prod environments

Copy link
Contributor

@danielcondemarin danielcondemarin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 Thanks!

@danielcondemarin danielcondemarin merged commit 704120b into serverless-nextjs:master Feb 4, 2020
@PrimeObjects
Copy link

great feature! Thank you for making it happen!

@Podders
Copy link

Podders commented Feb 5, 2020

@Kampfheizung is this confirmed as working? Running V1.8.1 I still can't seem to set lambda names with or without the @serverless/template configuration,

Is this reliant on this PR being merged at serverless-components/aws-lambda#16 ?

@danielcondemarin
Copy link
Contributor

@Podders I’ve not published the changes yet, will do tonight

@Podders
Copy link

Podders commented Feb 5, 2020

@danielcondemarin yeah I spotted its not published so I pulled it directly from github master and its still failing to set names for me I'm afraid, possibly my configuration but will test again with a clean project and 1.8.1

@Podders
Copy link

Podders commented Feb 6, 2020

@danielcondemarin I tested again with the Next blog example app in a clean install, added serverless-next.js from github so that I have the current version of master which is 1.8.1, with

yarn add serverless-next.js https://github.com/danielcondemarin/serverless-next.js

Added the following serverless.yml file

myNextApplication:
  component: serverless-next.js
  inputs:
    memory: 1024
    timeout: 30
    name:
      defaultLambda: test-default
      apiLambda: test-api

Ran serverless --debug and got the following output

  DEBUG ─ Resovling the template's static variables.
  DEBUG ─ Collecting components from the template.
  DEBUG ─ Downloading any NPM components found in the template.
  DEBUG ─ Analyzing the template's components dependencies.
  DEBUG ─ Creating the template's components graph.
  DEBUG ─ Syncing template state.
  DEBUG ─ Executing the template's components graph.
  DEBUG ─ Deploying bucket kyquu4g-rm3sup6 in region us-east-1.
  DEBUG ─ Checking if bucket kyquu4g-rm3sup6 exists.
  DEBUG ─ Bucket kyquu4g-rm3sup6 does not exist. Creating...
  DEBUG ─ Bucket kyquu4g-rm3sup6 created. Confirming it's ready...
  DEBUG ─ Bucket kyquu4g-rm3sup6 creation confirmed.
  DEBUG ─ Setting acceleration to "true" for bucket kyquu4g-rm3sup6.
  DEBUG ─ Bucket kyquu4g-rm3sup6 was successfully deployed to the us-east-1 region.
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Uploading file /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/about.html to bucket kyquu4g-rm3sup6
  DEBUG ─ Uploading file /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/deploy-to-now.html to bucket kyquu4g-rm3sup6
  DEBUG ─ Uploading file /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/syntax-highlighting.html to bucket kyquu4g-rm3sup6
  DEBUG ─ Uploading file /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/welcome.html to bucket kyquu4g-rm3sup6
  DEBUG ─ Uploading directory /Users/totddev/Documents/Projects/blog-starter-app/.next/static to bucket kyquu4g-rm3sup6
  DEBUG ─ Starting upload to bucket kyquu4g-rm3sup6 in region us-east-1
  DEBUG ─ Uploading directory /Users/totddev/Documents/Projects/blog-starter-app/public to bucket kyquu4g-rm3sup6
  DEBUG ─ File /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/welcome.html uploaded with key static-pages/posts/welcome.html
  DEBUG ─ File /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/deploy-to-now.html uploaded with key static-pages/posts/deploy-to-now.html
  DEBUG ─ File /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/about.html uploaded with key static-pages/about.html
  DEBUG ─ File /Users/totddev/Documents/Projects/blog-starter-app/.next/serverless/pages/posts/syntax-highlighting.html uploaded with key static-pages/posts/syntax-highlighting.html
  DEBUG ─ Starting deployment of lambda kyquu4g-oqe2jmu to the us-east-1 region.
  DEBUG ─ Syncing role kyquu4g-n4bq1up in region us-east-1.
  DEBUG ─ Creating role kyquu4g-n4bq1up.
  DEBUG ─ Saved state for role kyquu4g-n4bq1up.
  DEBUG ─ Role kyquu4g-n4bq1up was successfully deployed to region us-east-1.
  DEBUG ─ Deployed role arn is arn:aws:iam::*********:role/kyquu4g-n4bq1up.
  DEBUG ─ Packaging lambda code from /Users/totddev/Documents/Projects/blog-starter-app/.serverless_nextjs/default-lambda.
  DEBUG ─ Creating lambda kyquu4g-oqe2jmu in the us-east-1 region.
  DEBUG ─ Successfully deployed lambda kyquu4g-oqe2jmu in the us-east-1 region.
  DEBUG ─ Starting deployment of CloudFront distribution to the us-east-1 region.
  DEBUG ─ Creating CloudFront distribution in the us-east-1 region.
  DEBUG ─ CloudFront deployed successfully with URL: https://*********.cloudfront.net.

I'm pretty sure that this is reliant on serverless-components/aws-lambda#16 being merged for aws-lambda before it will work, the aws-lambda component itself ignores the name property from the yaml file, unless I'm missing something obvious here? Do the components download their own instances of dependencies?

@TechEclipse
Copy link
Contributor Author

@Podders yeah you are totally right - i already see that the PR is merged so it should be working now, correct? Thanks for your awesome help 🙌

@Podders
Copy link

Podders commented Feb 6, 2020

@Kampfheizung I think it's still pending approval at serverless-components/aws-lambda, maybe @danielcondemarin could give them a nudge? pretty sure he's a contributor on that one :)

@PrimeObjects
Copy link

Any progress on this?

@danielcondemarin
Copy link
Contributor

Any progress on this?

AFAIK the work in the next component is done. I'm waiting for serverless-components/aws-lambda#16 to be merged.

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

Successfully merging this pull request may close these issues.

Define the lambda function name
5 participants