Class: AWSCDK::EC2::Connections

Inherits:
Jsii::Object
  • Object
show all
Includes:
IConnectable
Defined in:
ec2/connections.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = nil) ⇒ Connections

Returns a new instance of Connections.

Parameters:



18
19
20
21
22
# File 'ec2/connections.rb', line 18

def initialize(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::EC2::ConnectionsProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkNvbm5lY3Rpb25zUHJvcHMifQ==")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(props)
end

Class Method Details

.jsii_overridable_methodsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'ec2/connections.rb', line 24

def self.jsii_overridable_methods
  {
    :connections => { kind: :property, name: "connections", is_optional: false },
    :security_groups => { kind: :property, name: "securityGroups", is_optional: false },
    :default_port => { kind: :property, name: "defaultPort", is_optional: true },
    :add_security_group => { kind: :method, name: "addSecurityGroup", is_optional: false },
    :allow_default_port_from => { kind: :method, name: "allowDefaultPortFrom", is_optional: false },
    :allow_default_port_from_any_ipv4 => { kind: :method, name: "allowDefaultPortFromAnyIpv4", is_optional: false },
    :allow_default_port_internally => { kind: :method, name: "allowDefaultPortInternally", is_optional: false },
    :allow_default_port_to => { kind: :method, name: "allowDefaultPortTo", is_optional: false },
    :allow_from => { kind: :method, name: "allowFrom", is_optional: false },
    :allow_from_any_ipv4 => { kind: :method, name: "allowFromAnyIpv4", is_optional: false },
    :allow_internally => { kind: :method, name: "allowInternally", is_optional: false },
    :allow_to => { kind: :method, name: "allowTo", is_optional: false },
    :allow_to_any_ipv4 => { kind: :method, name: "allowToAnyIpv4", is_optional: false },
    :allow_to_default_port => { kind: :method, name: "allowToDefaultPort", is_optional: false },
  }
end

Instance Method Details

#add_security_group(*security_groups) ⇒ void

This method returns an undefined value.

Add a security group to the list of security groups managed by this object.

Parameters:



66
67
68
69
70
71
# File 'ec2/connections.rb', line 66

def add_security_group(*security_groups)
  security_groups.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklTZWN1cml0eUdyb3VwIn0=")), "securityGroups[#{index}]")
  end
  jsii_call_method("addSecurityGroup", [*security_groups])
end

#allow_default_port_from(other, description = nil) ⇒ void

This method returns an undefined value.

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:



80
81
82
83
84
# File 'ec2/connections.rb', line 80

def allow_default_port_from(other, description = nil)
  Jsii::Type.check_type(other, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklDb25uZWN0YWJsZSJ9")), "other")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowDefaultPortFrom", [other, description])
end

#allow_default_port_from_any_ipv4(description = nil) ⇒ void

This method returns an undefined value.

Allow default connections from all IPv4 ranges.

Parameters:

  • description (String, nil) (defaults to: nil)


90
91
92
93
# File 'ec2/connections.rb', line 90

def allow_default_port_from_any_ipv4(description = nil)
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowDefaultPortFromAnyIpv4", [description])
end

#allow_default_port_internally(description = nil) ⇒ void

This method returns an undefined value.

Allow hosts inside the security group to connect to each other.

Parameters:

  • description (String, nil) (defaults to: nil)


99
100
101
102
# File 'ec2/connections.rb', line 99

def allow_default_port_internally(description = nil)
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowDefaultPortInternally", [description])
end

#allow_default_port_to(other, description = nil) ⇒ void

This method returns an undefined value.

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:



111
112
113
114
115
# File 'ec2/connections.rb', line 111

def allow_default_port_to(other, description = nil)
  Jsii::Type.check_type(other, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklDb25uZWN0YWJsZSJ9")), "other")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowDefaultPortTo", [other, description])
end

#allow_from(other, port_range, description = nil) ⇒ void

This method returns an undefined value.

Allow connections from the peer on the given port.

Parameters:



123
124
125
126
127
128
# File 'ec2/connections.rb', line 123

def allow_from(other, port_range, description = nil)
  Jsii::Type.check_type(other, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklDb25uZWN0YWJsZSJ9")), "other")
  Jsii::Type.check_type(port_range, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlBvcnQifQ==")), "portRange")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowFrom", [other, port_range, description])
end

#allow_from_any_ipv4(port_range, description = nil) ⇒ void

This method returns an undefined value.

Allow from any IPv4 ranges.

Parameters:



135
136
137
138
139
# File 'ec2/connections.rb', line 135

def allow_from_any_ipv4(port_range, description = nil)
  Jsii::Type.check_type(port_range, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlBvcnQifQ==")), "portRange")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowFromAnyIpv4", [port_range, description])
end

#allow_internally(port_range, description = nil) ⇒ void

This method returns an undefined value.

Allow hosts inside the security group to connect to each other on the given port.

Parameters:



146
147
148
149
150
# File 'ec2/connections.rb', line 146

def allow_internally(port_range, description = nil)
  Jsii::Type.check_type(port_range, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlBvcnQifQ==")), "portRange")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowInternally", [port_range, description])
end

#allow_to(other, port_range, description = nil) ⇒ void

This method returns an undefined value.

Allow connections to the peer on the given port.

Parameters:



158
159
160
161
162
163
# File 'ec2/connections.rb', line 158

def allow_to(other, port_range, description = nil)
  Jsii::Type.check_type(other, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklDb25uZWN0YWJsZSJ9")), "other")
  Jsii::Type.check_type(port_range, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlBvcnQifQ==")), "portRange")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowTo", [other, port_range, description])
end

#allow_to_any_ipv4(port_range, description = nil) ⇒ void

This method returns an undefined value.

Allow to all IPv4 ranges.

Parameters:



170
171
172
173
174
# File 'ec2/connections.rb', line 170

def allow_to_any_ipv4(port_range, description = nil)
  Jsii::Type.check_type(port_range, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlBvcnQifQ==")), "portRange")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowToAnyIpv4", [port_range, description])
end

#allow_to_default_port(other, description = nil) ⇒ void

This method returns an undefined value.

Allow connections to the security group on their default port.

Parameters:



181
182
183
184
185
# File 'ec2/connections.rb', line 181

def allow_to_default_port(other, description = nil)
  Jsii::Type.check_type(other, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklDb25uZWN0YWJsZSJ9")), "other")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless description.nil?
  jsii_call_method("allowToDefaultPort", [other, description])
end

#connectionsAWSCDK::EC2::Connections

The network connections associated with this resource.

Returns:

  • (AWSCDK::EC2::Connections)


46
47
48
# File 'ec2/connections.rb', line 46

def connections()
  jsii_get_property("connections")
end

#default_portAWSCDK::EC2::Port?

The default port configured for this connection peer, if available.

Returns:



58
59
60
# File 'ec2/connections.rb', line 58

def default_port()
  jsii_get_property("defaultPort")
end

#security_groupsArray<AWSCDK::EC2::ISecurityGroup>

Returns:



51
52
53
# File 'ec2/connections.rb', line 51

def security_groups()
  jsii_get_property("securityGroups")
end