1
votes

I'm trying to update a cloud formation template with a few lambda functions in it. The last version of the template was deployed a few years ago, and all the lambda functions currently have a runtime of node6.10.

I have updated the runtime for all functions to node10.x, but when I deploy the template, I get the following message:

The runtime parameter of nodejs6.10 is no longer supported for creating or updating AWS Lambda functions

I've created a change set, and reviewed it, and it includes an update to the runtime property for each lambda function, however Cloud Formation seems to be ignoring it.

Is there something I'm missing?

2

2 Answers

2
votes

Context: I assume that you encountered this issue - (you got "nodejs version not supported error" message after you tried to amplify push followed by amplify add auth)

Go to amplify -> backend -> auth -> cognito -> click cognito cloudformation -> search for "Runtime: node"

change it to "Runtime: nodejs8.10" - whatever latest recommended in error message

re-run

$ amplify push
0
votes

Unfortunately, I found I had to update the runtime of all functions in a template outside of Cloud Formation, to get the stacks to deploy. I used this script:

const AWS = require('aws-sdk')

const lambda = new AWS.Lambda(...)

main().catch(err => {
    console.error(err)
    process.exit(1)
})

async function main() {
    const functions = await getFunctions()

    await Promise.all(
        functions
            // filter only functions you want to update
            .filter(...)
            .filter(x => x.Runtime !== 'nodejs10.x')
            .map(updateFunction)
    )
}

async function updateFunction(func) {
    await lambda
        .updateFunctionConfiguration({
            FunctionName: func.FunctionName,
            Runtime: 'nodejs10.x'
        })
        .promise()

    console.log(`function updated: ${func.FunctionName}`)
}

async function getFunctions() {
    let marker
    let functions = []

    do {
        const result = await lambda
            .listFunctions({
                Marker: marker
            })
            .promise()

        functions = [...functions, ...result.Functions]
        marker = result.NextMarker
    } while (marker)

    return functions
}