Port

class aws_cdk.aws_ec2.Port(*, protocol, string_representation, from_port=None, to_port=None)

Bases: object

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

ExampleMetadata:

infused

Example:

# instance_type: ec2.InstanceType


provider = ec2.NatProvider.instance_v2(
    instance_type=instance_type,
    default_allowed_traffic=ec2.NatTrafficDirection.OUTBOUND_ONLY
)
ec2.Vpc(self, "TheVPC",
    nat_gateway_provider=provider
)
provider.connections.allow_from(ec2.Peer.ipv4("1.2.3.4/8"), ec2.Port.HTTP)
Parameters:
  • protocol (Protocol) – The protocol for the range.

  • string_representation (str) – String representation for this object.

  • from_port (Union[int, float, None]) – The starting port for the range. Default: - Not included in the rule

  • to_port (Union[int, float, None]) – The ending port for the range. Default: - Not included in the rule

Methods

to_rule_json()

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

Return type:

Any

to_string()
Return type:

str

Attributes

DNS_TCP = <aws_cdk.aws_ec2.Port object>
DNS_UDP = <aws_cdk.aws_ec2.Port object>
HTTP = <aws_cdk.aws_ec2.Port object>
HTTPS = <aws_cdk.aws_ec2.Port object>
IMAP = <aws_cdk.aws_ec2.Port object>
IMAPS = <aws_cdk.aws_ec2.Port object>
LDAP = <aws_cdk.aws_ec2.Port object>
MSSQL = <aws_cdk.aws_ec2.Port object>
MYSQL_AURORA = <aws_cdk.aws_ec2.Port object>
NFS = <aws_cdk.aws_ec2.Port object>
POP3 = <aws_cdk.aws_ec2.Port object>
POP3_S = <aws_cdk.aws_ec2.Port object>
POSTGRES = <aws_cdk.aws_ec2.Port object>
RDP = <aws_cdk.aws_ec2.Port object>
SMB = <aws_cdk.aws_ec2.Port object>
SMTP = <aws_cdk.aws_ec2.Port object>
SSH = <aws_cdk.aws_ec2.Port object>
can_inline_rule

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

Static Methods

classmethod ah()

A single AH port.

Return type:

Port

classmethod all_icmp()

All ICMP traffic.

Return type:

Port

classmethod all_icmp_v6()

All ICMPv6 traffic.

Return type:

Port

classmethod all_tcp()

Any TCP traffic.

Return type:

Port

classmethod all_traffic()

All traffic.

Return type:

Port

classmethod all_udp()

Any UDP traffic.

Return type:

Port

classmethod esp()

A single ESP port.

Return type:

Port

classmethod icmp_ping()

ICMP ping (echo) traffic.

Return type:

Port

classmethod icmp_type(type)

All codes for a single ICMP type.

Parameters:

type (Union[int, float]) –

Return type:

Port

classmethod icmp_type_and_code(type, code)

A specific combination of ICMP type and code.

Parameters:
  • type (Union[int, float]) –

  • code (Union[int, float]) –

See:

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

Return type:

Port

classmethod tcp(port)

A single TCP port.

Parameters:

port (Union[int, float]) –

Return type:

Port

classmethod tcp_range(start_port, end_port)

A TCP port range.

Parameters:
  • start_port (Union[int, float]) –

  • end_port (Union[int, float]) –

Return type:

Port

classmethod udp(port)

A single UDP port.

Parameters:

port (Union[int, float]) –

Return type:

Port

classmethod udp_range(start_port, end_port)

A UDP port range.

Parameters:
  • start_port (Union[int, float]) –

  • end_port (Union[int, float]) –

Return type:

Port