Show / Hide Table of Contents

Class Peer

Peer object factories (to be used in Security Group management).

Inheritance
object
Peer
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Peer : DeputyBase
Syntax (vb)
Public Class Peer Inherits DeputyBase
Remarks

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.

ExampleMetadata: infused

Examples
var natGatewayProvider = NatProvider.InstanceV2(new NatInstanceProps {
                 InstanceType = new InstanceType("t3.small"),
                 DefaultAllowedTraffic = NatTrafficDirection.NONE
             });
             var vpc = new Vpc(this, "Vpc", new VpcProps { NatGatewayProvider = natGatewayProvider });

             var securityGroup = new SecurityGroup(this, "SecurityGroup", new SecurityGroupProps {
                 Vpc = vpc,
                 AllowAllOutbound = false
             });
             securityGroup.AddEgressRule(Peer.AnyIpv4(), Port.Tcp(443));
             for (var gatewayInstance in natGatewayProvider.GatewayInstances)
             {
                 gatewayInstance.AddSecurityGroup(securityGroup);
             }

Synopsis

Constructors

Peer()

Peer object factories (to be used in Security Group management).

Methods

AnyIpv4()

Any IPv4 address.

AnyIpv6()

Any IPv6 address.

Ipv4(string)

Create an IPv4 peer from a CIDR.

Ipv6(string)

Create an IPv6 peer from a CIDR.

PrefixList(string)

A prefix list.

SecurityGroupId(string, string?)

A security group ID.

Constructors

Peer()

Peer object factories (to be used in Security Group management).

public Peer()
Remarks

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.

ExampleMetadata: infused

Examples
var natGatewayProvider = NatProvider.InstanceV2(new NatInstanceProps {
                 InstanceType = new InstanceType("t3.small"),
                 DefaultAllowedTraffic = NatTrafficDirection.NONE
             });
             var vpc = new Vpc(this, "Vpc", new VpcProps { NatGatewayProvider = natGatewayProvider });

             var securityGroup = new SecurityGroup(this, "SecurityGroup", new SecurityGroupProps {
                 Vpc = vpc,
                 AllowAllOutbound = false
             });
             securityGroup.AddEgressRule(Peer.AnyIpv4(), Port.Tcp(443));
             for (var gatewayInstance in natGatewayProvider.GatewayInstances)
             {
                 gatewayInstance.AddSecurityGroup(securityGroup);
             }

Methods

AnyIpv4()

Any IPv4 address.

public static IPeer AnyIpv4()
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

AnyIpv6()

Any IPv6 address.

public static IPeer AnyIpv6()
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

Ipv4(string)

Create an IPv4 peer from a CIDR.

public static IPeer Ipv4(string cidrIp)
Parameters
cidrIp string
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

Ipv6(string)

Create an IPv6 peer from a CIDR.

public static IPeer Ipv6(string cidrIp)
Parameters
cidrIp string
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

PrefixList(string)

A prefix list.

public static IPeer PrefixList(string prefixListId)
Parameters
prefixListId string
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

SecurityGroupId(string, string?)

A security group ID.

public static IPeer SecurityGroupId(string securityGroupId, string? sourceSecurityGroupOwnerId = null)
Parameters
securityGroupId string
sourceSecurityGroupOwnerId string
Returns

IPeer

Remarks

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.

ExampleMetadata: infused

Back to top Generated by DocFX