aws-insight 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +84 -0
  5. data/.travis.yml +19 -0
  6. data/CHANGELOG.md +336 -0
  7. data/CODE_OF_CONDUCT.md +13 -0
  8. data/CONTRIBUTING.md +62 -0
  9. data/Gemfile +19 -0
  10. data/Guardfile +12 -0
  11. data/LICENSE +22 -0
  12. data/README.md +393 -0
  13. data/Rakefile +6 -0
  14. data/bin/terraforming +5 -0
  15. data/contrib/zsh-completion/_terraforming +65 -0
  16. data/lib/terraforming.rb +54 -0
  17. data/lib/terraforming/cli.rb +340 -0
  18. data/lib/terraforming/resource/alb.rb +98 -0
  19. data/lib/terraforming/resource/auto_scaling_group.rb +90 -0
  20. data/lib/terraforming/resource/cloud_watch_alarm.rb +87 -0
  21. data/lib/terraforming/resource/config.rb +98 -0
  22. data/lib/terraforming/resource/db_parameter_group.rb +58 -0
  23. data/lib/terraforming/resource/db_security_group.rb +57 -0
  24. data/lib/terraforming/resource/db_subnet_group.rb +52 -0
  25. data/lib/terraforming/resource/ec2.rb +130 -0
  26. data/lib/terraforming/resource/efs_file_system.rb +60 -0
  27. data/lib/terraforming/resource/eip.rb +66 -0
  28. data/lib/terraforming/resource/elasti_cache_cluster.rb +80 -0
  29. data/lib/terraforming/resource/elasti_cache_subnet_group.rb +56 -0
  30. data/lib/terraforming/resource/elb.rb +203 -0
  31. data/lib/terraforming/resource/iam_group.rb +54 -0
  32. data/lib/terraforming/resource/iam_group_membership.rb +63 -0
  33. data/lib/terraforming/resource/iam_group_policy.rb +71 -0
  34. data/lib/terraforming/resource/iam_instance_profile.rb +54 -0
  35. data/lib/terraforming/resource/iam_policy.rb +63 -0
  36. data/lib/terraforming/resource/iam_policy_attachment.rb +86 -0
  37. data/lib/terraforming/resource/iam_role.rb +56 -0
  38. data/lib/terraforming/resource/iam_role_policy.rb +71 -0
  39. data/lib/terraforming/resource/iam_user.rb +55 -0
  40. data/lib/terraforming/resource/iam_user_policy.rb +71 -0
  41. data/lib/terraforming/resource/internet_gateway.rb +54 -0
  42. data/lib/terraforming/resource/kms_alias.rb +55 -0
  43. data/lib/terraforming/resource/kms_key.rb +84 -0
  44. data/lib/terraforming/resource/launch_configuration.rb +106 -0
  45. data/lib/terraforming/resource/nat_gateway.rb +57 -0
  46. data/lib/terraforming/resource/network_acl.rb +83 -0
  47. data/lib/terraforming/resource/network_interface.rb +68 -0
  48. data/lib/terraforming/resource/rds.rb +74 -0
  49. data/lib/terraforming/resource/redshift.rb +67 -0
  50. data/lib/terraforming/resource/route53_record.rb +106 -0
  51. data/lib/terraforming/resource/route53_zone.rb +89 -0
  52. data/lib/terraforming/resource/route_table.rb +122 -0
  53. data/lib/terraforming/resource/route_table_association.rb +59 -0
  54. data/lib/terraforming/resource/s3.rb +69 -0
  55. data/lib/terraforming/resource/security_group.rb +188 -0
  56. data/lib/terraforming/resource/sns_topic.rb +75 -0
  57. data/lib/terraforming/resource/sns_topic_subscription.rb +83 -0
  58. data/lib/terraforming/resource/sqs.rb +70 -0
  59. data/lib/terraforming/resource/subnet.rb +55 -0
  60. data/lib/terraforming/resource/vpc.rb +67 -0
  61. data/lib/terraforming/resource/vpn_gateway.rb +55 -0
  62. data/lib/terraforming/template/tf/alb.erb +28 -0
  63. data/lib/terraforming/template/tf/auto_scaling_group.erb +28 -0
  64. data/lib/terraforming/template/tf/cloud_watch_alarm.erb +33 -0
  65. data/lib/terraforming/template/tf/db_parameter_group.erb +17 -0
  66. data/lib/terraforming/template/tf/db_security_group.erb +26 -0
  67. data/lib/terraforming/template/tf/db_subnet_group.erb +8 -0
  68. data/lib/terraforming/template/tf/ec2.erb +56 -0
  69. data/lib/terraforming/template/tf/eip.erb +11 -0
  70. data/lib/terraforming/template/tf/elasti_cache_cluster.erb +22 -0
  71. data/lib/terraforming/template/tf/elasti_cache_subnet_group.erb +8 -0
  72. data/lib/terraforming/template/tf/elastic_filesystem.erb +18 -0
  73. data/lib/terraforming/template/tf/elb.erb +51 -0
  74. data/lib/terraforming/template/tf/iam_group.erb +7 -0
  75. data/lib/terraforming/template/tf/iam_group_membership.erb +8 -0
  76. data/lib/terraforming/template/tf/iam_group_policy.erb +10 -0
  77. data/lib/terraforming/template/tf/iam_instance_profile.erb +8 -0
  78. data/lib/terraforming/template/tf/iam_policy.erb +12 -0
  79. data/lib/terraforming/template/tf/iam_policy_attachment.erb +10 -0
  80. data/lib/terraforming/template/tf/iam_role.erb +10 -0
  81. data/lib/terraforming/template/tf/iam_role_policy.erb +10 -0
  82. data/lib/terraforming/template/tf/iam_user.erb +7 -0
  83. data/lib/terraforming/template/tf/iam_user_policy.erb +10 -0
  84. data/lib/terraforming/template/tf/internet_gateway.erb +14 -0
  85. data/lib/terraforming/template/tf/kms_alias.erb +7 -0
  86. data/lib/terraforming/template/tf/kms_key.erb +13 -0
  87. data/lib/terraforming/template/tf/launch_configuration.erb +68 -0
  88. data/lib/terraforming/template/tf/nat_gateway.erb +9 -0
  89. data/lib/terraforming/template/tf/network_acl.erb +43 -0
  90. data/lib/terraforming/template/tf/network_interface.erb +22 -0
  91. data/lib/terraforming/template/tf/rds.erb +25 -0
  92. data/lib/terraforming/template/tf/redshift.erb +23 -0
  93. data/lib/terraforming/template/tf/route53_record.erb +52 -0
  94. data/lib/terraforming/template/tf/route53_zone.erb +18 -0
  95. data/lib/terraforming/template/tf/route_table.erb +34 -0
  96. data/lib/terraforming/template/tf/route_table_association.erb +9 -0
  97. data/lib/terraforming/template/tf/s3.erb +12 -0
  98. data/lib/terraforming/template/tf/security_group.erb +56 -0
  99. data/lib/terraforming/template/tf/sns_topic.erb +17 -0
  100. data/lib/terraforming/template/tf/sns_topic_subscription.erb +23 -0
  101. data/lib/terraforming/template/tf/sqs.erb +21 -0
  102. data/lib/terraforming/template/tf/subnet.erb +15 -0
  103. data/lib/terraforming/template/tf/vpc.erb +15 -0
  104. data/lib/terraforming/template/tf/vpn_gateway.erb +14 -0
  105. data/lib/terraforming/util.rb +30 -0
  106. data/lib/terraforming/version.rb +3 -0
  107. data/script/console +14 -0
  108. data/script/generate +97 -0
  109. data/script/setup +7 -0
  110. data/templates/resource.erb.erb +3 -0
  111. data/templates/resource.rb.erb +31 -0
  112. data/templates/resource_spec.rb.erb +39 -0
  113. data/terraforming.gemspec +31 -0
  114. metadata +271 -0
@@ -0,0 +1,11 @@
1
+ <% eips.each do |addr| -%>
2
+ resource "aws_eip" "<%= module_name_of(addr) %>" {
3
+ <% if addr.instance_id -%>
4
+ instance = "<%= addr.instance_id %>"
5
+ <% elsif addr.network_interface_id -%>
6
+ network_interface = "<%= addr.network_interface_id %>"
7
+ <% end -%>
8
+ vpc = <%= vpc?(addr) %>
9
+ }
10
+
11
+ <% end -%>
@@ -0,0 +1,22 @@
1
+ <% cache_clusters.each do |cache_cluster| -%>
2
+ resource "aws_elasticache_cluster" "<%= module_name_of(cache_cluster) %>" {
3
+ cluster_id = "<%= cache_cluster.cache_cluster_id %>"
4
+ engine = "<%= cache_cluster.engine %>"
5
+ engine_version = "<%= cache_cluster.engine_version %>"
6
+ node_type = "<%= cache_cluster.cache_node_type %>"
7
+ num_cache_nodes = <%= cache_cluster.num_cache_nodes %>
8
+ parameter_group_name = "<%= cache_cluster.cache_parameter_group.cache_parameter_group_name %>"
9
+ <%- if cache_cluster.configuration_endpoint -%>
10
+ port = <%= cache_cluster.configuration_endpoint.port %>
11
+ <%- else -%>
12
+ port = <%= cache_cluster.cache_nodes[0].endpoint.port %>
13
+ <%- end -%>
14
+ <%- if cluster_in_vpc?(cache_cluster) -%>
15
+ subnet_group_name = "<%= cache_cluster.cache_subnet_group_name %>"
16
+ security_group_ids = <%= security_group_ids_of(cache_cluster).inspect %>
17
+ <%- else -%>
18
+ security_group_names = <%= security_group_names_of(cache_cluster).inspect %>
19
+ <%- end -%>
20
+ }
21
+
22
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ <% cache_subnet_groups.each do |cache_subnet_group| -%>
2
+ resource "aws_elasticache_subnet_group" "<%= module_name_of(cache_subnet_group) %>" {
3
+ name = "<%= cache_subnet_group.cache_subnet_group_name %>"
4
+ description = "<%= cache_subnet_group.cache_subnet_group_description %>"
5
+ subnet_ids = <%= subnet_ids_of(cache_subnet_group).inspect %>
6
+ }
7
+
8
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ <% file_systems.each_with_index do |efs, idx| -%>
2
+ resource "aws_efs_file_system" "<%= module_name_of(efs) %>" {
3
+ <% if efs.creation_token -%>
4
+ creation_token = "<%= efs.creation_token %>"
5
+ <% end -%>
6
+ <% if efs.file_system_id -%>
7
+ file_system_id = "<%= efs.file_system_id %>"
8
+ <% end -%>
9
+ <% if efs.performance_mode -%>
10
+ performance_mode = "<%= efs.performance_mode %>"
11
+ <% end -%>
12
+ <% if efs.name -%>
13
+ tags {
14
+ Name = "<%= efs.name %>"
15
+ }
16
+ <% end -%>
17
+ }
18
+ <% end -%>
@@ -0,0 +1,51 @@
1
+ <% load_balancers.each do |load_balancer| -%>
2
+ <%- load_balancer_attributes = load_balancer_attributes_of(load_balancer) -%>
3
+ resource "aws_elb" "<%= module_name_of(load_balancer) %>" {
4
+ name = "<%= load_balancer.load_balancer_name %>"
5
+ <%- if vpc_elb?(load_balancer) -%>
6
+ subnets = <%= load_balancer.subnets.inspect %>
7
+ <%- else -%>
8
+ availability_zones = <%= load_balancer.availability_zones.inspect %>
9
+ <%- end -%>
10
+ security_groups = <%= load_balancer.security_groups.inspect %>
11
+ instances = <%= load_balancer.instances.map { |instance| instance.instance_id }.inspect %>
12
+ cross_zone_load_balancing = <%= load_balancer_attributes.cross_zone_load_balancing.enabled %>
13
+ idle_timeout = <%= load_balancer_attributes.connection_settings.idle_timeout %>
14
+ connection_draining = <%= load_balancer_attributes.connection_draining.enabled %>
15
+ connection_draining_timeout = <%= load_balancer_attributes.connection_draining.timeout %>
16
+ internal = <%= internal?(load_balancer).to_s %>
17
+
18
+ <%- if load_balancer_attributes.access_log.enabled -%>
19
+ access_logs {
20
+ bucket = "<%= load_balancer_attributes.access_log.s3_bucket_name %>"
21
+ bucket_prefix = "<%= load_balancer_attributes.access_log.s3_bucket_prefix %>"
22
+ interval = <%= load_balancer_attributes.access_log.emit_interval %>
23
+ }
24
+
25
+ <%- end -%>
26
+ <% load_balancer.listener_descriptions.map { |ld| ld.listener }.map do |listener| -%>
27
+ listener {
28
+ instance_port = <%= listener.instance_port %>
29
+ instance_protocol = "<%= listener.instance_protocol.downcase %>"
30
+ lb_port = <%= listener.load_balancer_port %>
31
+ lb_protocol = "<%= listener.protocol.downcase %>"
32
+ ssl_certificate_id = "<%= listener.ssl_certificate_id %>"
33
+ }
34
+
35
+ <% end -%>
36
+ health_check {
37
+ healthy_threshold = <%= load_balancer.health_check.healthy_threshold %>
38
+ unhealthy_threshold = <%= load_balancer.health_check.unhealthy_threshold %>
39
+ interval = <%= load_balancer.health_check.interval %>
40
+ target = "<%= load_balancer.health_check.target %>"
41
+ timeout = <%= load_balancer.health_check.timeout %>
42
+ }
43
+
44
+ tags {
45
+ <% @client.describe_tags(load_balancer_names: [load_balancer.load_balancer_name]).tag_descriptions.first.tags.each do |tag| -%>
46
+ "<%= tag.key %>" = "<%= tag.value %>"
47
+ <% end -%>
48
+ }
49
+ }
50
+
51
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ <% iam_groups.each do |group| -%>
2
+ resource "aws_iam_group" "<%= module_name_of(group) %>" {
3
+ name = "<%= group.group_name %>"
4
+ path = "<%= group.path %>"
5
+ }
6
+
7
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ <% iam_groups.each do |group| -%>
2
+ resource "aws_iam_group_membership" "<%= module_name_of(group) %>" {
3
+ name = "<%= membership_name_of(group) %>"
4
+ users = <%= group_members_of(group).inspect %>
5
+ group = "<%= group.group_name %>"
6
+ }
7
+
8
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <% iam_group_policies.each do |policy| -%>
2
+ resource "aws_iam_group_policy" "<%= unique_name(policy) %>" {
3
+ name = "<%= policy.policy_name %>"
4
+ group = "<%= policy.group_name %>"
5
+ policy = <<POLICY
6
+ <%= prettify_policy(policy.policy_document, unescape: true) %>
7
+ POLICY
8
+ }
9
+
10
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ <% iam_instance_profiles.each do |profile| -%>
2
+ resource "aws_iam_instance_profile" "<%= module_name_of(profile) %>" {
3
+ name = "<%= profile.instance_profile_name %>"
4
+ path = "<%= profile.path %>"
5
+ roles = <%= profile.roles.map { |role| role.role_name }.inspect %>
6
+ }
7
+
8
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <% iam_policies.each do |policy| -%>
2
+ <%- version = iam_policy_version_of(policy) -%>
3
+ resource "aws_iam_policy" "<%= module_name_of(policy) %>" {
4
+ name = "<%= policy.policy_name %>"
5
+ path = "<%= policy.path %>"
6
+ description = "<%= iam_policy_description(policy) %>"
7
+ policy = <<POLICY
8
+ <%= prettify_policy(version.document, unescape: true) %>
9
+ POLICY
10
+ }
11
+
12
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <% iam_policy_attachments.each do |policy_attachment| -%>
2
+ resource "aws_iam_policy_attachment" "<%= module_name_of(policy_attachment) %>" {
3
+ name = "<%= policy_attachment[:name] %>"
4
+ policy_arn = "<%= policy_attachment[:arn] %>"
5
+ groups = <%= policy_attachment[:entities].policy_groups.map(&:group_name).inspect %>
6
+ users = <%= policy_attachment[:entities].policy_users.map(&:user_name).inspect %>
7
+ roles = <%= policy_attachment[:entities].policy_roles.map(&:role_name).inspect %>
8
+ }
9
+
10
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <% iam_roles.each do |role| -%>
2
+ resource "aws_iam_role" "<%= module_name_of(role) %>" {
3
+ name = "<%= role.role_name %>"
4
+ path = "<%= role.path %>"
5
+ assume_role_policy = <<POLICY
6
+ <%= prettify_policy(role.assume_role_policy_document, unescape: true) %>
7
+ POLICY
8
+ }
9
+
10
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <% iam_role_policies.each do |policy| -%>
2
+ resource "aws_iam_role_policy" "<%= unique_name(policy) %>" {
3
+ name = "<%= policy.policy_name %>"
4
+ role = "<%= policy.role_name %>"
5
+ policy = <<POLICY
6
+ <%= prettify_policy(policy.policy_document, unescape: true) %>
7
+ POLICY
8
+ }
9
+
10
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ <% iam_users.each do |user| -%>
2
+ resource "aws_iam_user" "<%= module_name_of(user) %>" {
3
+ name = "<%= user.user_name %>"
4
+ path = "<%= user.path %>"
5
+ }
6
+
7
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <% iam_user_policies.each do |policy| -%>
2
+ resource "aws_iam_user_policy" "<%= unique_name(policy) %>" {
3
+ name = "<%= policy.policy_name %>"
4
+ user = "<%= policy.user_name %>"
5
+ policy = <<POLICY
6
+ <%= prettify_policy(policy.policy_document, unescape: true) %>
7
+ POLICY
8
+ }
9
+
10
+ <% end -%>
@@ -0,0 +1,14 @@
1
+ <% internet_gateways.each do |internet_gateway| -%>
2
+ <% unless internet_gateway.attachments.empty? -%>
3
+ resource "aws_internet_gateway" "<%= module_name_of(internet_gateway) %>" {
4
+ vpc_id = "<%= internet_gateway.attachments[0].vpc_id %>"
5
+
6
+ tags {
7
+ <% internet_gateway.tags.each do |tag| -%>
8
+ "<%= tag.key %>" = "<%= tag.value %>"
9
+ <% end -%>
10
+ }
11
+ }
12
+
13
+ <% end -%>
14
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ <% aliases.each do |als| -%>
2
+ resource "aws_kms_alias" "<%= module_name_of(als) %>" {
3
+ name = "<%= als.alias_name %>"
4
+ target_key_id = "<%= als.target_key_id %>"
5
+ }
6
+
7
+ <% end -%>
@@ -0,0 +1,13 @@
1
+ <% keys.each do |key| -%>
2
+ resource "aws_kms_key" "<%= module_name_of(key) %>" {
3
+ description = "<%= key.description %>"
4
+ key_usage = "<%= key_usage_of(key) %>"
5
+ is_enabled = <%= key.enabled %>
6
+ enable_key_rotation = <%= key_rotation_status_of(key).key_rotation_enabled %>
7
+
8
+ policy = <<POLICY
9
+ <%= key_policy_of(key).strip %>
10
+ POLICY
11
+ }
12
+
13
+ <% end -%>
@@ -0,0 +1,68 @@
1
+ <% launch_configurations.each do |launch_configuration| -%>
2
+ resource "aws_launch_configuration" "<%= module_name_of(launch_configuration) %>" {
3
+ name = "<%= launch_configuration.launch_configuration_name %>"
4
+ image_id = "<%= launch_configuration.image_id %>"
5
+ instance_type = "<%= launch_configuration.instance_type %>"
6
+ <%- if launch_configuration.iam_instance_profile -%>
7
+ iam_instance_profile = "<%= launch_configuration.iam_instance_profile %>"
8
+ <%- end -%>
9
+ <%- unless launch_configuration.key_name.empty? -%>
10
+ key_name = "<%= launch_configuration.key_name %>"
11
+ <%- end -%>
12
+ security_groups = <%= launch_configuration.security_groups.map { |sg| sg }.inspect %>
13
+ <%- unless launch_configuration.associate_public_ip_address.nil? -%>
14
+ associate_public_ip_address = <%= launch_configuration.associate_public_ip_address %>
15
+ <%- end -%>
16
+ <%- unless launch_configuration.user_data.empty? -%>
17
+ user_data = "<%= launch_configuration.user_data %>"
18
+ <%- end -%>
19
+ enable_monitoring = <%= launch_configuration.instance_monitoring.enabled %>
20
+ ebs_optimized = <%= launch_configuration.ebs_optimized %>
21
+ <%- if launch_configuration.spot_price -%>
22
+ spot_price = "<%= launch_configuration.spot_price %>"
23
+ <%- end -%>
24
+ <%- if launch_configuration.placement_tenancy -%>
25
+ placement_tenancy = "<%= launch_configuration.placement_tenancy %>"
26
+ <%- end -%>
27
+
28
+ <% launch_configuration.block_device_mappings.each do |block_device| -%>
29
+ <%- if root_block_device?(block_device) -%>
30
+ root_block_device {
31
+ <%- if ebs_block_device?(block_device) -%>
32
+ volume_type = "<%= block_device.ebs.volume_type %>"
33
+ volume_size = <%= block_device.ebs.volume_size %>
34
+ <%- if block_device.ebs.iops -%>
35
+ iops = <%= block_device.ebs.iops %>
36
+ <%- end -%>
37
+ delete_on_termination = <%= block_device.ebs.delete_on_termination %>
38
+ <%- end -%>
39
+ }
40
+
41
+ <%- elsif ebs_block_device?(block_device) -%>
42
+ ebs_block_device {
43
+ device_name = "<%= block_device.device_name %>"
44
+ <%- if block_device.ebs.snapshot_id -%>
45
+ snapshot_id = "<%= block_device.ebs.snapshot_id %>"
46
+ <%- end -%>
47
+ volume_type = "<%= block_device.ebs.volume_type %>"
48
+ volume_size = <%= block_device.ebs.volume_size %>
49
+ <%- if block_device.ebs.iops -%>
50
+ iops = <%= block_device.ebs.iops %>
51
+ <%- end -%>
52
+ delete_on_termination = <%= block_device.ebs.delete_on_termination %>
53
+ <%- if block_device.ebs.encrypted -%>
54
+ encrypted = <%= block_device.ebs.encrypted %>
55
+ <%- end -%>
56
+ }
57
+
58
+ <%- elsif ephemeral_block_device?(block_device) -%>
59
+ ephemeral_block_device {
60
+ device_name = "<%= block_device.device_name %>"
61
+ virtual_name = "<%= block_device.virtual_name %>"
62
+ }
63
+
64
+ <%- end -%>
65
+ <%- end -%>
66
+ }
67
+
68
+ <%- end -%>
@@ -0,0 +1,9 @@
1
+ <% nat_gateways.each do |nat_gateway| -%>
2
+ <% unless nat_gateway.nat_gateway_addresses.empty? -%>
3
+ resource "aws_nat_gateway" "<%= module_name_of(nat_gateway) %>" {
4
+ allocation_id = "<%= nat_gateway.nat_gateway_addresses[0].allocation_id %>"
5
+ subnet_id = "<%= nat_gateway.subnet_id %>"
6
+ }
7
+
8
+ <% end -%>
9
+ <% end -%>
@@ -0,0 +1,43 @@
1
+ <% network_acls.each do |network_acl| -%>
2
+ resource "aws_network_acl" "<%= module_name_of(network_acl) %>" {
3
+ vpc_id = "<%= network_acl.vpc_id %>"
4
+ subnet_ids = <%= subnet_ids_of(network_acl).inspect %>
5
+
6
+ <% ingresses_of(network_acl).each do |ingress| -%>
7
+ ingress {
8
+ from_port = <%= from_port_of(ingress) %>
9
+ to_port = <%= to_port_of(ingress) %>
10
+ rule_no = <%= ingress.rule_number %>
11
+ action = "<%= ingress.rule_action %>"
12
+ protocol = "<%= ingress.protocol %>"
13
+ cidr_block = "<%= ingress.cidr_block %>"
14
+ <%- if ingress.icmp_type_code -%>
15
+ icmp_code = "<%= ingress.icmp_type_code.code %>"
16
+ icmp_type = "<%= ingress.icmp_type_code.type %>"
17
+ <%- end -%>
18
+ }
19
+
20
+ <% end -%>
21
+ <% egresses_of(network_acl).each do |egress| -%>
22
+ egress {
23
+ from_port = <%= from_port_of(egress) %>
24
+ to_port = <%= to_port_of(egress) %>
25
+ rule_no = <%= egress.rule_number %>
26
+ action = "<%= egress.rule_action %>"
27
+ protocol = "<%= egress.protocol %>"
28
+ cidr_block = "<%= egress.cidr_block %>"
29
+ <%- if egress.icmp_type_code -%>
30
+ icmp_code = "<%= egress.icmp_type_code.code %>"
31
+ icmp_type = "<%= egress.icmp_type_code.type %>"
32
+ <%- end -%>
33
+ }
34
+
35
+ <% end -%>
36
+ tags {
37
+ <% network_acl.tags.each do |tag| -%>
38
+ "<%= tag.key %>" = "<%= tag.value %>"
39
+ <% end -%>
40
+ }
41
+ }
42
+
43
+ <% end -%>
@@ -0,0 +1,22 @@
1
+ <% network_interfaces.each do |network_interface| -%>
2
+ resource "aws_network_interface" "<%= module_name_of(network_interface) %>" {
3
+ subnet_id = "<%= network_interface.subnet_id %>"
4
+ private_ips = <%= private_ips_of(network_interface).inspect %>
5
+ security_groups = <%= security_groups_of(network_interface).inspect %>
6
+ source_dest_check = <%= network_interface.source_dest_check %>
7
+ <% if network_interface.attachment && network_interface.attachment.instance_id -%>
8
+ attachment {
9
+ instance = "<%= network_interface.attachment.instance_id %>"
10
+ device_index = <%= network_interface.attachment.device_index %>
11
+ }
12
+ <% end -%>
13
+ <% if network_interface.tag_set.length > 0 -%>
14
+ tags {
15
+ <% network_interface.tag_set.each do |tag| -%>
16
+ "<%= tag.key %>" = "<%= tag.value %>"
17
+ <% end -%>
18
+ }
19
+ <% end -%>
20
+ }
21
+
22
+ <% end -%>
@@ -0,0 +1,25 @@
1
+ <% db_instances.each do |instance| -%>
2
+ resource "aws_db_instance" "<%= instance.db_instance_identifier %>" {
3
+ identifier = "<%= module_name_of(instance) %>"
4
+ allocated_storage = <%= instance.allocated_storage %>
5
+ storage_type = "<%= instance.storage_type %>"
6
+ engine = "<%= instance.engine %>"
7
+ engine_version = "<%= instance.engine_version %>"
8
+ instance_class = "<%= instance.db_instance_class %>"
9
+ name = "<%= instance.db_name %>"
10
+ username = "<%= instance.master_username %>"
11
+ password = "xxxxxxxx"
12
+ port = <%= instance.endpoint.port %>
13
+ publicly_accessible = <%= instance.publicly_accessible %>
14
+ availability_zone = "<%= instance.availability_zone %>"
15
+ security_group_names = <%= instance.db_security_groups.map { |sg| sg.db_security_group_name }.inspect %>
16
+ vpc_security_group_ids = <%= instance.vpc_security_groups.map { |sg| sg.vpc_security_group_id }.inspect %>
17
+ db_subnet_group_name = "<%= instance.db_subnet_group ? instance.db_subnet_group.db_subnet_group_name : "" %>"
18
+ parameter_group_name = "<%= instance.db_parameter_groups[0].db_parameter_group_name %>"
19
+ multi_az = <%= instance.multi_az %>
20
+ backup_retention_period = <%= instance.backup_retention_period %>
21
+ backup_window = "<%= instance.preferred_backup_window %>"
22
+ maintenance_window = "<%= instance.preferred_maintenance_window %>"
23
+ final_snapshot_identifier = "<%= instance.db_instance_identifier %>-final"
24
+ }
25
+ <% end -%>
@@ -0,0 +1,23 @@
1
+ <% clusters.each do |cluster| -%>
2
+ resource "aws_redshift_cluster" "<%= module_name_of(cluster) %>" {
3
+ cluster_identifier = "<%= cluster.cluster_identifier %>"
4
+ <%- if cluster.db_name -%>
5
+ database_name = "<%= cluster.db_name %>"
6
+ <%- end -%>
7
+ cluster_type = "<%= cluster.number_of_nodes == 1 ? "single-node" : "multi-node" %>"
8
+ node_type = "<%= cluster.node_type %>"
9
+ master_password = "xxxxxxxx"
10
+ master_username = "<%= cluster.master_username %>"
11
+ availability_zone = "<%= cluster.availability_zone %>"
12
+ preferred_maintenance_window = "<%= cluster.preferred_maintenance_window %>"
13
+ cluster_parameter_group_name = "<%= cluster.cluster_parameter_groups[0].parameter_group_name %>"
14
+ automated_snapshot_retention_period = "<%= cluster.automated_snapshot_retention_period %>"
15
+ port = "<%= cluster.endpoint.port %>"
16
+ cluster_version = "<%= cluster.cluster_version %>"
17
+ allow_version_upgrade = "<%= cluster.allow_version_upgrade %>"
18
+ number_of_nodes = "<%= cluster.number_of_nodes %>"
19
+ publicly_accessible = "<%= cluster.publicly_accessible %>"
20
+ encrypted = "<%= cluster.encrypted %>"
21
+ skip_final_snapshot = "true"
22
+ }
23
+ <% end -%>