Skip to content

fix: Use Amazon Linux 2 provided runtime #401

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

Closed
wants to merge 0 commits into from

Conversation

SamStephens
Copy link
Contributor

The Go runtime will shortly be end of life, so change over to the AL2 runtime.

Fixes #320

This is a direct copy of #323.

I've not been able to do any real testing. npx test appears to pass.

I tried to deploy the sample application as per README.md via NO_PREBUILT_LAMBDA=1 npx cdk deploy -a "npx ts-node -P tsconfig.dev.json --prefer-ts-exts test/example.ecr-deployment.ts", but it appears this no longer works.

$ NO_PREBUILT_LAMBDA=1 npx cdk deploy -a "npx ts-node -P tsconfig.dev.json --prefer-ts-exts test/example.ecr-deployment.ts"
/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
test/example.ecr-deployment.ts:4:23 - error TS2307: Cannot find module 'path' or its corresponding type declarations.

4 import * as path from 'path';
                        ~~~~~~
test/example.ecr-deployment.ts:13:8 - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations.

13 } from 'aws-cdk-lib';
          ~~~~~~~~~~~~~
test/example.ecr-deployment.ts:29:28 - error TS2304: Cannot find name '__dirname'.

29       directory: path.join(__dirname, 'docker'),
                              ~~~~~~~~~

    at createTSError (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Object.require.extensions.<computed> [as .ts] (/home/sam/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Function.Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  diagnosticCodes: [ 2307, 2307, 2304 ]
}

Subprocess exited with error 1

I'd test using my application that consumes this package, but it's a Python package, and I don't know how to generate a Python library from this package.

@SamStephens SamStephens changed the title Use Amazon Linux 2 provided runtime fix: Use Amazon Linux 2 provided runtime Nov 7, 2023
@scanlonp scanlonp self-assigned this Nov 14, 2023
@scanlonp
Copy link
Contributor

Getting on this today.

Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

Tested this out and it fails since asset/main is empty. I do not think we should change the name in Dockerfile.

@reubenfrith
Copy link

Curious as to when this will be merged ? Do you need some help ?

@SamStephens
Copy link
Contributor Author

@scanlonp I won't be back at work until next week, I'll look at this then.

@learner1unknown you're welcome to pick this up and take it across the line if you want to.

auto-merge was automatically disabled November 20, 2023 21:58

Head branch was pushed to by a user without write access

@SamStephens
Copy link
Contributor Author

@scanlonp apologies for the delay. It seems clear from the source file still being named main.go that you're right, and the change from main to bootstrap should not have been made.

I've hopefully fixed things, with the usual caveat that I cannot test this.

@scanlonp
Copy link
Contributor

@SamStephens yup, I will run this again.

@scanlonp
Copy link
Contributor

@SamStephens, I am not super familiar with this module. When I build locally, I cannot get the lambda main to be non-empty. I will see if this is a problem isolated to this pull, but from my initial testing, it is the same for the main branch of the module. Any ideas?

@SamStephens
Copy link
Contributor Author

Okay, now I understand a bit more what is going on, some more fundamental changes are needed.

I managed to get the test example running and I've learned some more about how this works.

Even with the change I based this on, they're still using the base image public.ecr.aws/sam/build-go1.x:latest, which is deprecated at the end of the year when the Go runtime is.

Instead it should be using an Amazon Linux base image with the aws-lambda-go/lambda package.

The rename of main to bootstrap you called out earlier will have been to do with how Custom Lambda runtimes work. I think rather than this rename, the right thing is to use the aws-lambda-go/lambda package.

I think at this point I'm probably going to close out this pull request, and start with a fresh one.

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

Successfully merging this pull request may close these issues.

Update Lambda runtime from Go 1.x (Deprecated) to custom runtime on Amazon Linux 2
3 participants