繁体   English   中英

如何在 CDK (AWS) 中将安全组添加到 VPC 端点

[英]How to add security group to VPC Endpoint in CDK (AWS)

我的 AWS 账户上有一个现有的 VPC 终端节点。 当我部署我的 CDK 堆栈时,我需要以某种方式向该 VPC 端点添加一个安全组,以便我的服务器能够与另一个网络上的 Redshift 集群通信。

我这样定义我的安全组:

const securityGroup = new ec2.SecurityGroup(this, "SecurityGroup", {
        vpc,
        allowAllOutbound: true,
    });

如何将该安全组添加到 VPC 终端节点? 我知道端点 ID,但不知何故无法弄清楚如何做到这一点。 我试图通过 ID 获取 VPC 端点并使用安全组

您需要使用ec2.InterfaceVpcEndpoint来创建一个新的 Vpc 端点并允许您添加安全组 ID。 这里借用它可能看起来像这样:

    ec2.InterfaceVpcEndpoint(
        self,
        "VPCe - Redshift",
        service=ec2.InterfaceVpcEndpointService("redshift.amazonaws.com")
        ),
        private_dns_enabled=True,
        vpc=self.vpc,
        security_groups=[securityGroup],
    )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM