Class: Convection::Model::Template::Resource::EC2SecurityGroup::Rule

Inherits:
Convection::Model::Template::Resource show all
Defined in:
lib/convection/model/template/resource/aws_ec2_security_group.rb

Overview

Examples:

Egress rule

ec2_security_group 'SuperSecretSecurityGroup' do
  # other properties...

  egress_rule :tcp, 443 do
    # The source CIDR block.
    destination '10.10.10.0/24'
  end
end

Ingress rule

ec2_security_group 'SuperSecretSecurityGroup' do
  # other properties...

  ingress_rule :tcp, 8080 do
    # The source security group ID.
    source_group stack.get('security-groups', 'HttpProxy')
  end
end

Instance Attribute Summary

Attributes inherited from Convection::Model::Template::Resource

#exist, #name, #parent, #properties, #resource_attributes, #template

Instance Method Summary collapse

Methods inherited from Convection::Model::Template::Resource

#as_attribute, attach_method, #deletion_policy, #depends_on, #initialize, properties, #property, property, #reference, type, #type, #with_output

Methods included from Mixin::Conditional

#condition, #render_condition

Methods included from DSL::Template::Resource

attach_resource

Methods included from DSL::Helpers

#camel_case, included, method_name, #screaming_snake_case, #snake_case

Methods included from DSL::IntrinsicFunctions

#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_not, #fn_or, #fn_ref, #get_att, #get_azs, #join, #select

Constructor Details

This class inherits a constructor from Convection::Model::Template::Resource

Instance Method Details

#renderObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/convection/model/template/resource/aws_ec2_security_group.rb', line 86

def render
  {
    'IpProtocol' => Mixin::Protocol.lookup(protocol)
  }.tap do |rule|
    rule['FromPort'] = from unless from.nil?
    rule['ToPort'] = to unless to.nil?
    rule['CidrIp'] = source unless source.nil?
    rule['CidrIp'] = destination unless destination.nil?
    rule['DestinationSecurityGroupId'] = destination_group unless destination_group.nil?
    rule['SourceSecurityGroupId'] = source_group unless source_group.nil?
    rule['SourceSecurityGroupOwnerId'] = source_group_owner unless source_group_owner.nil?
  end
end