serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

My lambda must deployed to cn-northwest-1 in china. But it is always us-east-1?

Open hotlong opened this issue 4 years ago • 4 comments

Issue Summary

My lambda must deployed to cn-northwest-1 in china. But it is always us-east-1. aws key and secret in china can not apply to us-east-1 region: InvalidClientTokenId: The security token included in the request is invalid.

Actual behavior

lambda deployed to us-east-1

Expected behavior

lambda deployed to cn-northwest-1

Steps to reproduce

# serverless.yml
myNextApplication:
  component: "./node_modules/@sls-next/serverless-component" # it is recommended you pin the latest stable version of serverless-next.js
  inputs:
    name:
      defaultLambda: nextjsTestDefaultLambda
      apiLambda: nextjsTestApiLambda
      imageLambda: nextjsTestImageLambda
    domain: ["test", "steedos.cn"]
    stage: dev
    deploy: true
    bucketRegion: cn-northwest-1
    region: cn-northwest-1
    runtime: nodejs14.x
    memory: 2048
    timeout: 30
    enableS3Acceleration: false

Screenshots/Code/Configuration/Logs

  DEBUG ─ Starting deployment of lambda nextjsTestApiLambda to the us-east-1 region.
  DEBUG ─ Syncing role v6excn-4asies in region us-east-1.

  error:
  InvalidClientTokenId: The security token included in the request is invalid.

Versions

  • OS/Environment: Mac
  • @sls-next/serverless-component version: 3.3
  • Next.js version: 11.1.2

Additional context

Checklist

  • [x] You have reviewed the README and FAQs, which answers several common questions.
  • [x] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible.
  • [x] You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

hotlong avatar Sep 14 '21 04:09 hotlong

Please see here: https://github.com/serverless-nextjs/serverless-next.js#my-lambda-is-deployed-to-us-east-1-how-can-i-deploy-it-to-another-region

Currently this only supports Lambda@Edge which is deployed globally in all regions where CloudFront is available: https://aws.amazon.com/cloudfront/features/?whats-new-cloudfront. For China it looks like there are two regions. The base Lambda is created in us-east-1 (per AWS, it has to) but actually it's replicated across all CF regions.

Lambda is not yet available with the component, although there is draft PR here https://github.com/serverless-nextjs/serverless-next.js/pull/1144 but as this is a community project, no ETA on it yet.

dphang avatar Sep 14 '21 05:09 dphang

AWS has two completely independent services around the world:

  • China: https://www.amazonaws.cn/
  • Global: https://aws.amazon.com/

The difference is not only in region. They have independent user account and password, and also independent AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

Services deployed to nodes outside of China have very unstable access speeds in China and are always blocked.

I want to deploy my service to lambda in china: https://www.amazonaws.cn/en/lambda/?nc1=h_ls , thanks

hotlong avatar Sep 15 '21 00:09 hotlong

Ya, that makes sense, as I don't have experience deploying for China I'm not sure the differences in CloudFront. It seems Lambda@Edge is not supported in China CloudFront for now but maybe that has changed? https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html.

Unfortunately but we are only supporting Lambda@Edge for now as mentioned until the above PR is completed: https://github.com/serverless-nextjs/serverless-next.js/pull/1144.

dphang avatar Sep 15 '21 01:09 dphang

Ya, that makes sense, as I don't have experience deploying for China I'm not sure the differences in CloudFront. It seems Lambda@Edge is not supported in China CloudFront for now but maybe that has changed? https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html.

Unfortunately but we are only supporting Lambda@Edge for now as mentioned until the above PR is completed: #1144.

Since https://github.com/serverless-nextjs/serverless-next.js/pull/1144 is completed, is there any update for this issue?

hotlong avatar Jun 29 '22 14:06 hotlong