Connections
- class aws_cdk.aws_ec2.Connections(*, default_port=None, peer=None, security_groups=None)
Bases:
object
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.
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ec2 as ec2 # peer: ec2.IPeer # port: ec2.Port # security_group: ec2.SecurityGroup connections = ec2.Connections( default_port=port, peer=peer, security_groups=[security_group] )
- Parameters
default_port (
Optional
[Port
]) – Default port range for initiating connections to and from this object. Default: - No default portpeer (
Optional
[IPeer
]) – Class that represents the rule by which others can connect to this connectable. This object is required, but will be derived from securityGroup if that is passed. Default: Derived from securityGroup if set.security_groups (
Optional
[Sequence
[ISecurityGroup
]]) – What securityGroup(s) this object is managing connections for. Default: No security groups
Methods
- add_security_group(*security_groups)
Add a security group to the list of security groups managed by this object.
- Parameters
security_groups (
ISecurityGroup
) –- Return type
None
- allow_default_port_from(other, description=None)
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 (
IConnectable
) –description (
Optional
[str
]) –
- Return type
None
- allow_default_port_from_any_ipv4(description=None)
Allow default connections from all IPv4 ranges.
- Parameters
description (
Optional
[str
]) –- Return type
None
- allow_default_port_internally(description=None)
Allow hosts inside the security group to connect to each other.
- Parameters
description (
Optional
[str
]) –- Return type
None
- allow_default_port_to(other, description=None)
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 (
IConnectable
) –description (
Optional
[str
]) –
- Return type
None
- allow_from(other, port_range, description=None)
Allow connections from the peer on the given port.
- Parameters
other (
IConnectable
) –port_range (
Port
) –description (
Optional
[str
]) –
- Return type
None
- allow_from_any_ipv4(port_range, description=None)
Allow from any IPv4 ranges.
- Parameters
port_range (
Port
) –description (
Optional
[str
]) –
- Return type
None
- allow_internally(port_range, description=None)
Allow hosts inside the security group to connect to each other on the given port.
- Parameters
port_range (
Port
) –description (
Optional
[str
]) –
- Return type
None
- allow_to(other, port_range, description=None)
Allow connections to the peer on the given port.
- Parameters
other (
IConnectable
) –port_range (
Port
) –description (
Optional
[str
]) –
- Return type
None
- allow_to_any_ipv4(port_range, description=None)
Allow to all IPv4 ranges.
- Parameters
port_range (
Port
) –description (
Optional
[str
]) –
- Return type
None
- allow_to_default_port(other, description=None)
Allow connections to the security group on their default port.
- Parameters
other (
IConnectable
) –description (
Optional
[str
]) –
- Return type
None
Attributes
- connections
The network connections associated with this resource.
- default_port
The default port configured for this connection peer, if available.
- security_groups