<% launch_configurations.each do |launch_configuration| -%> resource "aws_launch_configuration" "<%= module_name_of(launch_configuration) %>" { name = "<%= launch_configuration.launch_configuration_name %>" image_id = "<%= launch_configuration.image_id %>" instance_type = "<%= launch_configuration.instance_type %>" <%- if launch_configuration.iam_instance_profile -%> iam_instance_profile = "<%= launch_configuration.iam_instance_profile %>" <%- end -%> <%- unless launch_configuration.key_name.empty? -%> key_name = "<%= launch_configuration.key_name %>" <%- end -%> security_groups = <%= launch_configuration.security_groups.map { |sg| sg }.inspect %> associate_public_ip_address = <%= launch_configuration.associate_public_ip_address %> <%- unless launch_configuration.user_data.empty? -%> user_data = "<%= launch_configuration.user_data %>" <%- end -%> enable_monitoring = <%= launch_configuration.instance_monitoring.enabled %> ebs_optimized = <%= launch_configuration.ebs_optimized %> <%- if launch_configuration.spot_price -%> spot_price = "<%= launch_configuration.spot_price %>" <%- end -%> <%- if launch_configuration.placement_tenancy -%> placement_tenancy = "<%= launch_configuration.placement_tenancy %>" <%- end -%> <% launch_configuration.block_device_mappings.each do |block_device| -%> <%- if root_block_device?(block_device) -%> root_block_device { <%- if ebs_block_device?(block_device) -%> volume_type = "<%= block_device.ebs.volume_type %>" volume_size = <%= block_device.ebs.volume_size %> <%- if block_device.ebs.iops -%> iops = <%= block_device.ebs.iops %> <%- end -%> delete_on_termination = <%= block_device.ebs.delete_on_termination %> <%- end -%> } <%- elsif ebs_block_device?(block_device) -%> ebs_block_device { device_name = "<%= block_device.device_name %>" <%- if block_device.ebs.snapshot_id -%> snapshot_id = "<%= block_device.ebs.snapshot_id %>" <%- end -%> volume_type = "<%= block_device.ebs.volume_type %>" volume_size = <%= block_device.ebs.volume_size %> <%- if block_device.ebs.iops -%> iops = <%= block_device.ebs.iops %> <%- end -%> delete_on_termination = <%= block_device.ebs.delete_on_termination %> <%- if block_device.ebs.encrypted -%> encrypted = <%= block_device.ebs.encrypted %> <%- end -%> } <%- elsif ephemeral_block_device?(block_device) -%> ephemeral_block_device { device_name = "<%= block_device.device_name %>" virtual_name = "<%= block_device.virtual_name %>" } <%- end -%> <%- end -%> } <%- end -%>