aws-cdk-lib.aws_ec2.Port

class Port

LanguageType name
.NETAmazon.CDK.AWS.EC2.Port
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#Port
Javasoftware.amazon.awscdk.services.ec2.Port
Pythonaws_cdk.aws_ec2.Port
TypeScript (source)aws-cdk-lib » aws_ec2 » Port

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

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 Port(props: PortProps)

Parameters

  • props PortProps

Properties

NameTypeDescription
canInlineRulebooleanWhether the rule containing this port range can be inlined into a securitygroup or not.

canInlineRule

Type: boolean

Whether the rule containing this port range can be inlined into a securitygroup or not.

Methods

NameDescription
toRuleJson()Produce the ingress/egress rule JSON for the given connection.
toString()
static ah()A single AH port.
static allIcmp()All ICMP traffic.
static allIcmpV6()All ICMPv6 traffic.
static allTcp()Any TCP traffic.
static allTraffic()All traffic.
static allUdp()Any UDP traffic.
static esp()A single ESP port.
static icmpPing()ICMP ping (echo) traffic.
static icmpType(type)All codes for a single ICMP type.
static icmpTypeAndCode(type, code)A specific combination of ICMP type and code.
static tcp(port)A single TCP port.
static tcpRange(startPort, endPort)A TCP port range.
static udp(port)A single UDP port.
static udpRange(startPort, endPort)A UDP port range.

toRuleJson()

public toRuleJson(): any

Returns

  • any

Produce the ingress/egress rule JSON for the given connection.


toString()

public toString(): string

Returns

  • string

static ah()

public static ah(): Port

Returns

  • Port

A single AH port.


static allIcmp()

public static allIcmp(): Port

Returns

  • Port

All ICMP traffic.


static allIcmpV6()

public static allIcmpV6(): Port

Returns

  • Port

All ICMPv6 traffic.


static allTcp()

public static allTcp(): Port

Returns

  • Port

Any TCP traffic.


static allTraffic()

public static allTraffic(): Port

Returns

  • Port

All traffic.


static allUdp()

public static allUdp(): Port

Returns

  • Port

Any UDP traffic.


static esp()

public static esp(): Port

Returns

  • Port

A single ESP port.


static icmpPing()

public static icmpPing(): Port

Returns

  • Port

ICMP ping (echo) traffic.


static icmpType(type)

public static icmpType(type: number): Port

Parameters

  • type number

Returns

  • Port

All codes for a single ICMP type.


static icmpTypeAndCode(type, code)

public static icmpTypeAndCode(type: number, code: number): Port

Parameters

  • type number
  • code number

Returns

  • Port

A specific combination of ICMP type and code.

See also: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml


static tcp(port)

public static tcp(port: number): Port

Parameters

  • port number

Returns

  • Port

A single TCP port.


static tcpRange(startPort, endPort)

public static tcpRange(startPort: number, endPort: number): Port

Parameters

  • startPort number
  • endPort number

Returns

  • Port

A TCP port range.


static udp(port)

public static udp(port: number): Port

Parameters

  • port number

Returns

  • Port

A single UDP port.


static udpRange(startPort, endPort)

public static udpRange(startPort: number, endPort: number): Port

Parameters

  • startPort number
  • endPort number

Returns

  • Port

A UDP port range.