【问题标题】:"FAILED" Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document“失败”状态:失败。原因:转换 AWS::Serverless-2016-10-31 失败,原因是:无服务器应用程序规范文档无效
【发布时间】:2022-11-15 12:10:48
【问题描述】:

我正在尝试将 cloudformation 堆栈部署到跨帐户帐户中。但是,当我部署 cloudfromation.yml 文件时,出现以下错误。我什至尝试过使用 cloudformation.yaml 但同样的错误

Waiting for changeset to be created..

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: 
For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [helloworldpython3] is invalid. 'CodeUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.

这是我得到的 cloudformation.yml 文件,它正在部署一个简单的 lambda 函数。我什至尝试过使用 cloudformation.yaml 但我得到了同样的错误

AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Description: A starter AWS Lambda function.

Resources:
  helloworldpython3:
    Type: "AWS::Serverless::Function"
    Properties:
      Handler: lambda_function.lambda_handler
      Runtime: python3.6
      CodeUri: ./lambda
      Description: 'Lambda function for CD Demo'
      MemorySize: 128
      Timeout: 30

这是我已经设置好的 buildspec.yml 文件

version: 0.2

phases:
  install:
    commands:
      - echo $CROSS_ACCOUNT_ROLE
      - echo $TARGET_ACCOUNT_ID
      - cd $CODEBUILD_SRC_DIR
      - chmod +x cross-account-setup.sh
  build:
    commands:
      - echo "Start Deploy"
      - cd $CODEBUILD_SRC_DIR
      - . ./cross-account-setup.sh
      - >
        aws cloudformation deploy --stack-name amr-manual-deployment-cicd --template-file cloudformation-stack.yml --no-fail-on-empty-changeset 
      - echo "End Deploy"

为了成功部署云形成堆栈,我需要在 .yml 文件中进行哪些更改。

谢谢

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation aws-codepipeline aws-codebuild aws-sam


    【解决方案1】:

    然后您使用转换,您可以说您让 CF“构建”您的 lambda 函数并将您的工件上传到 s3 存储桶。 Transform 将重做您的 CF 以指向现在存储在 s3 中的这些工件。在跨账户解决方案中执行此操作可能会导致 CF 对工件的读取访问权限问题。

    【讨论】:

      猜你喜欢
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多