Skip to content

Instantly share code, notes, and snippets.

@imbriaco
Last active October 15, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imbriaco/5b8540d5a39d91a47111 to your computer and use it in GitHub Desktop.
Save imbriaco/5b8540d5a39d91a47111 to your computer and use it in GitHub Desktop.
dynamic!(:my_security_group, :nat, {
:description => 'My Shiny Security Group',
:ingress => [
{
:cidr_ip => '0.0.0.0/0',
:ip_protocol => 'icmp',
:from_port => -1,
:to_port => -1
}
]
}
SparkleFormation.dynamic(:my_security_group) do |_name, _config = {}|
resources("#{_name}_security_group".to_sym) do
type 'AWS::EC2::SecurityGroup'
::SparkleFormation::SparkleStruct.camel_keys = true
[ :ingress, :egress ].each do |dir|
next unless _config[dir]
_config[dir] = _config[dir].map { |rule| ::SparkleFormation::SparkleStruct.new(rule) }
end
properties do
vpc_id _config[:vpc_id] || ref!(:vpc)
group_description _config[:description]
security_group_ingress _config[:ingress]
security_group_egress _config[:egress]
end
end
end
SparkleFormation.dynamic(:my_security_group) do |_name, _config = {}|
resources("#{_name}_security_group".to_sym) do
type 'AWS::EC2::SecurityGroup'
properties do
vpc_id _config[:vpc_id] || ref!(:vpc)
group_description _config[:description]
security_group_ingress _config[:ingress]
security_group_egress _config[:egress]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment