Edg*_*tez 2 aws-cloudformation aws-lambda
我有一个带有AWS :: Lambda :: Function资源的CloudFormation模板,并且我试图将本地zip文件作为代码上传,但是没有上传。Lambda函数是在没有代码文件的情况下创建的。
    Resources:
  mastertestingLambdaDataDigestor:
    Properties:
      Code:
        ZipFile: fileb:///home/dariobenitez/Proyectos/dataflow/templates/lambda_template.zip
      FunctionName: mastertesting_Kinesis2DynamoDB_Datapipeline
      Handler: handler.kinesis_to_dynamodb
      Role: SOMEROLE
      Runtime: python3.6
    Type: AWS::Lambda::Function
当我尝试使用CLI部署相同功能时,zip文件路径参数有效。任何的想法?
非常感谢!
您不能在此处指定文件路径。您必须输入功能代码本身。限制为4096个字节。如果代码较大,则需要先将其上传到S3并使用S3Bucket和S3Key。
例:
mastertestingLambdaDataDigestor:
  Properties:
    Code:
      ZipFile: >
        def handler(event, context):
          pass
    FunctionName: mastertesting_Kinesis2DynamoDB_Datapipeline
    Handler: handler.kinesis_to_dynamodb
    Role: SOMEROLE
    Runtime: python3.6
  Type: AWS::Lambda::Function
另一种选择是使用aws cloudformation package。它将为您上传zip文件,并将您的模板转换为具有正确路径的模板。为此,您必须将zip文件路径直接放在中Code。例如:
Resources:
  mastertestingLambdaDataDigestor:
    Properties:
      Code: /home/dariobenitez/Proyectos/dataflow/templates/lambda_template.zip
      FunctionName: mastertesting_Kinesis2DynamoDB_Datapipeline
      Handler: handler.kinesis_to_dynamodb
      Role: SOMEROLE
      Runtime: python3.6
    Type: AWS::Lambda::Function
然后运行:
aws cloudformation package --template-file my-template.yaml --s3-bucket my-bucket
它应该输出类似:
Resources:
  mastertestingLambdaDataDigestor:
    Properties:
      Code:
        S3Bucket: my-bucket
        S3Key: fjklsdu903490f349034g
      FunctionName: mastertesting_Kinesis2DynamoDB_Datapipeline
      Handler: handler.kinesis_to_dynamodb
      Role: SOMEROLE
      Runtime: python3.6
    Type: AWS::Lambda::Function
然后,您应该使用此模板来部署堆栈。
| 归档时间: | 
 | 
| 查看次数: | 1566 次 | 
| 最近记录: |