我需要一种方法,以确保一些服务已经站起来,他们的URL格式在GCP之前,我制定了一个OpenAPI规范-使用替代。URL相对来说是动态的,因为这个环境每晚都会被破坏。
我有一个解决办法
import { helloWorldUrl } from './cloud-run/hello-world';
import { anotherHelloWorldUrl } from './cloud-run/another-hello-world-service';
import * as pulumi from '@pulumi/pulumi';
import * as fs from 'fs';
import * as Mustache from 'mustache';
pulumi.all([helloWorldUrl, anotherHelloWorldUrl])
.apply(([hello, another]) => {
let gatewayOpenAPI = fs.readFileSync('./api-gateway/open-api/gateway.yaml').toString();
gatewayOpenAPI = Mustache.render(gatewayOpenAPI, { helloWorldUrl: hello, anotherHelloWorld: another });
fs.writeFileSync(`./api-gateway/open-api/gateway-${pulumi.getStack()}.yaml`, gatewayOpenAPI);
// create api gateway infra here.
// cannot return outputs here :(
});但这不允许我设置输出。有什么更好的解决方案吗?
欢呼声KH
发布于 2021-12-09 15:54:59
如果您希望拥有严格的依赖关系顺序,则应该使用Pulumi组件资源。然后,您可以将URL作为组件资源的输入传递给组件资源,并访问该组件资源创建的任何输出。您还应该注意,它不允许在apply 方法的回调中创建任何资源。
您可能会发现以下示例有助于查看组件资源的运行情况:https://www.pulumi.com/registry/packages/aws/how-to-guides/s3-folder-component/
https://stackoverflow.com/questions/70242798
复制相似问题