Sha256: fd300cb2ded5a43327811d541f25508ab052789b7c80ca4947b680a87b4e6f3a

Contents?: true

Size: 1.98 KB

Versions: 3

Compression:

Stored size: 1.98 KB

Contents

<% security_groups.each do |security_group| -%>
resource "aws_security_group" "<%= module_name_of(security_group) %>" {
    name        = "<%= security_group.group_name %>"
    description = "<%= security_group.description %>"
    vpc_id      = "<%= security_group.vpc_id || '' %>"

<% security_group.ip_permissions.each do |permission| -%>
  <%- security_groups = security_groups_in(permission).reject { |group_id| group_id == security_group.group_id } -%>
    ingress {
        from_port       = <%= permission.from_port || 0 %>
        to_port         = <%= permission.to_port || 0 %>
        protocol        = "<%= permission.ip_protocol %>"
<%- if permission.ip_ranges.length > 0 -%>
        cidr_blocks     = <%= permission.ip_ranges.map { |range| range.cidr_ip }.inspect %>
<%- end -%>
<%- if permission.user_id_group_pairs.length > 0 -%>
  <%- self_referenced = self_referenced_permission?(security_group, permission) -%>
  <%- unless self_referenced -%>
        security_groups = <%= security_groups.inspect %>
  <%- end -%>
        self            = <%= self_referenced %>
<%- end -%>
    }

<% end -%>

<% security_group.ip_permissions_egress.each do |permission| -%>
    egress {
        from_port       = <%= permission.from_port || 0 %>
        to_port         = <%= permission.to_port || 0 %>
        protocol        = "<%= permission.ip_protocol %>"
<%- if permission.ip_ranges.length > 0 -%>
        cidr_blocks     = <%= permission.ip_ranges.map { |range| range.cidr_ip }.inspect %>
<%- end -%>
<%- if permission.user_id_group_pairs.length > 0 -%>
  <%- self_referenced = self_referenced_permission?(security_group, permission) -%>
  <%- unless self_referenced -%>
        security_groups = <%= security_groups_in(permission).inspect %>
  <%- end -%>
        self            = <%= self_referenced %>
<%- end -%>
    }

<% end -%>
<% if security_group.tags.length > 0 -%>
    tags {
<% security_group.tags.each do |tag| -%>
        "<%= tag.key %>" = "<%= tag.value %>"
<% end -%>
    }
<% end -%>
}

<% end -%>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terraforming-0.1.2 lib/terraforming/template/tf/security_group.erb
terraforming-0.1.1 lib/terraforming/template/tf/security_group.erb
terraforming-0.1.0 lib/terraforming/template/tf/security_group.erb