class Peer
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.Peer |
Java | software.amazon.awscdk.services.ec2.Peer |
Python | aws_cdk.aws_ec2.Peer |
TypeScript (source) | @aws-cdk/aws-ec2 » Peer |
Peer object factories (to be used in Security Group management).
The static methods on this object can be used to create peer objects which represent a connection partner in Security Group rules.
Use this object if you need to represent connection partners using plain IP addresses, or a prefix list ID.
If you want to address a connection partner by Security Group, you can just
use the Security Group (or the construct that contains a Security Group)
directly, as it already implements IPeer
.
Example
declare const instanceType: ec2.InstanceType;
const provider = ec2.NatProvider.instance({
instanceType,
defaultAllowedTraffic: ec2.NatTrafficDirection.OUTBOUND_ONLY,
});
new ec2.Vpc(this, 'TheVPC', {
natGatewayProvider: provider,
});
provider.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/8'), ec2.Port.tcp(80));
Initializer
new Peer()
Methods
Name | Description |
---|---|
static any | Any IPv4 address. |
static any | Any IPv6 address. |
static ipv4(cidrIp) | Create an IPv4 peer from a CIDR. |
static ipv6(cidrIp) | Create an IPv6 peer from a CIDR. |
static prefix | A prefix list. |
static security | A security group ID. |
Ipv4()
static anypublic static anyIpv4(): IPeer
Returns
Any IPv4 address.
Ipv6()
static anypublic static anyIpv6(): IPeer
Returns
Any IPv6 address.
static ipv4(cidrIp)
public static ipv4(cidrIp: string): IPeer
Parameters
- cidrIp
string
Returns
Create an IPv4 peer from a CIDR.
static ipv6(cidrIp)
public static ipv6(cidrIp: string): IPeer
Parameters
- cidrIp
string
Returns
Create an IPv6 peer from a CIDR.
List(prefixListId)
static prefixpublic static prefixList(prefixListId: string): IPeer
Parameters
- prefixListId
string
Returns
A prefix list.
GroupId(securityGroupId, sourceSecurityGroupOwnerId?)
static securitypublic static securityGroupId(securityGroupId: string, sourceSecurityGroupOwnerId?: string): IPeer
Parameters
- securityGroupId
string
- sourceSecurityGroupOwnerId
string
Returns
A security group ID.