Port Class
Interface for classes that provide the connection-specification parts of a security group rule.
Example
ts
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,
});
python
# load_balancer: elbv2.ApplicationLoadBalancer
vpc = ec2.Vpc(self, "MyVPC")
fleet = codebuild.Fleet(self, "MyProject",
compute_type=codebuild.FleetComputeType.MEDIUM,
environment_type=codebuild.EnvironmentType.LINUX_CONTAINER,
base_capacity=1,
vpc=vpc
)
fleet.connections.allow_to(load_balancer, ec2.Port.tcp(443))
project = codebuild.Project(self, "MyProject",
environment=codebuild.BuildEnvironment(
fleet=fleet
),
build_spec=codebuild.BuildSpec.from_object({})
)
java
ApplicationLoadBalancer loadBalancer;
Vpc vpc = new Vpc(this, "MyVPC");
Fleet fleet = Fleet.Builder.create(this, "MyProject")
.computeType(FleetComputeType.MEDIUM)
.environmentType(EnvironmentType.LINUX_CONTAINER)
.baseCapacity(1)
.vpc(vpc)
.build();
fleet.connections.allowTo(loadBalancer, Port.tcp(443));
Project project = Project.Builder.create(this, "MyProject")
.environment(BuildEnvironment.builder()
.fleet(fleet)
.build())
.buildSpec(BuildSpec.fromObject(Map.of()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
ApplicationLoadBalancer loadBalancer;
var vpc = new Vpc(this, "MyVPC");
var fleet = new Fleet(this, "MyProject", new FleetProps {
ComputeType = FleetComputeType.MEDIUM,
EnvironmentType = EnvironmentType.LINUX_CONTAINER,
BaseCapacity = 1,
Vpc = vpc
});
fleet.Connections.AllowTo(loadBalancer, Port.Tcp(443));
var project = new Project(this, "MyProject", new ProjectProps {
Environment = new BuildEnvironment {
Fleet = fleet
},
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> { })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var loadBalancer ApplicationLoadBalancer
vpc := ec2.NewVpc(this, jsii.String("MyVPC"))
fleet := codebuild.NewFleet(this, jsii.String("MyProject"), &FleetProps{
ComputeType: codebuild.FleetComputeType_MEDIUM,
EnvironmentType: codebuild.EnvironmentType_LINUX_CONTAINER,
BaseCapacity: jsii.Number(1),
Vpc: Vpc,
})
fleet.connections.AllowTo(loadBalancer, ec2.Port_Tcp(jsii.Number(443)))
project := codebuild.NewProject(this, jsii.String("MyProject"), &ProjectProps{
Environment: &BuildEnvironment{
Fleet: *Fleet,
},
BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
}),
})
Initializer
Properties
canInlineRulebooleancan_inline_ruleboolcanInlineRuleBooleanCanInlineRuleboolCanInlineRule*boolrequired#Whether the rule containing this port range can be inlined into a securitygroup or not.
Well-known Microsoft SQL Server port (TCP 1433).
Well-known MySQL and Aurora port (TCP 3306).
Well-known PostgreSQL port (TCP 5432).
Well-known Microsoft Remote Desktop Protocol port (TCP 3389).
Methods
ah(): Port // chainable@staticmethod def ah() -> Portpublic static Port ah()public static Port Ah()func Ah() Portstatic#A single AH port.
allIcmp(): Port // chainable@staticmethod def all_icmp() -> Portpublic static Port allIcmp()public static Port AllIcmp()func AllIcmp() Portstatic#All ICMP traffic.
allIcmpV6(): Port // chainable@staticmethod def all_icmp_v6() -> Portpublic static Port allIcmpV6()public static Port AllIcmpV6()func AllIcmpV6() Portstatic#All ICMPv6 traffic.
allTcp(): Port // chainable@staticmethod def all_tcp() -> Portpublic static Port allTcp()public static Port AllTcp()func AllTcp() Portstatic#Any TCP traffic.
allTraffic(): Port // chainable@staticmethod def all_traffic() -> Portpublic static Port allTraffic()public static Port AllTraffic()func AllTraffic() Portstatic#All traffic.
allUdp(): Port // chainable@staticmethod def all_udp() -> Portpublic static Port allUdp()public static Port AllUdp()func AllUdp() Portstatic#Any UDP traffic.
esp(): Port // chainable@staticmethod def esp() -> Portpublic static Port esp()public static Port Esp()func Esp() Portstatic#A single ESP port.
icmpPing(): Port // chainable@staticmethod def icmp_ping() -> Portpublic static Port icmpPing()public static Port IcmpPing()func IcmpPing() Portstatic#ICMP ping (echo) traffic.
icmpType(type: number): Port // chainable@staticmethod def icmp_type(type: int | float) -> Portpublic static Port icmpType(Number type)public static Port IcmpType(double type)func IcmpType(Type *float64) Portstatic#All codes for a single ICMP type.
icmpTypeAndCode(type: number, code: number): Port // chainable@staticmethod def icmp_type_and_code(type: int | float, code: int | float) -> Portpublic static Port icmpTypeAndCode(Number type, Number code)public static Port IcmpTypeAndCode(double type, double code)func IcmpTypeAndCode(Type *float64, Code *float64) Portstatic#A specific combination of ICMP type and code.
tcp(port: number): Port // chainable@staticmethod def tcp(port: int | float) -> Portpublic static Port tcp(Number port)public static Port Tcp(double port)func Tcp(Port *float64) Portstatic#A single TCP port.
tcpRange(startPort: number, endPort: number): Port // chainable@staticmethod def tcp_range(start_port: int | float, end_port: int | float) -> Portpublic static Port tcpRange(Number startPort, Number endPort)public static Port TcpRange(double startPort, double endPort)func TcpRange(StartPort *float64, EndPort *float64) Portstatic#A TCP port range.
toRuleJson(): anydef to_rule_json(self, ) -> Anypublic Object toRuleJson()public object ToRuleJson()func ToRuleJson() interface{}#Produce the ingress/egress rule JSON for the given connection.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#udp(port: number): Port // chainable@staticmethod def udp(port: int | float) -> Portpublic static Port udp(Number port)public static Port Udp(double port)func Udp(Port *float64) Portstatic#A single UDP port.
udpRange(startPort: number, endPort: number): Port // chainable@staticmethod def udp_range(start_port: int | float, end_port: int | float) -> Portpublic static Port udpRange(Number startPort, Number endPort)public static Port UdpRange(double startPort, double endPort)func UdpRange(StartPort *float64, EndPort *float64) Portstatic#A UDP port range.