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.84.0 (build 5404dcf)", date="2023-06-19T16:30:39.280Z") @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();
 
  • Constructor Details

    • Connections

      protected Connections(software.amazon.jsii.JsiiObjectRef objRef)
    • Connections

      protected Connections(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Connections

      @Stability(Stable) public Connections(@Nullable ConnectionsProps props)
      Parameters:
      props -
    • Connections

      @Stability(Stable) public Connections()
  • Method Details

    • addSecurityGroup

      @Stability(Stable) public void addSecurityGroup(@NotNull @NotNull ISecurityGroup... securityGroups)
      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

      @Stability(Stable) public void allowDefaultPortFrom(@NotNull IConnectable other)
      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

      @Stability(Stable) public void allowDefaultPortFromAnyIpv4(@Nullable String description)
      Allow default connections from all IPv4 ranges.

      Parameters:
      description -
    • allowDefaultPortFromAnyIpv4

      @Stability(Stable) public void allowDefaultPortFromAnyIpv4()
      Allow default connections from all IPv4 ranges.
    • allowDefaultPortInternally

      @Stability(Stable) public void allowDefaultPortInternally(@Nullable String description)
      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

      @Stability(Stable) public void allowDefaultPortTo(@NotNull IConnectable other)
      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

      @Stability(Stable) public void allowFrom(@NotNull IConnectable other, @NotNull Port portRange)
      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

      @Stability(Stable) public void allowFromAnyIpv4(@NotNull Port portRange)
      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

      @Stability(Stable) public void allowInternally(@NotNull Port portRange)
      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

      @Stability(Stable) public void allowTo(@NotNull IConnectable other, @NotNull Port portRange)
      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

      @Stability(Stable) public void allowToAnyIpv4(@NotNull Port portRange)
      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

      @Stability(Stable) public void allowToDefaultPort(@NotNull IConnectable other)
      Allow connections to the security group on their default port.

      Parameters:
      other - This parameter is required.
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      The network connections associated with this resource.
      Specified by:
      getConnections in interface IConnectable
    • getSecurityGroups

      @Stability(Stable) @NotNull public List<ISecurityGroup> getSecurityGroups()
    • getDefaultPort

      @Stability(Stable) @Nullable public Port getDefaultPort()
      The default port configured for this connection peer, if available.