Class Connections
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.Connections
- All Implemented Interfaces:
IConnectable,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)",
date="2025-10-24T13:34:36.710Z")
@Stability(Stable)
public class Connections
extends software.amazon.jsii.JsiiObject
implements IConnectable
Manage the allowed network connections for constructs with Security Groups.
Security Groups can be thought of as a firewall for network-connected devices. This class makes it easy to allow network connections to and from security groups, and between security groups individually. When establishing connectivity between security groups, it will automatically add rules in both security groups
This object can manage one or more security groups.
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
IPeer peer;
Port port;
SecurityGroup securityGroup;
Connections connections = Connections.Builder.create()
.defaultPort(port)
.peer(peer)
.securityGroups(List.of(securityGroup))
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IConnectable
IConnectable.Jsii$Default, IConnectable.Jsii$Proxy -
Constructor Summary
ConstructorsModifierConstructorDescriptionConnections(ConnectionsProps props) protectedConnections(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedConnections(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSecurityGroup(ISecurityGroup... securityGroups) Add a security group to the list of security groups managed by this object.voidallowDefaultPortFrom(IConnectable other) Allow connections from the peer on our default port.voidallowDefaultPortFrom(IConnectable other, String description) Allow connections from the peer on our default port.voidAllow default connections from all IPv4 ranges.voidallowDefaultPortFromAnyIpv4(String description) Allow default connections from all IPv4 ranges.voidAllow hosts inside the security group to connect to each other.voidallowDefaultPortInternally(String description) Allow hosts inside the security group to connect to each other.voidallowDefaultPortTo(IConnectable other) Allow connections from the peer on our default port.voidallowDefaultPortTo(IConnectable other, String description) Allow connections from the peer on our default port.voidallowFrom(IConnectable other, Port portRange) Allow connections from the peer on the given port.voidallowFrom(IConnectable other, Port portRange, String description) Allow connections from the peer on the given port.voidallowFromAnyIpv4(Port portRange) Allow from any IPv4 ranges.voidallowFromAnyIpv4(Port portRange, String description) Allow from any IPv4 ranges.voidallowInternally(Port portRange) Allow hosts inside the security group to connect to each other on the given port.voidallowInternally(Port portRange, String description) Allow hosts inside the security group to connect to each other on the given port.voidallowTo(IConnectable other, Port portRange) Allow connections to the peer on the given port.voidallowTo(IConnectable other, Port portRange, String description) Allow connections to the peer on the given port.voidallowToAnyIpv4(Port portRange) Allow to all IPv4 ranges.voidallowToAnyIpv4(Port portRange, String description) Allow to all IPv4 ranges.voidallowToDefaultPort(IConnectable other) Allow connections to the security group on their default port.voidallowToDefaultPort(IConnectable other, String description) Allow connections to the security group on their default port.The network connections associated with this resource.The default port configured for this connection peer, if available.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Connections
protected Connections(software.amazon.jsii.JsiiObjectRef objRef) -
Connections
protected Connections(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Connections
- Parameters:
props-
-
Connections
@Stability(Stable) public Connections()
-
-
Method Details
-
addSecurityGroup
Add a security group to the list of security groups managed by this object.- Parameters:
securityGroups- This parameter is required.
-
allowDefaultPortFrom
@Stability(Stable) public void allowDefaultPortFrom(@NotNull IConnectable other, @Nullable String description) Allow connections from the peer on our default port.Even if the peer has a default port, we will always use our default port.
- Parameters:
other- This parameter is required.description-
-
allowDefaultPortFrom
Allow connections from the peer on our default port.Even if the peer has a default port, we will always use our default port.
- Parameters:
other- This parameter is required.
-
allowDefaultPortFromAnyIpv4
Allow default connections from all IPv4 ranges.- Parameters:
description-
-
allowDefaultPortFromAnyIpv4
@Stability(Stable) public void allowDefaultPortFromAnyIpv4()Allow default connections from all IPv4 ranges. -
allowDefaultPortInternally
Allow hosts inside the security group to connect to each other.- Parameters:
description-
-
allowDefaultPortInternally
@Stability(Stable) public void allowDefaultPortInternally()Allow hosts inside the security group to connect to each other. -
allowDefaultPortTo
@Stability(Stable) public void allowDefaultPortTo(@NotNull IConnectable other, @Nullable String description) Allow connections from the peer on our default port.Even if the peer has a default port, we will always use our default port.
- Parameters:
other- This parameter is required.description-
-
allowDefaultPortTo
Allow connections from the peer on our default port.Even if the peer has a default port, we will always use our default port.
- Parameters:
other- This parameter is required.
-
allowFrom
@Stability(Stable) public void allowFrom(@NotNull IConnectable other, @NotNull Port portRange, @Nullable String description) Allow connections from the peer on the given port.- Parameters:
other- This parameter is required.portRange- This parameter is required.description-
-
allowFrom
Allow connections from the peer on the given port.- Parameters:
other- This parameter is required.portRange- This parameter is required.
-
allowFromAnyIpv4
@Stability(Stable) public void allowFromAnyIpv4(@NotNull Port portRange, @Nullable String description) Allow from any IPv4 ranges.- Parameters:
portRange- This parameter is required.description-
-
allowFromAnyIpv4
Allow from any IPv4 ranges.- Parameters:
portRange- This parameter is required.
-
allowInternally
@Stability(Stable) public void allowInternally(@NotNull Port portRange, @Nullable String description) Allow hosts inside the security group to connect to each other on the given port.- Parameters:
portRange- This parameter is required.description-
-
allowInternally
Allow hosts inside the security group to connect to each other on the given port.- Parameters:
portRange- This parameter is required.
-
allowTo
@Stability(Stable) public void allowTo(@NotNull IConnectable other, @NotNull Port portRange, @Nullable String description) Allow connections to the peer on the given port.- Parameters:
other- This parameter is required.portRange- This parameter is required.description-
-
allowTo
Allow connections to the peer on the given port.- Parameters:
other- This parameter is required.portRange- This parameter is required.
-
allowToAnyIpv4
@Stability(Stable) public void allowToAnyIpv4(@NotNull Port portRange, @Nullable String description) Allow to all IPv4 ranges.- Parameters:
portRange- This parameter is required.description-
-
allowToAnyIpv4
Allow to all IPv4 ranges.- Parameters:
portRange- This parameter is required.
-
allowToDefaultPort
@Stability(Stable) public void allowToDefaultPort(@NotNull IConnectable other, @Nullable String description) Allow connections to the security group on their default port.- Parameters:
other- This parameter is required.description-
-
allowToDefaultPort
Allow connections to the security group on their default port.- Parameters:
other- This parameter is required.
-
getConnections
The network connections associated with this resource.- Specified by:
getConnectionsin interfaceIConnectable
-
getSecurityGroups
-
getDefaultPort
The default port configured for this connection peer, if available.
-