elysia-lambda icon indicating copy to clipboard operation
elysia-lambda copied to clipboard

[BUG] Deployment expects layer in the wrong region

Open itsyoboieltr opened this issue 2 years ago • 1 comments

My layer is in eu-central-1.

elysia-lambda.yaml

deploy: src/index.ts
name: elysia-lambda
region: eu-central-1
memory: "1024"
arch: x86_64
description: Elysia Lambda
role: arn:aws:iam::...
layers:
  - arn:aws:lambda:eu-central-1:...

I set the configuration to be the same region as the bun layer.

bun run deploy

$ elysia-lambda --config elysia-lambda.yaml

Deploying "elysia-lambda"!
/Users/.../node_modules/@aws-sdk/client-lambda/dist-cjs/protocols/Aws_restJson1.js:5222
    const exception = new models_0_1.InvalidParameterValueException({
                      ^

InvalidParameterValueException: Layers are not in the same region as the function. Layers are expected to be in region us-east-1.
    at de_InvalidParameterValueExceptionRes (/Users/.../node_modules/@aws-sdk/client-lambda/dist-cjs/protocols/Aws_restJson1.js:5222:23)
    at de_CreateFunctionCommandError (/Users/.../node_modules/@aws-sdk/client-lambda/dist-cjs/protocols/Aws_restJson1.js:1931:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/.../node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
    at async /Users/.../node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
    at async /Users/.../node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46
    at async /Users/.../node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
    at async deploy (file:///Users/.../node_modules/elysia-lambda/deploy.mjs:302:9)
    at async file:///Users/.../node_modules/elysia-lambda/deploy.mjs:376:21 {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '253db0b8-3066-4ed2-aa4f-8c43b512a739',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Type: 'User'
}

The error message displays that they are not in the same region. Why are the layers expected to be in us-east-1? I do not want them to be there.

itsyoboieltr avatar Sep 06 '23 13:09 itsyoboieltr

Thanks for the bug report;

The issue is a very dumb mistake on my part - https://github.com/TotalTechGeek/elysia-lambda/blob/f1596407f2f9ca4592f3e2a6615ae644529139e8/deploy.mjs#L293

I hard-coded the region.

I'm working on a patch, but I'm unable to run the layer creation script (there appears to be an issue with one of the dependencies that Bun's script to publish layers requires).

I'll see if I can get something up this evening.

TotalTechGeek avatar Sep 06 '23 15:09 TotalTechGeek