# IPeer

Interface for classes that provide the peer-specification parts of a security group rule.

Extends: [IConnectable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IConnectable.html)
Implemented by: [PrefixList](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.PrefixList.html), [SecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SecurityGroup.html)
Obtainable from: [Peer.anyIpv4](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#anyipv4), [Peer.anyIpv6](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#anyipv6), [Peer.ipv4](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#ipv4), [Peer.ipv6](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#ipv6), [Peer.prefixList](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#prefixlist), [Peer.securityGroupId](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Peer.html#securitygroupid)
Used as argument in: [BastionHostLinux.allowSshAccessFrom](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.BastionHostLinux.html#allowsshaccessfrom), ISecurityGroup.addEgressRule, ISecurityGroup.addIngressRule
Returned by: [EndpointGroup.connectionsPeer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_globalaccelerator.EndpointGroup.html#connectionspeer)

- Source: [`aws-ec2/lib/peer.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ec2/lib/peer.ts#L77)
- Type last changed: v2.256.0 · 20 May 2026

## Properties

- `canInlineRule`: boolean — Whether the rule can be inlined into a SecurityGroup or not.

- `connections`: [Connections](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — The network connections associated with this resource.

- `uniqueId`: string — A unique identifier for this connection peer.

## Methods

- `toEgressRuleConfig(): EgressRuleConfig` — Produce the egress rule JSON for the given connection.

- `toIngressRuleConfig(): IngressRuleConfig` — Produce the ingress rule JSON for the given connection.
