Class: Banacle::AwsWrapper::Nacl
- Inherits:
-
Object
- Object
- Banacle::AwsWrapper::Nacl
- Defined in:
- lib/banacle/aws_wrapper/nacl.rb
Defined Under Namespace
Classes: EntryDuplicatedError, EntryNotFoundError, Result
Constant Summary collapse
- DEFAULT_RULE_NUMBER =
100
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#cidr_blocks ⇒ Object
readonly
Returns the value of attribute cidr_blocks.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#rule_numbers ⇒ Object
Returns the value of attribute rule_numbers.
-
#vpc_id ⇒ Object
readonly
Returns the value of attribute vpc_id.
Class Method Summary collapse
- .create_network_acl_ingress_entries(region:, vpc_id:, cidr_blocks:) ⇒ Object
- .delete_network_acl_entries(region:, vpc_id:, cidr_blocks:) ⇒ Object
Instance Method Summary collapse
- #create_network_acl_ingress_entries ⇒ Object
- #delete_network_acl_entries ⇒ Object
-
#initialize(region, vpc_id, cidr_blocks) ⇒ Nacl
constructor
A new instance of Nacl.
Constructor Details
#initialize(region, vpc_id, cidr_blocks) ⇒ Nacl
Returns a new instance of Nacl.
22 23 24 25 26 27 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 22 def initialize(region, vpc_id, cidr_blocks) @region = region @vpc_id = vpc_id @cidr_blocks = cidr_blocks @rule_numbers = ingress_rules.map(&:rule_number).sort end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
29 30 31 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 29 def action @action end |
#cidr_blocks ⇒ Object (readonly)
Returns the value of attribute cidr_blocks.
29 30 31 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 29 def cidr_blocks @cidr_blocks end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
29 30 31 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 29 def region @region end |
#rule_numbers ⇒ Object
Returns the value of attribute rule_numbers.
30 31 32 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 30 def rule_numbers @rule_numbers end |
#vpc_id ⇒ Object (readonly)
Returns the value of attribute vpc_id.
29 30 31 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 29 def vpc_id @vpc_id end |
Class Method Details
.create_network_acl_ingress_entries(region:, vpc_id:, cidr_blocks:) ⇒ Object
14 15 16 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 14 def self.create_network_acl_ingress_entries(region:, vpc_id:, cidr_blocks:) new(region, vpc_id, cidr_blocks).create_network_acl_ingress_entries end |
.delete_network_acl_entries(region:, vpc_id:, cidr_blocks:) ⇒ Object
18 19 20 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 18 def self.delete_network_acl_entries(region:, vpc_id:, cidr_blocks:) new(region, vpc_id, cidr_blocks).delete_network_acl_entries end |
Instance Method Details
#create_network_acl_ingress_entries ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 32 def create_network_acl_ingress_entries cidr_blocks.map do |cidr_block| begin rule_number = create_network_acl_ingress_entry(cidr_block) Result.new(cidr_block: cidr_block, status: true, rule_number: rule_number) rescue AwsWrapper::Error => e Result.new(cidr_block: cidr_block, status: false, error: e) end end end |
#delete_network_acl_entries ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/banacle/aws_wrapper/nacl.rb', line 43 def delete_network_acl_entries cidr_blocks.map do |cidr_block| begin rule_number = delete_network_acl_entry(cidr_block) Result.new(cidr_block: cidr_block, status: true, rule_number: rule_number) rescue AwsWrapper::Error => e Result.new(cidr_block: cidr_block, status: false, error: e) end end end |