使用这篇github帖子,我制作了一个Python代码片段:
vm_pipeline_qa = Stack.of(self).format_arn(
region="us-east-1",
service="codepipeline",
resource="pipeline",
account="111122223333",
resource_name="vm_pipeline_qa"
)
当前行为上面的代码片段创建了以下代码管道Arn:
arn:aws:codepipeline:us-east-1:111122223333:pipeline/vm_pipeline-
预期行为使用codepipeline控制台的有效代码管道将类似于以下内容:
arn:aws:codepipeline:us-east-1:111122223333:vm_pipeline-
这将产生预期的输出:
vm_pipeline_qa = Stack.of(self).format_arn(
account="111122223333",
region="us-east-1",
service="codepipeline",
resource="vm_pipeline_qa", # <- put the resource name into the resource slot
arn_format=cdk.ArnFormat.NO_RESOURCE_NAME, # <- omit the resource name slot
)
提示:account
和region
默认继承自Stack.of(self)
。