【发布时间】:2020-08-09 02:46:25
【问题描述】:
TL;DR. 我想通过本地 Pulumi 堆栈保存将先前堆栈的输出准备到较新的堆栈中。例如,在之前创建的 VPC/子网中创建 AWS Fargate ECS 集群。如何在 Python 中做到这一点?
我已经创建了devPulumi 堆栈,应用代码:
$ mkdir pulumi-infra-az
$ pulumi login --local
$ pulumi stack init dev
得到这样的Outputs:
...
Outputs:
pulumi-private-subnet-ids: [
[0]: "subnet-0dcbaabe273db8feb"
[1]: "subnet-08c63207611c6bae2"
[2]: "subnet-00fa346a71a323551"
]
pulumi-public-subnet-ids : [
[0]: "subnet-02c50846690f2cd70"
[1]: "subnet-06282506863db7ac1"
[2]: "subnet-0cfae8a4f5e4fc03c"
]
pulumi-vpc-id : "vpc-0767f0d49e3a59d42"
Resources:
~ 3 updated
22 unchanged
Duration: 10s
Permalink: file:///root/.pulumi/stacks/dev.json
...
正如您在此处看到的,我正在使用本地堆栈放置 /root/.pulumi/stacks/dev.json。到目前为止,一切都很好。现在在其他目录中,我想创建 Fargate 集群描述:
$ mkdir pulumi-ecs-fargate
$ pulumi stack init dev-ecs # by the way can I use the same `dev` stack name here?
这里我需要读取之前创建的pulumi-private-subnet-ids、pulumi-public-subnet-ids、pulumi-vpc-id 输出值?如何正确地做到这一点?
我只找到了https://app.pulumi.com 后端示例:
https://www.pulumi.com/docs/intro/concepts/organizing-stacks-projects/#inter-stack-dependencies
https://www.pulumi.com/docs/intro/concepts/programming-model/#stack-references
https://www.pulumi.com/docs/tutorials/aws/aws-py-stackreference/
谁能提供本地或 AWS s3 示例如何读取其他堆栈/目录中的输出?
【问题讨论】:
标签: python amazon-web-services amazon-s3 infrastructure-as-code pulumi