【问题标题】:Why my cloudformation template is over 1 MB?为什么我的 cloudformation 模板超过 1 MB?
【发布时间】:2021-12-17 10:58:37
【问题描述】:

我创建了一个 SAM 项目并创建了一个简单的 hello world lambda。执行后:

sam 包 --template-file template.yaml --output-template-file output.yaml --s3-bucket bucket-child-s3

成功上传到S3,执行时出现问题:

    let params = {
        StackName: 'stack-child',
        Capabilities: ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"],
        TemplateURL: 'https://s3.amazonaws.com/bucket-child-s3/9f63c6d47e7b8dde84306e20197e557b'
    };
    const result = await cloudformation.createStack(params).promise();

我收到此错误:

模板的大小不得超过 1000000 字节

我查看了我的 s3 存储桶,文件大小为 28.7 MB,我不知道为什么当我只上传一个带有 hello world 消息响应的 lambda 时会这么大。

我需要做些什么来最小化文件大小?

【问题讨论】:

    标签: amazon-web-services amazon-s3 aws-lambda amazon-cloudformation aws-sam


    【解决方案1】:

    我读到一个可能的解决方案是添加 lambdas 的属性:

    CodeUri: src/

    但它只上传 lambda 本身的代码,我收到此错误:

    模板包含无效字符

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 2012-05-27
      相关资源
      最近更新 更多