我正在使用aws cdk中aws\u ec2.vpc的select\u subnets方法,使用subnet\u group\u name属性选择私有子网,如下代码片段所述:
from aws_cdk import core as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk import core
class SimpleCdkStack(cdk.Stack):
def __init__(self, scope: cdk.Construct, construct_id: str,**kwargs) -> None:
super().__init__(scope, construct_id,**kwargs)
subnets = ec2.Vpc.select_subnets(self,
subnet_group_name="private-subnet"
)
print("Subnet Ids: " + subnets.subnet_ids)
上述错误在执行过程中产生以下错误:
$ cdk diff
jsii.errors.JavaScriptError:
Error: Class @aws-cdk/core.Stack doesn't have a method 'selectSubnets'
at Kernel._typeInfoForMethod (/tmp/tmphu1erjw6/lib/program.js:8420:27)
at Kernel._findInvokeTarget (/tmp/tmphu1erjw6/lib/program.js:8340:33)
at Kernel.invoke (/tmp/tmphu1erjw6/lib/program.js:7966:44)
at KernelHost.processRequest (/tmp/tmphu1erjw6/lib/program.js:9479:36)
at KernelHost.run (/tmp/tmphu1erjw6/lib/program.js:9442:22)
at Immediate._onImmediate (/tmp/tmphu1erjw6/lib/program.js:9443:46)
at processImmediate (internal/timers.js:461:21)
我已经使用下面的命令安装了所需的软件包
$ pip install aws_cdk.aws_ec2
不知道我哪里出错了。
aws在这里明确提到了awsèec2.vpc类可用的方法
感谢您的帮助!
暂无答案!
目前还没有任何答案,快来回答吧!