AWS CDK子网选择 [英] AWS CDK subnet selections
本文介绍了AWS CDK子网选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在AWS CDK上创建负载均衡器.我熟悉云的形成.在创建负载均衡器的过程中,我要提供如下的子网.
Hi I am working on AWS CDK to create load balancer. I am familiar with cloud formation. During creation of Load Balancer I want to give subnets as below.
LB:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Tags:
-
Key: "Name"
Value: !Ref "AWS::StackName"
Subnets:
-
Fn::ImportValue: "infra-vpc-base::SubnetIdPrivateAz1"
-
Fn::ImportValue: "infra-vpc-base::SubnetIdPrivateAz2"
我尝试如下在cdk中创建LB.
I tried to create LB in cdk as below.
lb = elbv2.ApplicationLoadBalancer(
self, "LB",
load_balancer_name="Load Balancer CDK",
vpc = vpc,
internet_facing= False,
security_group= mws_vpc_sg_alb,
vpc_subnets= ???
)
在上面的代码vpc_subnets中,我想给出两个子网.在上面的代码中,vpc_subnets的类型为类型.optional[aws_cdk.aws_ec2.SubnetSelection] = none.
In the above code vpc_subnets I want to give two subnets. In the above code vpc_subnets is of type typing.optional[aws_cdk.aws_ec2.SubnetSelection]= none.
有人可以帮助我在AWS CDK中获得子网选择吗?
Can someone help me to get subnet selection in AWS CDK?
推荐答案
这是来自自动缩放组,但应该相同:
this is from an auto scaling group but should be the same:
vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType('PUBLIC'))
这篇关于AWS CDK子网选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文