我正在使用Pulumi和Python创建一个GCP存储桶和聚合日志接收器。要创建接收器,我需要Pulumi提供的bucket id的值
bucket = storage.Bucket(resource_name=bucket_name,
location="us-central1",
storage_class="REGIONAL",
uniform_bucket_level_access=True)
# destination value is needed to create the logging sink.
destination = Output.all(bucket.id).apply(lambda l: f"storage.googleapis.com/{l[0]}")
print(destination)
我希望得到类似于"storage.googleapis.com/bucket_id"
的目标变量的打印输出。相反,我得到了
<pulumi.output.Output object at 0x10c39ae80>
。我还尝试使用Pulumi-concat方法,如Pulumi docs中所述
destination = Output.concat("storage.googleapis.com/", bucket.id)
print(destination)
这将返回相同的<pulumi.output.Output object at 0x10c39ae80>
,而不是预期的字符串
如有任何建议,将不胜感激
无法打印
Output
,因为输出是延迟值的容器,在调用print
时该值不可用。相反,请尝试将该值导出为堆栈输出如果确实要打印它,请尝试在
apply
内执行此操作:顺便说一下,您的第一个代码片段可以简化为
但是
concat
实际上更简单相关问题 更多 >
编程相关推荐