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 loadBalancer: elbv2.ApplicationLoadBalancer;
const vpc = new ec2.Vpc(this, 'MyVPC');
const fleet = new codebuild.Fleet(this, 'MyProject', {
computeType: codebuild.FleetComputeType.MEDIUM,
environmentType: codebuild.EnvironmentType.LINUX_CONTAINER,
baseCapacity: 1,
vpc,
});
fleet.connections.allowTo(loadBalancer, ec2.Port.tcp(443));
const project = new codebuild.Project(this, 'MyProject', {
environment: {
fleet,
},
buildSpec: codebuild.BuildSpec.fromObject({
// ...
}),
// Trying to configure a project-level VPC is an error, because this project
// runs on the Fleet created above.
// vpc,
});
Initializer
new Port(props: PortProps)
Parameters
- props
PortProps
Properties
| Name | Type | Description |
|---|---|---|
| can | boolean | Whether the rule containing this port range can be inlined into a securitygroup or not. |
| static DNS_TCP | Port | Well-known DNS port (TCP 53). |
| static DNS_UDP | Port | Well-known DNS port (UDP 53). |
| static HTTP | Port | Well-known HTTP port (TCP 80). |
| static HTTPS | Port | Well-known HTTPS port (TCP 443). |
| static IMAP | Port | Well-known IMAP port (TCP 143). |
| static IMAPS | Port | Well-known IMAPS port (TCP 993). |
| static LDAP | Port | Well-known LDAP port (TCP 389). |
| static MSSQL | Port | Well-known Microsoft SQL Server port (TCP 1433). |
| static MYSQL_AURORA | Port | Well-known MySQL and Aurora port (TCP 3306). |
| static NFS | Port | Well-known NFS port (TCP 2049). |
| static POP3 | Port | Well-known POP3 port (TCP 110). |
| static POP3 | Port | Well-known POP3S port (TCP 995). |
| static POSTGRES | Port | Well-known PostgreSQL port (TCP 5432). |
| static RDP | Port | Well-known Microsoft Remote Desktop Protocol port (TCP 3389). |
| static SMB | Port | Well-known SMB port (TCP 445). |
| static SMTP | Port | Well-known SMTP port (TCP 25). |
| static SSH | Port | Well-known SSH port (TCP 22). |
canInlineRule
Type:
boolean
Whether the rule containing this port range can be inlined into a securitygroup or not.
static DNS_TCP
Type:
Port
Well-known DNS port (TCP 53).
static DNS_UDP
Type:
Port
Well-known DNS port (UDP 53).
static HTTP
Type:
Port
Well-known HTTP port (TCP 80).
static HTTPS
Type:
Port
Well-known HTTPS port (TCP 443).
static IMAP
Type:
Port
Well-known IMAP port (TCP 143).
static IMAPS
Type:
Port
Well-known IMAPS port (TCP 993).
static LDAP
Type:
Port
Well-known LDAP port (TCP 389).
static MSSQL
Type:
Port
Well-known Microsoft SQL Server port (TCP 1433).
static MYSQL_AURORA
Type:
Port
Well-known MySQL and Aurora port (TCP 3306).
static NFS
Type:
Port
Well-known NFS port (TCP 2049).
static POP3
Type:
Port
Well-known POP3 port (TCP 110).
static POP3S
Type:
Port
Well-known POP3S port (TCP 995).
static POSTGRES
Type:
Port
Well-known PostgreSQL port (TCP 5432).
static RDP
Type:
Port
Well-known Microsoft Remote Desktop Protocol port (TCP 3389).
static SMB
Type:
Port
Well-known SMB port (TCP 445).
static SMTP
Type:
Port
Well-known SMTP port (TCP 25).
static SSH
Type:
Port
Well-known SSH port (TCP 22).
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. |
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
A single AH port.
static allIcmp()
public static allIcmp(): Port
Returns
All ICMP traffic.
static allIcmpV6()
public static allIcmpV6(): Port
Returns
All ICMPv6 traffic.
static allTcp()
public static allTcp(): Port
Returns
Any TCP traffic.
static allTraffic()
public static allTraffic(): Port
Returns
All traffic.
static allUdp()
public static allUdp(): Port
Returns
Any UDP traffic.
static esp()
public static esp(): Port
Returns
A single ESP port.
static icmpPing()
public static icmpPing(): Port
Returns
ICMP ping (echo) traffic.
static icmpType(type)
public static icmpType(type: number): Port
Parameters
- type
number
Returns
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
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.
static tcpRange(startPort, endPort)
public 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.
static udpRange(startPort, endPort)
public static udpRange(startPort: number, endPort: number): Port
Parameters
- startPort
number - endPort
number
Returns
A UDP port range.

.NET
Go
Java
Python
TypeScript (