AWS CDK를 사용하여 두 보안 그룹을 함께 연결하려면 어떻게해야합니까?
이것은 포트 443을 통해 IPv4 트래픽 수신을 허용하는 예입니다.
ec2SecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(443), 'Test rule', false)
이것은 문서에서 가져온 것입니다.
public addIngressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean): void
이것이 제가 생각 해낼 수있는 최선의 방법입니다 ( 'elbSecurityGroup'은 다른 보안 그룹입니다).
const p = Peer.anyIpv4()
p.connections.allowFrom(elbSecurityGroup.connections, Port.tcp(443))
ec2SecurityGroup.addIngressRule(p, Port.tcp(443), 'Test rule', false)
그러나 그것은 정말로 말이되지 않습니다. 피어를 초기화하는 더 좋은 방법이 있어야합니다. Typescript 말한다
'Peer'클래스의 생성자는 보호되며 클래스 선언 내에서만 액세스 할 수 있습니다.
내가 시도하면 :
const p = new Peer()
이는 SecurityGroups 또는 기타 Constructs의 '연결'에 직접 액세스하여 수행 할 수 있습니다.
ec2SecurityGroup.connections.allowFrom(elbSecurityGroup, Port.tcp(443), 'Application Load Balancer')
또는 EC2 인스턴스 객체에서 다른 EC2 인스턴스로 직접 :
ec2Instance1.connections.allowFrom(ec2Instance2, Port.tcp(4321), 'Inbound')
ec2Instance2.connections.allowTo(ec2Instance1, Port.tcp(4321), 'Outbound')
그러면 EC2 인스턴스에 연결된 CDK에 의해 생성 된 SecurityGroup이 생성 / 변경됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다