You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS API Gateway开发者门户部署StaticAssetUploader创建失败求助

解决方案

步骤1:排查StaticAssetUploader对应的Lambda函数日志

  • 进入AWS Lambda控制台,搜索前缀包含StaticAssetUploader的函数,进入函数详情页
  • 点击「监控」标签页,选择「日志组」,找到对应请求IDea5b3458-f29c-4950-b068-d0a3f352ad5f的日志条目
  • 优先排查以下错误类型:
    • Lambda执行权限不足,比如无法访问S3存储桶、无法调用CloudFormation相关接口
    • 代码运行报错,比如依赖缺失、参数取值异常
    • 执行超时,默认的Lambda超时时间过短导致函数还没执行完就被终止

步骤2:处理cfn-response模块适配问题

如果日志显示cfn-response相关报错,直接将该模块的完整代码手动嵌入函数代码中,避免AWS Python运行时内置的cfn-response模块版本不兼容问题,同时确保函数无论执行成功还是失败,都主动返回响应给CloudFormation:

import urllib3
import json
http = urllib3.PoolManager()
SUCCESS = "SUCCESS"
FAILED = "FAILED"

def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False, reason=None):
    responseUrl = event['ResponseURL']
    responseBody = {
        'Status' : responseStatus,
        'Reason' : reason or "See the details in CloudWatch Log Stream: {}".format(context.log_stream_name),
        'PhysicalResourceId' : physicalResourceId or context.log_stream_name,
        'StackId' : event['StackId'],
        'RequestId' : event['RequestId'],
        'LogicalResourceId' : event['LogicalResourceId'],
        'NoEcho' : noEcho,
        'Data' : responseData
    }
    json_responseBody = json.dumps(responseBody)
    headers = {
        'content-type' : '',
        'content-length' : str(len(json_responseBody))
    }
    try:
        response = http.request('PUT', responseUrl, headers=headers, body=json_responseBody)
        print("Status code: ", response.status)
    except Exception as e:
        print("send(..) failed executing http.request(..):", e)

步骤3:调整配置后重新部署

  • 把Lambda的超时时间调整到至少5分钟,内存调整到256MB以上,避免资源不足导致执行中断
  • 确认Lambda的执行角色已经附加了对应S3桶的读写权限、CloudWatch日志写入权限
  • 重新触发CloudFormation栈的更新部署即可

内容的提问来源于stack exchange,提问作者CreaSoft

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 03:24:03