aws-cdk - 创建 ALB 时是否可以添加多个安全组
问题描述
ALB CDK 具有返回安全组列表的属性,但在创建 ALB 时找不到添加安全组列表的方法。有什么解决方法吗?
解决方案
取决于您对安全组的用例。这可能有效 - 只需将它放在多个安全组的循环中:
myAlb.connections.addSecurityGroup(mySG)
编辑:
这其实是有票的。
这是一种解决方法:
myElb; // ELB created elsewhere in code
// get the CfnLoadBalancer from the LoadBalancer object
const cfnElb = myElb.node.defaultChild as elb.CfnLoadBalancer
// View SG list before the addition
console.log(cfnAdminELB.securityGroups)
// SecurityGroups can be 'undefined' need to check so that you don't get a warning
if (cfnElb.securityGroups){
cfnElb.securityGroups.push(mySecurityGroup.securityGroupId)
}
// Verify the token is added
console.log(cfnAdminELB.securityGroups)
理论上,如果您想摆脱默认 CDK 创建的内容,您也可以从 cfnElb.securityGroups 列表中删除内容。
推荐阅读
- flutter - 如何处理飞镖上的原始字节?
- python - 使用 BeautifulSoup 的多个 URL 的错误请求
- javascript - 视频结束后 Java Script Auto Next Page
- video.js - videojs:如何在“cuechange”上获取字幕的实际文本
- react-native - 在 Android 上的 React Native 中使用 Axios 上传图片
- javascript - laravel如何在highcharts饼图中添加动态数据
- excel - 打印时更新的 Excel 中的页码
- ios - 从 Firebase 查询数据并写入 UITextfield
- java - 如何做一组通用值?
- java - 如何让 android XML 或 Kotlin 按钮将我带到我在 XML 中的其他活动?