aws-insight 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +84 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +336 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +62 -0
- data/Gemfile +19 -0
- data/Guardfile +12 -0
- data/LICENSE +22 -0
- data/README.md +393 -0
- data/Rakefile +6 -0
- data/bin/terraforming +5 -0
- data/contrib/zsh-completion/_terraforming +65 -0
- data/lib/terraforming.rb +54 -0
- data/lib/terraforming/cli.rb +340 -0
- data/lib/terraforming/resource/alb.rb +98 -0
- data/lib/terraforming/resource/auto_scaling_group.rb +90 -0
- data/lib/terraforming/resource/cloud_watch_alarm.rb +87 -0
- data/lib/terraforming/resource/config.rb +98 -0
- data/lib/terraforming/resource/db_parameter_group.rb +58 -0
- data/lib/terraforming/resource/db_security_group.rb +57 -0
- data/lib/terraforming/resource/db_subnet_group.rb +52 -0
- data/lib/terraforming/resource/ec2.rb +130 -0
- data/lib/terraforming/resource/efs_file_system.rb +60 -0
- data/lib/terraforming/resource/eip.rb +66 -0
- data/lib/terraforming/resource/elasti_cache_cluster.rb +80 -0
- data/lib/terraforming/resource/elasti_cache_subnet_group.rb +56 -0
- data/lib/terraforming/resource/elb.rb +203 -0
- data/lib/terraforming/resource/iam_group.rb +54 -0
- data/lib/terraforming/resource/iam_group_membership.rb +63 -0
- data/lib/terraforming/resource/iam_group_policy.rb +71 -0
- data/lib/terraforming/resource/iam_instance_profile.rb +54 -0
- data/lib/terraforming/resource/iam_policy.rb +63 -0
- data/lib/terraforming/resource/iam_policy_attachment.rb +86 -0
- data/lib/terraforming/resource/iam_role.rb +56 -0
- data/lib/terraforming/resource/iam_role_policy.rb +71 -0
- data/lib/terraforming/resource/iam_user.rb +55 -0
- data/lib/terraforming/resource/iam_user_policy.rb +71 -0
- data/lib/terraforming/resource/internet_gateway.rb +54 -0
- data/lib/terraforming/resource/kms_alias.rb +55 -0
- data/lib/terraforming/resource/kms_key.rb +84 -0
- data/lib/terraforming/resource/launch_configuration.rb +106 -0
- data/lib/terraforming/resource/nat_gateway.rb +57 -0
- data/lib/terraforming/resource/network_acl.rb +83 -0
- data/lib/terraforming/resource/network_interface.rb +68 -0
- data/lib/terraforming/resource/rds.rb +74 -0
- data/lib/terraforming/resource/redshift.rb +67 -0
- data/lib/terraforming/resource/route53_record.rb +106 -0
- data/lib/terraforming/resource/route53_zone.rb +89 -0
- data/lib/terraforming/resource/route_table.rb +122 -0
- data/lib/terraforming/resource/route_table_association.rb +59 -0
- data/lib/terraforming/resource/s3.rb +69 -0
- data/lib/terraforming/resource/security_group.rb +188 -0
- data/lib/terraforming/resource/sns_topic.rb +75 -0
- data/lib/terraforming/resource/sns_topic_subscription.rb +83 -0
- data/lib/terraforming/resource/sqs.rb +70 -0
- data/lib/terraforming/resource/subnet.rb +55 -0
- data/lib/terraforming/resource/vpc.rb +67 -0
- data/lib/terraforming/resource/vpn_gateway.rb +55 -0
- data/lib/terraforming/template/tf/alb.erb +28 -0
- data/lib/terraforming/template/tf/auto_scaling_group.erb +28 -0
- data/lib/terraforming/template/tf/cloud_watch_alarm.erb +33 -0
- data/lib/terraforming/template/tf/db_parameter_group.erb +17 -0
- data/lib/terraforming/template/tf/db_security_group.erb +26 -0
- data/lib/terraforming/template/tf/db_subnet_group.erb +8 -0
- data/lib/terraforming/template/tf/ec2.erb +56 -0
- data/lib/terraforming/template/tf/eip.erb +11 -0
- data/lib/terraforming/template/tf/elasti_cache_cluster.erb +22 -0
- data/lib/terraforming/template/tf/elasti_cache_subnet_group.erb +8 -0
- data/lib/terraforming/template/tf/elastic_filesystem.erb +18 -0
- data/lib/terraforming/template/tf/elb.erb +51 -0
- data/lib/terraforming/template/tf/iam_group.erb +7 -0
- data/lib/terraforming/template/tf/iam_group_membership.erb +8 -0
- data/lib/terraforming/template/tf/iam_group_policy.erb +10 -0
- data/lib/terraforming/template/tf/iam_instance_profile.erb +8 -0
- data/lib/terraforming/template/tf/iam_policy.erb +12 -0
- data/lib/terraforming/template/tf/iam_policy_attachment.erb +10 -0
- data/lib/terraforming/template/tf/iam_role.erb +10 -0
- data/lib/terraforming/template/tf/iam_role_policy.erb +10 -0
- data/lib/terraforming/template/tf/iam_user.erb +7 -0
- data/lib/terraforming/template/tf/iam_user_policy.erb +10 -0
- data/lib/terraforming/template/tf/internet_gateway.erb +14 -0
- data/lib/terraforming/template/tf/kms_alias.erb +7 -0
- data/lib/terraforming/template/tf/kms_key.erb +13 -0
- data/lib/terraforming/template/tf/launch_configuration.erb +68 -0
- data/lib/terraforming/template/tf/nat_gateway.erb +9 -0
- data/lib/terraforming/template/tf/network_acl.erb +43 -0
- data/lib/terraforming/template/tf/network_interface.erb +22 -0
- data/lib/terraforming/template/tf/rds.erb +25 -0
- data/lib/terraforming/template/tf/redshift.erb +23 -0
- data/lib/terraforming/template/tf/route53_record.erb +52 -0
- data/lib/terraforming/template/tf/route53_zone.erb +18 -0
- data/lib/terraforming/template/tf/route_table.erb +34 -0
- data/lib/terraforming/template/tf/route_table_association.erb +9 -0
- data/lib/terraforming/template/tf/s3.erb +12 -0
- data/lib/terraforming/template/tf/security_group.erb +56 -0
- data/lib/terraforming/template/tf/sns_topic.erb +17 -0
- data/lib/terraforming/template/tf/sns_topic_subscription.erb +23 -0
- data/lib/terraforming/template/tf/sqs.erb +21 -0
- data/lib/terraforming/template/tf/subnet.erb +15 -0
- data/lib/terraforming/template/tf/vpc.erb +15 -0
- data/lib/terraforming/template/tf/vpn_gateway.erb +14 -0
- data/lib/terraforming/util.rb +30 -0
- data/lib/terraforming/version.rb +3 -0
- data/script/console +14 -0
- data/script/generate +97 -0
- data/script/setup +7 -0
- data/templates/resource.erb.erb +3 -0
- data/templates/resource.rb.erb +31 -0
- data/templates/resource_spec.rb.erb +39 -0
- data/terraforming.gemspec +31 -0
- metadata +271 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class SQS
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::SQS::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::SQS::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/sqs")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
queues.inject({}) do |resources, queue|
|
24
|
+
attributes = {
|
25
|
+
"name" => module_name_of(queue),
|
26
|
+
"id" => queue["QueueUrl"],
|
27
|
+
"arn" => queue["QueueArn"],
|
28
|
+
"visibility_timeout_seconds" => queue["VisibilityTimeout"],
|
29
|
+
"message_retention_seconds" => queue["MessageRetentionPeriod"],
|
30
|
+
"max_message_size" => queue["MaximumMessageSize"],
|
31
|
+
"delay_seconds" => queue["DelaySeconds"],
|
32
|
+
"receive_wait_time_seconds" => queue["ReceiveMessageWaitTimeSeconds"],
|
33
|
+
"policy" => queue.key?("Policy") ? queue["Policy"] : "",
|
34
|
+
"redrive_policy" => queue.key?("RedrivePolicy") ? queue["RedrivePolicy"] : "",
|
35
|
+
}
|
36
|
+
resources["aws_sqs_queue.#{module_name_of(queue)}"] = {
|
37
|
+
"type" => "aws_sqs_queue",
|
38
|
+
"primary" => {
|
39
|
+
"id" => queue["QueueUrl"],
|
40
|
+
"attributes" => attributes,
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
resources
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def queues
|
51
|
+
queue_urls.map do |queue_url|
|
52
|
+
attributes = @client.get_queue_attributes({
|
53
|
+
queue_url: queue_url,
|
54
|
+
attribute_names: ["All"],
|
55
|
+
}).attributes
|
56
|
+
attributes["QueueUrl"] = queue_url
|
57
|
+
attributes
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def queue_urls
|
62
|
+
@client.list_queues.map(&:queue_urls).flatten
|
63
|
+
end
|
64
|
+
|
65
|
+
def module_name_of(queue)
|
66
|
+
normalize_module_name(queue["QueueArn"].split(":").last)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class Subnet
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::EC2::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::EC2::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/subnet")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
subnets.inject({}) do |resources, subnet|
|
24
|
+
attributes = {
|
25
|
+
"availability_zone" => subnet.availability_zone,
|
26
|
+
"cidr_block" => subnet.cidr_block,
|
27
|
+
"id" => subnet.subnet_id,
|
28
|
+
"map_public_ip_on_launch" => subnet.map_public_ip_on_launch.to_s,
|
29
|
+
"tags.#" => subnet.tags.length.to_s,
|
30
|
+
"vpc_id" => subnet.vpc_id,
|
31
|
+
}
|
32
|
+
resources["aws_subnet.#{module_name_of(subnet)}"] = {
|
33
|
+
"type" => "aws_subnet",
|
34
|
+
"primary" => {
|
35
|
+
"id" => subnet.subnet_id,
|
36
|
+
"attributes" => attributes
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
resources
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def subnets
|
47
|
+
@client.describe_subnets.map(&:subnets).flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def module_name_of(subnet)
|
51
|
+
normalize_module_name("#{subnet.subnet_id}-#{name_from_tag(subnet, subnet.subnet_id)}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class VPC
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::EC2::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::EC2::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/vpc")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
vpcs.inject({}) do |resources, vpc|
|
24
|
+
attributes = {
|
25
|
+
"cidr_block" => vpc.cidr_block,
|
26
|
+
"enable_dns_hostnames" => enable_dns_hostnames?(vpc).to_s,
|
27
|
+
"enable_dns_support" => enable_dns_support?(vpc).to_s,
|
28
|
+
"id" => vpc.vpc_id,
|
29
|
+
"instance_tenancy" => vpc.instance_tenancy,
|
30
|
+
"tags.#" => vpc.tags.length.to_s,
|
31
|
+
}
|
32
|
+
resources["aws_vpc.#{module_name_of(vpc)}"] = {
|
33
|
+
"type" => "aws_vpc",
|
34
|
+
"primary" => {
|
35
|
+
"id" => vpc.vpc_id,
|
36
|
+
"attributes" => attributes
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
resources
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def enable_dns_hostnames?(vpc)
|
47
|
+
vpc_attribute(vpc, :enableDnsHostnames).enable_dns_hostnames.value
|
48
|
+
end
|
49
|
+
|
50
|
+
def enable_dns_support?(vpc)
|
51
|
+
vpc_attribute(vpc, :enableDnsSupport).enable_dns_support.value
|
52
|
+
end
|
53
|
+
|
54
|
+
def module_name_of(vpc)
|
55
|
+
normalize_module_name(name_from_tag(vpc, vpc.vpc_id))
|
56
|
+
end
|
57
|
+
|
58
|
+
def vpcs
|
59
|
+
@client.describe_vpcs.map(&:vpcs).flatten
|
60
|
+
end
|
61
|
+
|
62
|
+
def vpc_attribute(vpc, attribute)
|
63
|
+
@client.describe_vpc_attribute(vpc_id: vpc.vpc_id, attribute: attribute)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class VPNGateway
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::EC2::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::EC2::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/vpn_gateway")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
vpn_gateways.inject({}) do |resources, vpn_gateway|
|
24
|
+
next resources if vpn_gateway.vpc_attachments.empty?
|
25
|
+
|
26
|
+
attributes = {
|
27
|
+
"id" => vpn_gateway.vpn_gateway_id,
|
28
|
+
"vpc_id" => vpn_gateway.vpc_attachments[0].vpc_id,
|
29
|
+
"availability_zone" => vpn_gateway.availability_zone,
|
30
|
+
"tags.#" => vpn_gateway.tags.length.to_s,
|
31
|
+
}
|
32
|
+
resources["aws_vpn_gateway.#{module_name_of(vpn_gateway)}"] = {
|
33
|
+
"type" => "aws_vpn_gateway",
|
34
|
+
"primary" => {
|
35
|
+
"id" => vpn_gateway.vpn_gateway_id,
|
36
|
+
"attributes" => attributes
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
resources
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def vpn_gateways
|
47
|
+
@client.describe_vpn_gateways.map(&:vpn_gateways).flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def module_name_of(vpn_gateway)
|
51
|
+
normalize_module_name(name_from_tag(vpn_gateway, vpn_gateway.vpn_gateway_id))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% load_balancers.each do |load_balancer| -%>
|
2
|
+
<%- load_balancer_attributes = load_balancer_attributes_of(load_balancer) -%>
|
3
|
+
<%- tags = tags_of(load_balancer) -%>
|
4
|
+
resource "aws_alb" "<%= module_name_of(load_balancer) %>" {
|
5
|
+
idle_timeout = <%= load_balancer_attributes["idle_timeout.timeout_seconds"] %>
|
6
|
+
internal = <%= internal?(load_balancer).to_s %>
|
7
|
+
name = "<%= load_balancer.load_balancer_name %>"
|
8
|
+
security_groups = <%= load_balancer.security_groups.inspect %>
|
9
|
+
subnets = <%= load_balancer.availability_zones.map { |az| az.subnet_id }.inspect %>
|
10
|
+
|
11
|
+
enable_deletion_protection = <%= load_balancer_attributes["deletion_protection.enabled"].to_s %>
|
12
|
+
|
13
|
+
<%- if load_balancer_attributes["access_logs.s3.enabled"] == "true" -%>
|
14
|
+
access_logs {
|
15
|
+
bucket = "<%= load_balancer_attributes["access_logs.s3.bucket"] %>"
|
16
|
+
enabled = <%= load_balancer_attributes["access_logs.s3.enabled"] %>
|
17
|
+
prefix = "<%= load_balancer_attributes["access_logs.s3.prefix"] %>"
|
18
|
+
}
|
19
|
+
|
20
|
+
<%- end -%>
|
21
|
+
tags {
|
22
|
+
<% tags.each do |tag| -%>
|
23
|
+
"<%= tag.key %>" = "<%= tag.value %>"
|
24
|
+
<% end -%>
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
<% end -%>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% auto_scaling_groups.each do |group| -%>
|
2
|
+
<%- vpc_zone_specified = vpc_zone_specified?(group) -%>
|
3
|
+
resource "aws_autoscaling_group" "<%= module_name_of(group) %>" {
|
4
|
+
<%- unless vpc_zone_specified -%>
|
5
|
+
availability_zones = <%= group.availability_zones.inspect %>
|
6
|
+
<%- end -%>
|
7
|
+
desired_capacity = <%= group.desired_capacity %>
|
8
|
+
health_check_grace_period = <%= group.health_check_grace_period %>
|
9
|
+
health_check_type = "<%= group.health_check_type %>"
|
10
|
+
launch_configuration = "<%= group.launch_configuration_name %>"
|
11
|
+
max_size = <%= group.max_size %>
|
12
|
+
min_size = <%= group.min_size %>
|
13
|
+
name = "<%= group.auto_scaling_group_name %>"
|
14
|
+
<%- if vpc_zone_specified -%>
|
15
|
+
vpc_zone_identifier = <%= vpc_zone_identifier_of(group).inspect %>
|
16
|
+
<%- end -%>
|
17
|
+
|
18
|
+
<% group.tags.each do |tag| -%>
|
19
|
+
tag {
|
20
|
+
key = "<%= tag.key %>"
|
21
|
+
value = "<%= tag.value %>"
|
22
|
+
propagate_at_launch = <%= tag.propagate_at_launch.to_s %>
|
23
|
+
}
|
24
|
+
|
25
|
+
<% end -%>
|
26
|
+
}
|
27
|
+
|
28
|
+
<% end -%>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<% alarms.each do |alarm| -%>
|
2
|
+
resource "aws_cloudwatch_metric_alarm" "<%= normalize_module_name(alarm.alarm_name) %>" {
|
3
|
+
alarm_name = "<%= alarm.alarm_name %>"
|
4
|
+
comparison_operator = "<%= alarm.comparison_operator %>"
|
5
|
+
evaluation_periods = "<%= alarm.evaluation_periods %>"
|
6
|
+
metric_name = "<%= alarm.metric_name %>"
|
7
|
+
namespace = "<%= alarm.namespace %>"
|
8
|
+
period = "<%= alarm.period %>"
|
9
|
+
statistic = "<%= alarm.statistic %>"
|
10
|
+
threshold = "<%= alarm.threshold %>"
|
11
|
+
alarm_description = "<%= alarm.alarm_description %>"
|
12
|
+
<%- unless alarm.ok_actions.empty? -%>
|
13
|
+
ok_actions = <%= alarm.ok_actions %>
|
14
|
+
<%- end -%>
|
15
|
+
<%- unless alarm.alarm_actions.empty? -%>
|
16
|
+
alarm_actions = <%= alarm.alarm_actions %>
|
17
|
+
<%- end -%>
|
18
|
+
<%- unless alarm.actions_enabled -%>
|
19
|
+
actions_enabled = <%= alarm.actions_enabled %>
|
20
|
+
<%- end -%>
|
21
|
+
<%- unless alarm.dimensions.empty? -%>
|
22
|
+
dimensions {
|
23
|
+
<% alarm.dimensions.each do |dimension| -%>
|
24
|
+
<%= dimension.name %> = "<%= dimension.value %>"
|
25
|
+
<% end -%>
|
26
|
+
}
|
27
|
+
<%- end -%>
|
28
|
+
<%- unless alarm.insufficient_data_actions.empty? -%>
|
29
|
+
insufficient_data_actions = <%= alarm.insufficient_data_actions %>
|
30
|
+
<%- end -%>
|
31
|
+
}
|
32
|
+
|
33
|
+
<%- end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% db_parameter_groups.each do |parameter_group| -%>
|
2
|
+
resource "aws_db_parameter_group" "<%= module_name_of(parameter_group) %>" {
|
3
|
+
name = "<%= parameter_group.db_parameter_group_name %>"
|
4
|
+
family = "<%= parameter_group.db_parameter_group_family %>"
|
5
|
+
description = "<%= parameter_group.description %>"
|
6
|
+
|
7
|
+
<% db_parameters_in(parameter_group).each do |parameter| -%>
|
8
|
+
parameter {
|
9
|
+
name = "<%= parameter.parameter_name %>"
|
10
|
+
value = "<%= parameter.parameter_value || '' %>"
|
11
|
+
apply_method = "<%= parameter.apply_method || 'immediate' %>"
|
12
|
+
}
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
}
|
16
|
+
|
17
|
+
<% end -%>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% db_security_groups.each do |security_group| -%>
|
2
|
+
resource "aws_db_security_group" "<%= module_name_of(security_group) %>" {
|
3
|
+
name = "<%= security_group.db_security_group_name %>"
|
4
|
+
description = "<%= security_group.db_security_group_description %>"
|
5
|
+
|
6
|
+
<% security_group.ip_ranges.each do |cidr| -%>
|
7
|
+
ingress {
|
8
|
+
cidr = "<%= cidr.cidrip %>"
|
9
|
+
security_group_name = ""
|
10
|
+
security_group_id = ""
|
11
|
+
security_group_owner_id = ""
|
12
|
+
}
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
<% security_group.ec2_security_groups.each do |ec2_sg| -%>
|
16
|
+
ingress {
|
17
|
+
cidr = ""
|
18
|
+
security_group_name = "<%= ec2_sg.ec2_security_group_name %>"
|
19
|
+
security_group_id = "<%= ec2_sg.ec2_security_group_id %>"
|
20
|
+
security_group_owner_id = "<%= ec2_sg.ec2_security_group_owner_id %>"
|
21
|
+
}
|
22
|
+
|
23
|
+
<% end -%>
|
24
|
+
}
|
25
|
+
|
26
|
+
<% end -%>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% db_subnet_groups.each do |subnet_group| -%>
|
2
|
+
resource "aws_db_subnet_group" "<%= module_name_of(subnet_group) %>" {
|
3
|
+
name = "<%= subnet_group.db_subnet_group_name %>"
|
4
|
+
description = "<%= subnet_group.db_subnet_group_description %>"
|
5
|
+
subnet_ids = <%= subnet_group.subnets.map { |subnet| subnet.subnet_identifier }.inspect %>
|
6
|
+
}
|
7
|
+
|
8
|
+
<% end -%>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<% instances.each do |instance| -%>
|
2
|
+
resource "aws_instance" "<%= module_name_of(instance) %>" {
|
3
|
+
ami = "<%= instance.image_id %>"
|
4
|
+
availability_zone = "<%= instance.placement.availability_zone %>"
|
5
|
+
ebs_optimized = <%= instance.ebs_optimized %>
|
6
|
+
instance_type = "<%= instance.instance_type %>"
|
7
|
+
<%- unless instance.placement.group_name.empty? -%>
|
8
|
+
placement_group = "<%= instance.placement.group_name %>"
|
9
|
+
<%- end -%>
|
10
|
+
monitoring = <%= monitoring_state(instance) %>
|
11
|
+
key_name = "<%= instance.key_name %>"
|
12
|
+
<%- if in_vpc?(instance) -%>
|
13
|
+
subnet_id = "<%= instance.subnet_id %>"
|
14
|
+
vpc_security_group_ids = <%= instance.security_groups.map { |sg| sg.group_id }.inspect %>
|
15
|
+
<%- else -%>
|
16
|
+
security_groups = <%= instance.security_groups.map { |sg| sg.group_name }.inspect %>
|
17
|
+
<%- end -%>
|
18
|
+
associate_public_ip_address = <%= associate_public_ip?(instance) %>
|
19
|
+
private_ip = "<%= instance.private_ip_address %>"
|
20
|
+
<%- if instance.source_dest_check -%>
|
21
|
+
source_dest_check = <%= instance.source_dest_check %>
|
22
|
+
<%- end -%>
|
23
|
+
|
24
|
+
<% block_devices_of(instance).each do |block_device| -%>
|
25
|
+
<%- mapping = block_device_mapping_of(instance, block_device.volume_id) -%>
|
26
|
+
<%- if root_block_device?(mapping, instance) -%>
|
27
|
+
root_block_device {
|
28
|
+
volume_type = "<%= block_device.volume_type %>"
|
29
|
+
volume_size = <%= block_device.size %>
|
30
|
+
delete_on_termination = <%= mapping.ebs.delete_on_termination %>
|
31
|
+
<%- if block_device.volume_type == "io1" && block_device.iops -%>
|
32
|
+
iops = <%= block_device.iops %>
|
33
|
+
<%- end -%>
|
34
|
+
}
|
35
|
+
<%- else -%>
|
36
|
+
ebs_block_device {
|
37
|
+
device_name = "<%= mapping.device_name %>"
|
38
|
+
snapshot_id = "<%= block_device.snapshot_id %>"
|
39
|
+
volume_type = "<%= block_device.volume_type %>"
|
40
|
+
volume_size = <%= block_device.size %>
|
41
|
+
delete_on_termination = <%= mapping.ebs.delete_on_termination %>
|
42
|
+
<%- if block_device.volume_type == "io1" && block_device.iops -%>
|
43
|
+
iops = <%= block_device.iops %>
|
44
|
+
<%- end -%>
|
45
|
+
}
|
46
|
+
<% end -%>
|
47
|
+
|
48
|
+
<% end -%>
|
49
|
+
tags {
|
50
|
+
<% instance.tags.each do |tag| -%>
|
51
|
+
"<%= tag.key %>" = "<%= tag.value %>"
|
52
|
+
<% end -%>
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
<% end -%>
|