class Port
This page is available in another version. Click here for the v2 documentation.
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.Port |
![]() | software.amazon.awscdk.services.ec2.Port |
![]() | aws_cdk.aws_ec2.Port |
![]() | @aws-cdk/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 project = new codebuild.Project(this, 'MyProject', {
vpc: vpc,
buildSpec: codebuild.BuildSpec.fromObject({
// ...
}),
});
project.connections.allowTo(loadBalancer, ec2.Port.tcp(443));
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 | 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 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.