【问题标题】:CloudFormation: The runtime parameter of nodejs6.10 is no longer supported for creating or updating AWS Lambda functionsCloudFormation:不再支持 nodejs6.10 的运行时参数创建或更新 AWS Lambda 函数
【发布时间】:2019-11-15 01:38:42
【问题描述】:

我正在尝试更新包含一些 lambda 函数的云形成模板。模板的最后一个版本是几年前部署的,目前所有的 lambda 函数都有 node6.10 的运行时。

我已将所有函数的运行时更新为 node10.x,但是当我部署模板时,我收到以下消息:

nodejs6.10 的运行时参数不再支持创建或更新 AWS Lambda 函数

我创建了一个更改集,并对其进行了审查,其中包含对每个 lambda 函数的运行时属性的更新,但 Cloud Formation 似乎忽略了它。

我有什么遗漏吗?

【问题讨论】:

    标签: aws-lambda amazon-cloudformation


    【解决方案1】:

    不幸的是,我发现我必须更新 Cloud Formation 外部模板中所有函数的运行时,才能部署堆栈。我使用了这个脚本:

    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
    }
    

    【讨论】:

      【解决方案2】:

      背景: 我假设您遇到了这个问题 - (在您尝试放大推送然后放大添加身份验证后,您收到“nodejs version not supported error”消息)

      去放大 -> 后端 -> auth -> cognito -> 点击 cognito cloudformation -> 搜索“运行时:节点”

      将其更改为“运行时:nodejs8.10” - 错误消息中最新推荐的任何内容

      重新运行

      $ amplify push
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-10-02
        • 2021-05-11
        • 1970-01-01
        • 2019-01-06
        • 2017-10-14
        • 1970-01-01
        • 1970-01-01
        • 2020-03-27
        相关资源
        最近更新 更多