gpt4 book ai didi

amazon-web-services - AWS cloudformation 嵌套堆栈因模板 URL 失败

转载 作者:行者123 更新时间:2023-12-03 07:30:35 24 4
gpt4 key购买 nike

我是 cloudformation 的新手,但当前项目有一个模板,其中所有资源都位于一个唯一的文件中,我们尝试使用嵌套堆栈选项将多个文件分开。当我尝试部署模板时,执行失败并显示下一条消息:

$ aws s3 cp testing-substack.yml s3://gitlab-cicd

upload: ./testing-substack.yml to s3://gitlab-cicd/testing-substack.yml


$ aws cloudformation package --template-file testing-mainstack.yml --s3-bucket gitlab-cicd --output-template testing-packstack.yaml

Unable to upload artifact substack-amp.yml referenced by TemplateURL parameter of SubstackA resource.
TemplateURL parameter of SubstackA resource is invalid. It must be a S3 URL or path to CloudFormation template file. Actual: /builds/project-0/substack-amp.yml

接下来包含两个模板(lambda 函数只有一个“Hello world”:

测试-mainstack.yml

测试A

Resources:
SubstackA:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: testing-substack.yml

测试B

Resources:
SubstackA:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: s3://gitlab-cicd/testing-substack.yml

子堆栈模板:testing-substack.yml

  TestingSubLambda:
Type: AWS::Serverless::Function
Properties:
Description: "Testing lambda inside substack"
CodeUri: ./
Handler: lambda-two.lambda_handler
Runtime: python3.8
FunctionName: TestingSubLambda
# Role: arn:aws:iam::000365055762:role/lambda-essential-role
Timeout: 480
# Events:
# B2bCImportOrdersApiEvent:
# Type: Api
# Properties:
# Path: /b2b-channels/import-orders
# Method: GET
# RestApiId: !Ref B2bCAPIDev

如何确定将子堆栈定义到主堆栈中的正确方法?

最佳答案

TemplateURL 应写为 S3 中的 URL,因此 https://...

this doc ,写为:

TemplateURL: https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template

关于amazon-web-services - AWS cloudformation 嵌套堆栈因模板 URL 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70027685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com