【问题标题】:how to deploy a lambda function using boto3?如何使用 boto3 部署 lambda 函数?
【发布时间】:2021-03-25 13:05:37
【问题描述】:

我之前在nodejs中使用如下方式部署了一个lambda函数。

    await aws.command(
      `cloudformation package \
        --template-file ${template} \
        --output-template-file ${serverless} \
        --s3-bucket ${bucketName}`
    ).then(function (data) {
      console.log('cloudformation packaging data=', data)
    })
    console.log('server deploying...')
    await aws.command(
      `cloudformation deploy \
        --template-file ${serverless} \
        --stack-name ${stackName} \
        --capabilities CAPABILITY_IAM`
    ).then(function (data) {
      console.log('cloudformation deploying data=', data)
    })

这是我的 cloudformation 模板文件。

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Resources:
  ExportServer:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/server.handler
      Runtime: nodejs12.x
      Events:
        AnyRequest:
          Type: Api
          Properties:
            Path: /graphql
            Method: ANY

但现在我需要在 python 中使用 boto3。

请给我任何建议。

【问题讨论】:

    标签: aws-lambda amazon-cloudformation boto3


    【解决方案1】: