lib/terraforming/template/tf/security_group.erb in terraforming-0.0.5 vs lib/terraforming/template/tf/security_group.erb in terraforming-0.1.0
- old
+ new
@@ -3,19 +3,24 @@
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 -%>
- security_groups = <%= permission.user_id_group_pairs.map { |range| range.group_id }.inspect %>
+ <%- self_referenced = self_referenced_permission?(security_group, permission) -%>
+ <%- unless self_referenced -%>
+ security_groups = <%= security_groups.inspect %>
+ <%- end -%>
+ self = <%= self_referenced %>
<%- end -%>
}
<% end -%>
@@ -26,10 +31,14 @@
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 -%>
- security_groups = <%= permission.user_id_group_pairs.map { |range| range.group_id }.inspect %>
+ <%- 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 -%>