gpt4 book ai didi

Python AWS CDK 资源已存在错误

转载 作者:行者123 更新时间:2023-12-05 07:03:56 24 4
gpt4 key购买 nike

我正在尝试使用 AWS CDK 的 Python sdk 创建金丝雀部署。这是代码的相关部分:

canary = CfnCanary(
scope=self,
id='canary',
execution_role_arn=canary_execution_role.role_arn,
name='canary-example',
run_config=CfnCanary.RunConfigProperty(timeout_in_seconds=1),
runtime_version='syn-1.0',
schedule=CfnCanary.ScheduleProperty(duration_in_seconds='5', expression='rate(0 minute)'),
artifact_s3_location=f's3://{bucket.bucket_name}',
start_canary_after_creation=False,
code=CfnCanary.CodeProperty(s3_bucket='s3://canary-script-002', handler='handler.handler', s3_key='handler.handler')
)

即使我检查没有创建其他金丝雀,我也会收到此错误:

Resource of type 'AWS::Synthetics::Canary' with identifier '{"/properties/Name":"canary-example"}' already exists.

正如我所说,我已经在控制台中检查了是否存在其他金丝雀(没有),并且在重试之前销毁了创建的堆栈。

有什么想法吗?

最佳答案

通过向资源名称添加随机字符串(使用 Date.Now() 在 TypeScript 中工作或在 Python 中等效),我已经成功解决了类似的情况。这会强制 CloudFormation 在每次部署时删除并重新创建资源。

关于Python AWS CDK 资源已存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63073474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com