CDK Redis缓存CDK.Resource.isResource不是一个函数

2024-06-28 10:59:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下redis集群的CDK配置(用python),它是根据在线找到的示例构建的

Im对所有软件包使用最新版本(1.91.0)

  redis_subnet_group = elasticache.CfnSubnetGroup(
            self,
            "RedisSubnetGroup",
            description='Redis Subnet Group',
            subnet_ids=[subnet.subnet_id for subnet in vpc.private_subnets]
        )

        redis_security_group = ec2.SecurityGroup(self, "RedisSecurityGroup", vpc=vpc)

        redis = elasticache.CfnCacheCluster(
            self,
            "RedisCluster",
            engine='redis',
            cache_node_type="cache.t2.micro",
            num_cache_nodes=1,
            cluster_name="RedisCluster",
            cache_subnet_group_name=redis_subnet_group.ref,
            vpc_security_group_ids=[redis_security_group.security_group_id]
        )

当我运行synth或diff时,我得到以下错误

jsii.errors.JavaScriptError: 
  TypeError: cdk.Resource.isResource is not a function
      at new CfnDBInstance (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/jsii-kernel-bEHk2i/node_modules/@aws-cdk/aws-rds/lib/rds.generated.js:804:45)
      at new DatabaseInstance (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/jsii-kernel-bEHk2i/node_modules/@aws-cdk/aws-rds/lib/instance.js:356:26)
      at /private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:2720:58
      at Kernel._wrapSandboxCode (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:3148:24)
      at Kernel._create (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:2720:34)
      at Kernel.create (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:2461:29)
      at KernelHost.processRequest (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:9457:36)
      at KernelHost.run (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:9420:22)
      at Immediate._onImmediate (/private/var/folders/95/pb_k79ms1rnflkw2p8jl5mkm0000gn/T/tmpq6sjgwjd/lib/program.js:9421:46)
      at processImmediate (internal/timers.js:461:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 23, in <module>
    dev = EnvStack(
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/name/PycharmProjects/infa/env/__init__.py", line 27, in __init__
    saleor = SaleorBackend(
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/name/PycharmProjects/infa/env/saleor_backend.py", line 50, in __init__
    database = rds.DatabaseInstance(
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/aws_cdk/aws_rds/__init__.py", line 24573, in __init__
    jsii.create(DatabaseInstance, self, [scope, id, props])
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 265, in create
    response = self.provider.create(
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 348, in create
    return self._process.send(request, CreateResponse)
  File "/Users/name/.pyenv/versions/3.8.6/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 330, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: cdk.Resource.isResource is not a function

奇怪的是,它似乎引用了RDS实例(它已经存在了几个月了——这只是因为我添加了redis集群(如果我删除了RDS实例,那么它正确地引用了堆栈中的redis集群)


Tags: nameinpyredisvarliblinejs