Is there a way to link two security groups together using the AWS CDK?
For example, allowing IPv4 traffic ingress via port 443:
ec2SecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(443), 'Test rule', false)
This is an excerpt from the documentation:
public addIngressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean): void
I attempted this approach (where 'elbSecurityGroup' represents another security group):
const p = Peer.anyIpv4()
p.connections.allowFrom(elbSecurityGroup.connections, Port.tcp(443))
ec2SecurityGroup.addIngressRule(p, Port.tcp(443), 'Test rule', false)
Unfortunately, it seems illogical. There must be a more effective way of initializing the Peer. According to TypeScript:
Constructor of class 'Peer' is protected and only accessible within the class declaration.
Even attempting to create a new instance like this yields an error:
const p = new Peer()