class Port
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.Port |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#Port |
Java | software.amazon.awscdk.services.ec2.Port |
Python | aws_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.instanceV2({
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
Port
Props
Properties
Name | Type | Description |
---|---|---|
can | boolean | Whether 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
Name | Description |
---|---|
to | Produce the ingress/egress rule JSON for the given connection. |
to | |
static ah() | A single AH port. |
static all | All ICMP traffic. |
static all | All ICMPv6 traffic. |
static all | Any TCP traffic. |
static all | All traffic. |
static all | Any UDP traffic. |
static esp() | A single ESP port. |
static icmp | ICMP ping (echo) traffic. |
static icmp | All codes for a single ICMP type. |
static icmp | A specific combination of ICMP type and code. |
static tcp(port) | A single TCP port. |
static tcp | A TCP port range. |
static udp(port) | A single UDP port. |
static udp | A UDP port range. |
RuleJson()
topublic toRuleJson(): any
Returns
any
Produce the ingress/egress rule JSON for the given connection.
String()
topublic toString(): string
Returns
string
static ah()
public static ah(): Port
Returns
A single AH port.
Icmp()
static allpublic static allIcmp(): Port
Returns
All ICMP traffic.
IcmpV6()
static allpublic static allIcmpV6(): Port
Returns
All ICMPv6 traffic.
Tcp()
static allpublic static allTcp(): Port
Returns
Any TCP traffic.
Traffic()
static allpublic static allTraffic(): Port
Returns
All traffic.
Udp()
static allpublic static allUdp(): Port
Returns
Any UDP traffic.
static esp()
public static esp(): Port
Returns
A single ESP port.
Ping()
static icmppublic static icmpPing(): Port
Returns
ICMP ping (echo) traffic.
Type(type)
static icmppublic static icmpType(type: number): Port
Parameters
- type
number
Returns
All codes for a single ICMP type.
TypeAndCode(type, code)
static icmppublic static icmpTypeAndCode(type: number, code: number): Port
Parameters
- type
number
- code
number
Returns
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
A single TCP port.
Range(startPort, endPort)
static tcppublic static tcpRange(startPort: number, endPort: number): Port
Parameters
- startPort
number
- endPort
number
Returns
A TCP port range.
static udp(port)
public static udp(port: number): Port
Parameters
- port
number
Returns
A single UDP port.
Range(startPort, endPort)
static udppublic static udpRange(startPort: number, endPort: number): Port
Parameters
- startPort
number
- endPort
number
Returns
A UDP port range.