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

Allow Node 22 functions #2269

Merged
merged 8 commits into from
Nov 26, 2024

Conversation

ataylorme
Copy link
Contributor

Problem

Closes #2268

Changes

Add support to @aws-amplify/backend-function for Node 22, which is a supported Lambda runtime that was added in aws-cdk-lib/aws-lambda version 2.168.0 on November 20th, 2024

Validation

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add support to `@aws-amplify/backend-function` for Node 22, which is a [supported Lambda runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels) that was added in [`aws-cdk-lib/aws-lambda` version `2.168.0`](https://github.com/aws/aws-cdk/releases/tag/v2.168.0) on November 20th, 2024
@ataylorme ataylorme requested review from a team as code owners November 25, 2024 23:19
Copy link

changeset-bot bot commented Nov 25, 2024

🦋 Changeset detected

Latest commit: 29ee0db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@aws-amplify/backend-function Minor
@aws-amplify/backend Minor
@aws-amplify/backend-platform-test-stubs Patch
@aws-amplify/backend-output-storage Patch
@aws-amplify/integration-tests Patch
@aws-amplify/backend-deployer Patch
@aws-amplify/schema-generator Patch
@aws-amplify/backend-storage Patch
@aws-amplify/auth-construct Patch
@aws-amplify/ai-constructs Patch
@aws-amplify/client-config Patch
@aws-amplify/backend-auth Patch
@aws-amplify/backend-data Patch
@aws-amplify/plugin-types Patch
@aws-amplify/backend-ai Patch
@aws-amplify/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@sobolk sobolk left a comment

Choose a reason for hiding this comment

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

LGTM.
I left couple of comments to get checks passing.

packages/client-config/API.md Outdated Show resolved Hide resolved
packages/platform-core/API.md Outdated Show resolved Hide resolved
@@ -32,7 +32,7 @@
"uuid": "^9.0.1"
},
"peerDependencies": {
"aws-cdk-lib": "^2.158.0",
"aws-cdk-lib": "^2.168.0",
Copy link
Member

Choose a reason for hiding this comment

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

Please update aws-cdk-lib and aws-cdk to matching version in all package.json files across the workspace.

Copy link
Contributor Author

@ataylorme ataylorme Nov 26, 2024

Choose a reason for hiding this comment

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

Updated package.json files in d443b1f and package-lock.json in 6c98329

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a script update-cdk-in-packages.js to do this. Sharing in case it is useful to you in the future.

/* eslint-disable */
const rootDir = process.cwd();
import fs from 'fs';
import path from 'path';

async function findPackageJsonFiles(dir) {
    let results = [];
    const list = fs.readdirSync(dir);
    for (let file of list) {
        file = path.resolve(dir, file);
        const stat = fs.statSync(file);
        if (stat && stat.isDirectory()) {
            results = results.concat(await findPackageJsonFiles(file));
        } else if (file.endsWith('package.json')) {
            const relativePath = path.relative(rootDir, file);
            if (/packages\/[\w-]+\/package\.json$/.test(relativePath)) {
                results.push(file);
            }
        }
    }
    return results;
}

function updatePackageVersion(packageJson, packageName, newVersion) {
    if (packageJson.dependencies && packageJson.dependencies[packageName]) {
        packageJson.dependencies[packageName] = newVersion;
    }
    if (packageJson.devDependencies && packageJson.devDependencies[packageName]) {
        packageJson.devDependencies[packageName] = newVersion;
    }
    if (packageJson.peerDependencies && packageJson.peerDependencies[packageName]) {
        packageJson.peerDependencies[packageName] = newVersion;
    }
}

async function updateCdkVersion(filePaths) {
    for (let filePath of filePaths) {
        const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf8'));
        updatePackageVersion(packageJson, 'aws-cdk-lib', '^2.168.0');
        updatePackageVersion(packageJson, 'aws-cdk', '^2.168.0');
        fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 2) + `\n`, 'utf8');
    }
}

async function main() {
    const packageJsonFiles = await findPackageJsonFiles(path.join(rootDir, 'packages'));
    await updateCdkVersion(packageJsonFiles);
    console.log('Updated package.json files:', packageJsonFiles);
}

main();
/* eslint-enable */

Copy link
Member

Choose a reason for hiding this comment

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

thank you.
there will be one more thing needed - additional changeset, since most of packages got touched.
Please see b56d344 for reference. This commit contains a changeset file from last time we upgraded CDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reference, that helps.

@sobolk
Copy link
Member

sobolk commented Nov 26, 2024

Looks like some tests are failing. Could you please take a look https://github.com/aws-amplify/amplify-backend/actions/runs/12033789933/job/33549492119?pr=2269 ?

@sobolk sobolk enabled auto-merge (squash) November 26, 2024 18:04
@sobolk sobolk merged commit 72b2fe0 into aws-amplify:main Nov 26, 2024
40 checks passed
@sobolk
Copy link
Member

sobolk commented Nov 26, 2024

@ataylorme thanks for contributing!

@ataylorme ataylorme deleted the feat/allow-node-22-functions branch November 26, 2024 18:20
@ataylorme
Copy link
Contributor Author

Thank you! In the spirit of contributing any chance I can get a review of #1971?

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.

Node 22 Support
3 participants