1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 看起来需要将基础安全组ID作为输出进行导出。
//将安全组ID导出, 以便相关的堆栈可以通过CDK From方法引用并检索原始安全组。 var outputName = StackHelper.SharedExports.DbSecurityGroupId(this.StackName); new CfnOutput(this, outputName, new CfnOutputProps { ExportName = outputName, Value = this.DbSecurityGroup.SecurityGroupId, Description = dbSgName + " 安全组ID."
});
然后, 依赖的应用程序堆栈导入安全组ID并自行检索安全组,而不是直接引用代码。
var dbSecurityGroupId = Fn.ImportValue(StackHelper.SharedExports.DbSecurityGroupId(this._dataStack.StackName)); var dbSecurityGroup = SecurityGroup.FromSecurityGroupId(this, "dbSg", dbSecurityGroupId); dbSecurityGroup.AddIngressRule(this.AppSecurityGroup, Port.Tcp(3306), "允许来自app1的连接。");
这样,依赖的堆栈仅拥有(并添加)完整性规则到基础安全组,而基础堆栈不会知道或依赖于应用程序堆栈。
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前