简体   繁体   English

Python AWS CDK 资源已存在错误

[英]Python AWS CDK resource already exists error

I'm trying to create a canary deployment using the Python sdk for AWS CDK.我正在尝试使用 AWS CDK 的 Python sdk 创建金丝雀部署。 This is the pertinent part of the code:这是代码的相关部分:

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')
    )

I'm getting this error, even when I check that there's no other canary created:即使我检查没有创建其他金丝雀,我也会收到此错误:

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

As I said, I already checked in the console for the existence of other canary (there's none), and I destroy the created stack before trying again.正如我所说,我已经在控制台中检查了是否存在其他金丝雀(没有),我在重试之前销毁了创建的堆栈。

Any ideas?有任何想法吗?

I've had success with similar situations by adding a random string to the name of the resource (using Date.Now() works in TypeScript or the equivalent in Python).通过在资源名称中添加随机字符串(在 TypeScript 中使用 Date.Now() 或 Python 中的等效项),我在类似情况下取得了成功。 This forces CloudFormation to delete, and re-create the resource on each deploy.这会强制 CloudFormation 在每次部署时删除并重新创建资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM