如何使用 cloudformation 从一个 yaml 模板调用资源到另一个 yaml 模板?

问题描述 投票:0回答:1

我需要一些关于cloudformation模板的指导。

我有一个名为 test1.yaml在这里,我创建了一个IAM角色,叫做 S3角色.

现在我有另一个堆栈叫 test2.yaml在这里,我创建了一个管理策略来附加到现有的IAM角色。

现在我想调用 test1.yml 档案 S3角色test2.yml 管理策略的文件。

谁能帮我写一下脚本?

amazon-cloudformation
1个回答

0
投票

谁能帮我提供脚本。

显然,由于你的问题中的细节运气,它不可能提供任何脚本。但我可以提供一般的 psudo-code.

test1.yaml

你将不得不 出口 S3角色阿恩或名字

Resources:

  S3Role:
    Type: IAM::ROLE
    <rest of role definition>

Outputs:

  RoleArn:
     Value: !GetAtt  S3Role.Arn
     Exports:
        Name: RoleArn

test2.yml你将不得不 输入 角色导出的Arn(或名称)从 test1.yaml:


Resources:

  SomeResouce:
     Properties:
       Role: !ImportValue RoleArn

希望能帮到你

© www.soinside.com 2019 - 2024. All rights reserved.