cf_factory 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. data/bin/cf_factory +9 -9
  2. data/examples/base_vpc.rb +40 -40
  3. data/examples/cloudfront_private.rb +23 -23
  4. data/examples/cloudinit_script_for_one_instance.rb +77 -77
  5. data/examples/cloudinit_script_with_autoscaling.rb +85 -85
  6. data/examples/dynamodb_table.rb +24 -24
  7. data/examples/elastic_beanstalk_example.rb +23 -23
  8. data/examples/elb_with_cloudfront.rb +100 -100
  9. data/examples/instance_with_eip.rb +40 -40
  10. data/examples/instance_with_yum.rb +40 -40
  11. data/examples/just_an_instance.rb +31 -31
  12. data/examples/nat_mutual_monitoring.rb +69 -69
  13. data/examples/play_with_region_and_zones.rb +28 -28
  14. data/examples/ra_web_hosting.rb +148 -148
  15. data/examples/s3_with_cloudfront.rb +35 -35
  16. data/examples/test_vpc.rb +61 -61
  17. data/lib/cf_factory/as/cf_as_group.rb +80 -77
  18. data/lib/cf_factory/as/cf_as_launch_config.rb +55 -55
  19. data/lib/cf_factory/as/cf_as_scaling_policy.rb +35 -35
  20. data/lib/cf_factory/as/cf_as_update_policy.rb +23 -0
  21. data/lib/cf_factory/base/cf_base.rb +112 -102
  22. data/lib/cf_factory/base/cf_ec2_tag.rb +34 -34
  23. data/lib/cf_factory/base/cf_generator.rb +20 -20
  24. data/lib/cf_factory/base/cf_helper.rb +93 -93
  25. data/lib/cf_factory/base/cf_inner.rb +74 -74
  26. data/lib/cf_factory/base/cf_main.rb +103 -103
  27. data/lib/cf_factory/base/cf_mapping.rb +28 -28
  28. data/lib/cf_factory/base/cf_named_inner.rb +70 -1
  29. data/lib/cf_factory/base/cf_output.rb +26 -26
  30. data/lib/cf_factory/base/cf_parameter.rb +27 -27
  31. data/lib/cf_factory/base/cf_script_reader.rb +34 -34
  32. data/lib/cf_factory/cloudformation/cf_cloud_formation_init.rb +27 -27
  33. data/lib/cf_factory/cloudformation/cf_cloudformation_command.rb +39 -39
  34. data/lib/cf_factory/cloudformation/cf_cloudformation_commands.rb +27 -27
  35. data/lib/cf_factory/cloudformation/cf_cloudformation_config.rb +35 -35
  36. data/lib/cf_factory/cloudformation/cf_cloudformation_file.rb +40 -40
  37. data/lib/cf_factory/cloudformation/cf_cloudformation_files.rb +27 -27
  38. data/lib/cf_factory/cloudformation/cf_cloudformation_inner.rb +30 -30
  39. data/lib/cf_factory/cloudformation/cf_cloudformation_package.rb +36 -36
  40. data/lib/cf_factory/cloudformation/cf_cloudformation_packages.rb +44 -44
  41. data/lib/cf_factory/cloudformation/cf_cloudformation_sources.rb +32 -32
  42. data/lib/cf_factory/cloudformation/cf_init_script.rb +80 -80
  43. data/lib/cf_factory/cloudfront/cf_cache_behavior.rb +39 -39
  44. data/lib/cf_factory/cloudfront/cf_cache_behaviors.rb +30 -30
  45. data/lib/cf_factory/cloudfront/cf_cloudfront_distribution.rb +66 -66
  46. data/lib/cf_factory/cloudfront/cf_custom_origin_config.rb +39 -39
  47. data/lib/cf_factory/cloudfront/cf_default_cache_behavior.rb +34 -34
  48. data/lib/cf_factory/cloudfront/cf_distribution_config.rb +33 -33
  49. data/lib/cf_factory/cloudfront/cf_forwarded_values.rb +27 -27
  50. data/lib/cf_factory/cloudfront/cf_logging.rb +26 -26
  51. data/lib/cf_factory/cloudfront/cf_origin.rb +42 -42
  52. data/lib/cf_factory/cloudfront/cf_s3_origin_config.rb +27 -27
  53. data/lib/cf_factory/cloudwatch/cf_cloud_watch_alarm.rb +60 -60
  54. data/lib/cf_factory/dynamo/cf_dynamo_table.rb +45 -45
  55. data/lib/cf_factory/eb/cd_eb_solution_stack.rb +27 -28
  56. data/lib/cf_factory/eb/cf_eb_application.rb +41 -41
  57. data/lib/cf_factory/eb/cf_eb_application_version.rb +24 -24
  58. data/lib/cf_factory/eb/cf_eb_configuration_template.rb +36 -36
  59. data/lib/cf_factory/eb/cf_eb_environment.rb +56 -56
  60. data/lib/cf_factory/eb/cf_eb_option_setting.rb +19 -19
  61. data/lib/cf_factory/ec2/cf_ebs_volume.rb +56 -56
  62. data/lib/cf_factory/ec2/cf_ec2_instance.rb +80 -66
  63. data/lib/cf_factory/ec2/cf_ec2_security_group.rb +42 -42
  64. data/lib/cf_factory/ec2/cf_ec2_security_group_egress.rb +30 -30
  65. data/lib/cf_factory/ec2/cf_ec2_security_group_ingress.rb +41 -41
  66. data/lib/cf_factory/ec2/cf_eip.rb +28 -28
  67. data/lib/cf_factory/ec2/cf_eip_association.rb +33 -31
  68. data/lib/cf_factory/ec2/cf_inner_network_interface.rb +26 -0
  69. data/lib/cf_factory/ec2/cf_network_interface.rb +40 -0
  70. data/lib/cf_factory/elb/cf_app_cookie_stickiness_policy.rb +17 -17
  71. data/lib/cf_factory/elb/cf_elb.rb +51 -51
  72. data/lib/cf_factory/elb/cf_health_check.rb +25 -25
  73. data/lib/cf_factory/elb/cf_lb_cookie_stickiness_policy.rb +17 -17
  74. data/lib/cf_factory/elb/cf_listener.rb +28 -28
  75. data/lib/cf_factory/help/fixes.rb +15 -15
  76. data/lib/cf_factory/help/ip_mask.rb +167 -167
  77. data/lib/cf_factory/help/template_validation.rb +30 -30
  78. data/lib/cf_factory/iam/cf_iam_access_key.rb +34 -34
  79. data/lib/cf_factory/iam/cf_iam_group.rb +32 -32
  80. data/lib/cf_factory/iam/cf_iam_instance_profile.rb +32 -32
  81. data/lib/cf_factory/iam/cf_iam_policy.rb +20 -20
  82. data/lib/cf_factory/iam/cf_iam_role.rb +58 -58
  83. data/lib/cf_factory/iam/cf_iam_statement.rb +25 -25
  84. data/lib/cf_factory/iam/cf_iam_user.rb +36 -36
  85. data/lib/cf_factory/iam/cf_policy_document.rb +21 -21
  86. data/lib/cf_factory/modules/base_vpc.rb +63 -63
  87. data/lib/cf_factory/rds/cf_rds_instance.rb +55 -55
  88. data/lib/cf_factory/rds/cf_rds_security_group.rb +35 -35
  89. data/lib/cf_factory/rds/cf_rds_security_group_ingress.rb +31 -31
  90. data/lib/cf_factory/rds/cf_rds_subnet_group.rb +31 -31
  91. data/lib/cf_factory/route53/cf_elb_alias_target.rb +23 -23
  92. data/lib/cf_factory/route53/cf_record_set.rb +63 -63
  93. data/lib/cf_factory/route53/cf_route53_record_set.rb +63 -63
  94. data/lib/cf_factory/route53/cf_route53_record_set_group.rb +44 -44
  95. data/lib/cf_factory/s3/cf_s3_bucket.rb +34 -34
  96. data/lib/cf_factory/s3/cf_web_site_config.rb +26 -26
  97. data/lib/cf_factory/sqs/cf_sqs_queue.rb +28 -28
  98. data/lib/cf_factory/vpc/cf_attach_gateway.rb +30 -30
  99. data/lib/cf_factory/vpc/cf_internet_gateway.rb +32 -32
  100. data/lib/cf_factory/vpc/cf_network_acl.rb +41 -41
  101. data/lib/cf_factory/vpc/cf_network_acl_association.rb +26 -26
  102. data/lib/cf_factory/vpc/cf_network_acl_entry.rb +39 -39
  103. data/lib/cf_factory/vpc/cf_route.rb +45 -45
  104. data/lib/cf_factory/vpc/cf_route_table.rb +43 -43
  105. data/lib/cf_factory/vpc/cf_route_table_association.rb +26 -26
  106. data/lib/cf_factory/vpc/cf_subnet.rb +50 -50
  107. data/lib/cf_factory/vpc/cf_vpc.rb +66 -66
  108. data/lib/cf_factory.rb +12 -12
  109. metadata +120 -91
@@ -1,56 +1,56 @@
1
- require 'cf_factory/base/cf_base'
2
- module CfFactory
3
- class CfEbsVolume
4
- include CfBase
5
-
6
- def initialize(name, availability_zone, options = {})
7
- @name = name
8
- @availability_zone = availability_zone
9
-
10
- @size = options[:size]
11
- @snapshot_id = options[:snapshot_id]
12
- @iops = options[:iops]
13
- @volume_type = options[:volume_type]
14
- set_deletion_policy("Delete")
15
- end
16
-
17
- def self.create_normal(name, availability_zone, size)
18
- CfEbsVolume.new(name, availability_zone, {:size => size})
19
- end
20
-
21
- def self.create_piops(name, availability_zone, size, iops)
22
- CfEbsVolume.new(name, availability_zone, {:size => size, :volume_type => "io1", :iops => iops})
23
- end
24
-
25
- def self.create_from_snapshot(name, availability_zone, snapshot_id)
26
- CfEbsVolume.new(name, availability_zone, {:snapshot_id => snapshot_id})
27
- end
28
-
29
- def set_tags(tag_list)
30
- @tag_list = tag_list
31
- end
32
-
33
- def set_deletion_policy(deletion_policy)
34
- @deletion_policy = deletion_policy
35
- end
36
-
37
- def get_cf_type
38
- "AWS::EC2::Volume"
39
- end
40
-
41
- def get_cf_attributes
42
- result = super
43
- end
44
-
45
- def get_cf_properties
46
- result = {}
47
- result["AvailabilityZone"] = @availability_zone
48
- result["Size"] = @size unless @size.nil?
49
- result["VolumeType"] = @volume_type unless @volume_type.nil?
50
- result["SnapshotId"] = @snapshot_id unless @snapshot_id.nil?
51
- result["Iops"] = @iops unless @iops.nil?
52
- result
53
- end
54
-
55
- end
56
- end
1
+ require 'cf_factory/base/cf_base'
2
+ module CfFactory
3
+ class CfEbsVolume
4
+ include CfBase
5
+
6
+ def initialize(name, availability_zone, options = {})
7
+ @name = name
8
+ @availability_zone = availability_zone
9
+
10
+ @size = options[:size]
11
+ @snapshot_id = options[:snapshot_id]
12
+ @iops = options[:iops]
13
+ @volume_type = options[:volume_type]
14
+ set_deletion_policy("Delete")
15
+ end
16
+
17
+ def self.create_normal(name, availability_zone, size)
18
+ CfEbsVolume.new(name, availability_zone, {:size => size})
19
+ end
20
+
21
+ def self.create_piops(name, availability_zone, size, iops)
22
+ CfEbsVolume.new(name, availability_zone, {:size => size, :volume_type => "io1", :iops => iops})
23
+ end
24
+
25
+ def self.create_from_snapshot(name, availability_zone, snapshot_id)
26
+ CfEbsVolume.new(name, availability_zone, {:snapshot_id => snapshot_id})
27
+ end
28
+
29
+ def set_tags(tag_list)
30
+ @tag_list = tag_list
31
+ end
32
+
33
+ def set_deletion_policy(deletion_policy)
34
+ @deletion_policy = deletion_policy
35
+ end
36
+
37
+ def get_cf_type
38
+ "AWS::EC2::Volume"
39
+ end
40
+
41
+ def get_cf_attributes
42
+ result = super
43
+ end
44
+
45
+ def get_cf_properties
46
+ result = {}
47
+ result["AvailabilityZone"] = @availability_zone
48
+ result["Size"] = @size unless @size.nil?
49
+ result["VolumeType"] = @volume_type unless @volume_type.nil?
50
+ result["SnapshotId"] = @snapshot_id unless @snapshot_id.nil?
51
+ result["Iops"] = @iops unless @iops.nil?
52
+ result
53
+ end
54
+
55
+ end
56
+ end
@@ -1,66 +1,80 @@
1
- require 'cf_factory/base/cf_base'
2
- module CfFactory
3
- class CfEc2Instance
4
- SUPPORTED_TYPES = ["t1.micro","m1.small","m1.medium","m1.large","m1.xlarge",
5
- "m2.xlarge","m2.2xlarge","m2.4xlarge","m3.xlarge","m3.2xlarge","c1.medium", "c1.xlarge",
6
- "cc1.4xlarge","cc2.8xlarge", "cg1.4xlarge", "hi1.4xlarge"]
7
- include CfBase
8
-
9
- def initialize(name, image_id, instance_type, options = {})
10
- @name = name
11
- @image_id = image_id
12
- @instance_type = instance_type
13
- @keyname = options[:keyname]
14
- @subnet = options[:subnet]
15
- @vpc_security_groups = options[:vpc_security_groups]
16
- @security_groups = options[:security_groups]
17
- @source_dest_check = options[:source_dest_check]
18
- @user_data = options[:user_data]
19
- @availability_zone = options[:availability_zone]
20
- validate()
21
- end
22
-
23
- def set_tags(tag_list)
24
- @tag_list = tag_list
25
- end
26
-
27
- def set_deletion_policy(deletion_policy)
28
- @deletion_policy = deletion_policy
29
- end
30
-
31
- def get_cf_type
32
- "AWS::EC2::Instance"
33
- end
34
-
35
- def get_cf_attributes
36
- result = super
37
- end
38
-
39
- def get_cf_properties
40
- result = {"ImageId" => CfHelper.clean(@image_id),
41
- "InstanceType" => @instance_type,
42
- }
43
- result["KeyName"] = @keyname unless @keyname.nil?
44
- result["SubnetId"] = @subnet.generate_ref unless @subnet.nil?
45
- result["SecurityGroupIds"] = CfHelper.generate_ref_array(@vpc_security_groups) unless @vpc_security_groups.nil?
46
- result["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
47
- result["SourceDestCheck"] = @source_dest_check unless @source_dest_check.nil?
48
- result["UserData"] = CfHelper.base64(@user_data) unless @user_data.nil?
49
- result["AvailabilityZone"] = @availability_zone unless @availability_zone.nil?
50
- result
51
- end
52
-
53
- def assign_eip
54
- #TODo
55
- end
56
-
57
- private
58
-
59
- def validate
60
- unless @instance_type.include?("Ref")
61
- raise Exception.new("instance type not supported #{@instance_type}") unless SUPPORTED_TYPES.include?(@instance_type)
62
- end
63
- end
64
-
65
- end
66
- end
1
+ require 'cf_factory/base/cf_base'
2
+ module CfFactory
3
+ class CfEc2Instance
4
+ SUPPORTED_TYPES = ["t1.micro","m1.small","m1.medium","m1.large","m1.xlarge",
5
+ "m2.xlarge","m2.2xlarge","m2.4xlarge","m3.xlarge","m3.2xlarge","c1.medium", "c1.xlarge",
6
+ "cc1.4xlarge","cc2.8xlarge", "cg1.4xlarge", "hi1.4xlarge"]
7
+ include CfBase
8
+
9
+ def initialize(name, image_id, instance_type, options = {})
10
+ @name = name
11
+ @image_id = image_id
12
+ @instance_type = instance_type
13
+ @keyname = options[:keyname]
14
+ @subnet = options[:subnet]
15
+ @vpc_security_groups = options[:vpc_security_groups]
16
+ @security_groups = options[:security_groups]
17
+ @source_dest_check = options[:source_dest_check]
18
+ @user_data = options[:user_data]
19
+ @availability_zone = options[:availability_zone]
20
+ @network_interfaces = options[:network_interfaces]
21
+ validate()
22
+ end
23
+
24
+ def set_tags(tag_list)
25
+ @tag_list = tag_list
26
+ end
27
+
28
+ def set_deletion_policy(deletion_policy)
29
+ @deletion_policy = deletion_policy
30
+ end
31
+
32
+ def get_cf_type
33
+ "AWS::EC2::Instance"
34
+ end
35
+
36
+ def get_cf_attributes
37
+ result = super
38
+ end
39
+
40
+ def get_cf_properties
41
+ result = {"ImageId" => CfHelper.clean(@image_id),
42
+ "InstanceType" => @instance_type,
43
+ }
44
+ result["KeyName"] = @keyname unless @keyname.nil?
45
+ result["SubnetId"] = @subnet.generate_ref unless @subnet.nil?
46
+ result["SecurityGroupIds"] = CfHelper.generate_ref_array(@vpc_security_groups) unless @vpc_security_groups.nil?
47
+ result["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
48
+ result["SourceDestCheck"] = @source_dest_check unless @source_dest_check.nil?
49
+ result["UserData"] = CfHelper.base64(@user_data) unless @user_data.nil?
50
+ result["AvailabilityZone"] = @availability_zone unless @availability_zone.nil?
51
+ if !@network_interfaces.nil? && @network_interfaces.size > 0
52
+ nics = []
53
+ index = 0
54
+ @network_interfaces.each() {|nic|
55
+ nics << CfFactory::CfInnerNetworkInterface.new(nic, index)
56
+ index += 1
57
+ }
58
+ result["NetworkInterfaces"] = CfHelper.generate_inner_array(nics)
59
+ end
60
+ result
61
+ end
62
+
63
+ def assign_eip
64
+ #TODo
65
+ end
66
+
67
+ private
68
+
69
+ def validate
70
+ unless @instance_type.include?("Ref")
71
+ raise Exception.new("instance type not supported #{@instance_type}") unless SUPPORTED_TYPES.include?(@instance_type)
72
+ end
73
+ unless @network_interfaces.nil?
74
+ raise Exception.new("no security group allowed when ENI specified") unless @security_groups.nil?
75
+ raise Exception.new("no subnet allowed when ENI specified") unless @subnet.nil?
76
+ end
77
+ end
78
+
79
+ end
80
+ end
@@ -1,42 +1,42 @@
1
- require 'cf_factory/base/cf_base'
2
- module CfFactory
3
- class CfEc2SecurityGroup
4
- include CfBase
5
-
6
- def initialize(name, description, vpc = nil)
7
- @name = name
8
- @description = description
9
- @vpc = vpc
10
- @ingress_rules = []
11
- @egress_rules = []
12
- #TODO: already check name/description for invalid characters
13
- end
14
-
15
- def get_cf_type
16
- "AWS::EC2::SecurityGroup"
17
- end
18
-
19
- def get_cf_attributes
20
- {}
21
- end
22
-
23
- def get_cf_properties
24
- result = {"GroupDescription" => @description}
25
- result["VpcId"] = @vpc.generate_ref unless @vpc.nil?
26
- ingress = CfHelper.generate_inner_array(@ingress_rules)
27
- result["SecurityGroupIngress"] = ingress unless @ingress_rules.size == 0
28
- egress = CfHelper.generate_inner_array(@egress_rules)
29
- result["SecurityGroupEgress"] = egress unless @egress_rules.size == 0
30
- result
31
- end
32
-
33
- def add_ingress_rule(ingress_rule)
34
- @ingress_rules << ingress_rule
35
- end
36
-
37
- def add_egress_rule(egress_rule)
38
- @egress_rules << egress_rule
39
- end
40
-
41
- end
42
- end
1
+ require 'cf_factory/base/cf_base'
2
+ module CfFactory
3
+ class CfEc2SecurityGroup
4
+ include CfBase
5
+
6
+ def initialize(name, description, vpc = nil)
7
+ @name = name
8
+ @description = description
9
+ @vpc = vpc
10
+ @ingress_rules = []
11
+ @egress_rules = []
12
+ #TODO: already check name/description for invalid characters
13
+ end
14
+
15
+ def get_cf_type
16
+ "AWS::EC2::SecurityGroup"
17
+ end
18
+
19
+ def get_cf_attributes
20
+ {}
21
+ end
22
+
23
+ def get_cf_properties
24
+ result = {"GroupDescription" => @description}
25
+ result["VpcId"] = @vpc.generate_ref unless @vpc.nil?
26
+ ingress = CfHelper.generate_inner_array(@ingress_rules)
27
+ result["SecurityGroupIngress"] = ingress unless @ingress_rules.size == 0
28
+ egress = CfHelper.generate_inner_array(@egress_rules)
29
+ result["SecurityGroupEgress"] = egress unless @egress_rules.size == 0
30
+ result
31
+ end
32
+
33
+ def add_ingress_rule(ingress_rule)
34
+ @ingress_rules << ingress_rule
35
+ end
36
+
37
+ def add_egress_rule(egress_rule)
38
+ @egress_rules << egress_rule
39
+ end
40
+
41
+ end
42
+ end
@@ -1,30 +1,30 @@
1
- require 'cf_factory/base/cf_inner'
2
-
3
- module CfFactory
4
- class CfEc2SecurityGroupEgress
5
- include CfInner
6
-
7
- def additional_indent
8
- 2
9
- end
10
-
11
- def initialize(ip_protocol, from_port, to_port, cidr = nil, dest_group = nil)
12
- @ip_protocol = ip_protocol
13
- @from_port = from_port
14
- @to_port = to_port
15
- @cidr = cidr
16
- @dest_group = dest_group
17
- end
18
-
19
- def get_cf_attributes
20
- result = {}
21
- result["CidrIp"] = @cidr unless @cidr.nil?
22
- result["DestinationSecurityGroupId"] = @dest_group.generate_ref unless @dest_group.nil?
23
- result["FromPort"] = @from_port
24
- result["ToPort"] = @to_port
25
- result["IpProtocol"] = @ip_protocol
26
- result
27
- end
28
-
29
- end
30
- end
1
+ require 'cf_factory/base/cf_inner'
2
+
3
+ module CfFactory
4
+ class CfEc2SecurityGroupEgress
5
+ include CfInner
6
+
7
+ def additional_indent
8
+ 2
9
+ end
10
+
11
+ def initialize(ip_protocol, from_port, to_port, cidr = nil, dest_group = nil)
12
+ @ip_protocol = ip_protocol
13
+ @from_port = from_port
14
+ @to_port = to_port
15
+ @cidr = cidr
16
+ @dest_group = dest_group
17
+ end
18
+
19
+ def get_cf_attributes
20
+ result = {}
21
+ result["CidrIp"] = @cidr unless @cidr.nil?
22
+ result["DestinationSecurityGroupId"] = @dest_group.generate_ref unless @dest_group.nil?
23
+ result["FromPort"] = @from_port
24
+ result["ToPort"] = @to_port
25
+ result["IpProtocol"] = @ip_protocol
26
+ result
27
+ end
28
+
29
+ end
30
+ end
@@ -1,41 +1,41 @@
1
- require 'cf_factory/base/cf_inner'
2
-
3
- module CfFactory
4
- class CfEc2SecurityGroupIngress
5
- include CfInner
6
-
7
- def additional_indent
8
- 2
9
- end
10
-
11
- def initialize(ip_protocol, from_port, to_port, cidr = nil, source_group = nil, options = {})
12
- @ip_protocol = ip_protocol
13
- @from_port = from_port
14
- @to_port = to_port
15
- @cidr = cidr
16
- @source_group = source_group
17
- @source_group_owner_id = options[:source_group_owner_id]
18
- @use_sg_id = true
19
- end
20
-
21
- def set_use_sg_id(flag)
22
- @use_sg_id = flag
23
- end
24
-
25
- def get_cf_attributes
26
- result = {}
27
- result["CidrIp"] = @cidr unless @cidr.nil?
28
- if @use_sg_id
29
- result["SourceSecurityGroupId"] = @source_group.generate_ref unless @source_group.nil?
30
- else
31
- result["SourceSecurityGroupName"] = @source_group.generate_ref unless @source_group.nil?
32
- end
33
- result["SourceSecurityGroupOwnerId"] = @source_group_owner_id unless @source_group_owner_id.nil?
34
- result["FromPort"] = @from_port
35
- result["ToPort"] = @to_port
36
- result["IpProtocol"] = @ip_protocol
37
- result
38
- end
39
-
40
- end
41
- end
1
+ require 'cf_factory/base/cf_inner'
2
+
3
+ module CfFactory
4
+ class CfEc2SecurityGroupIngress
5
+ include CfInner
6
+
7
+ def additional_indent
8
+ 2
9
+ end
10
+
11
+ def initialize(ip_protocol, from_port, to_port, cidr = nil, source_group = nil, options = {})
12
+ @ip_protocol = ip_protocol
13
+ @from_port = from_port
14
+ @to_port = to_port
15
+ @cidr = cidr
16
+ @source_group = source_group
17
+ @source_group_owner_id = options[:source_group_owner_id]
18
+ @use_sg_id = true
19
+ end
20
+
21
+ def set_use_sg_id(flag)
22
+ @use_sg_id = flag
23
+ end
24
+
25
+ def get_cf_attributes
26
+ result = {}
27
+ result["CidrIp"] = @cidr unless @cidr.nil?
28
+ if @use_sg_id
29
+ result["SourceSecurityGroupId"] = @source_group.generate_ref unless @source_group.nil?
30
+ else
31
+ result["SourceSecurityGroupName"] = @source_group.generate_ref unless @source_group.nil?
32
+ end
33
+ result["SourceSecurityGroupOwnerId"] = @source_group_owner_id unless @source_group_owner_id.nil?
34
+ result["FromPort"] = @from_port
35
+ result["ToPort"] = @to_port
36
+ result["IpProtocol"] = @ip_protocol
37
+ result
38
+ end
39
+
40
+ end
41
+ end
@@ -1,28 +1,28 @@
1
- require 'cf_factory/base/cf_base'
2
- module CfFactory
3
- class CfEip
4
- include CfBase
5
-
6
- def initialize(name, instance = nil, is_vpc = false)
7
- @name = name
8
- @instance = instance
9
- @domain = is_vpc ? "vpc" : nil
10
- end
11
-
12
- def get_cf_type
13
- "AWS::EC2::EIP"
14
- end
15
-
16
- def get_cf_attributes
17
- {}
18
- end
19
-
20
- def get_cf_properties
21
- result = {}
22
- result["InstanceId"] = @instance.generate_ref unless @instance.nil?
23
- result["Domain"] = @domain unless @domain.nil?
24
- result
25
- end
26
-
27
- end
28
- end
1
+ require 'cf_factory/base/cf_base'
2
+ module CfFactory
3
+ class CfEip
4
+ include CfBase
5
+
6
+ def initialize(name, instance = nil, is_vpc = false)
7
+ @name = name
8
+ @instance = instance
9
+ @domain = is_vpc ? "vpc" : nil
10
+ end
11
+
12
+ def get_cf_type
13
+ "AWS::EC2::EIP"
14
+ end
15
+
16
+ def get_cf_attributes
17
+ {}
18
+ end
19
+
20
+ def get_cf_properties
21
+ result = {}
22
+ result["InstanceId"] = @instance.generate_ref unless @instance.nil?
23
+ result["Domain"] = @domain unless @domain.nil?
24
+ result
25
+ end
26
+
27
+ end
28
+ end
@@ -1,31 +1,33 @@
1
- require 'cf_factory/base/cf_base'
2
-
3
- module CfFactory
4
- class CfEipAssociation
5
- include CfBase
6
-
7
- def initialize(name, eip, instance, network_interface, is_vpc = false) #TODO: network interface
8
- @name = name
9
- @eip = eip
10
- @instance = instance
11
- @is_vpc = is_vpc
12
- end
13
-
14
- def get_cf_type
15
- "AWS::EC2::EIPAssociation"
16
- end
17
-
18
- def get_cf_attributes
19
- {}
20
- end
21
-
22
- def get_cf_properties
23
- result = {}
24
- result["InstanceId"] = @instance.generate_ref unless @instance.nil?
25
- result["EIP"] = @eip.generate_ref unless @is_vpc
26
- result["AllocationId"] = @eip.retrieve_attribute("AllocationId") if @is_vpc
27
- result
28
- end
29
-
30
- end
31
- end
1
+ require 'cf_factory/base/cf_base'
2
+
3
+ module CfFactory
4
+ class CfEipAssociation
5
+ include CfBase
6
+
7
+ def initialize(name, options = {})
8
+ @name = name
9
+ @eip = options[:eip]
10
+ @instance = options[:instance]
11
+ @network_interface = options[:network_interface]
12
+ @is_vpc = options[:is_vpc] || false
13
+ end
14
+
15
+ def get_cf_type
16
+ "AWS::EC2::EIPAssociation"
17
+ end
18
+
19
+ def get_cf_attributes
20
+ {}
21
+ end
22
+
23
+ def get_cf_properties
24
+ result = {}
25
+ result["InstanceId"] = @instance.generate_ref unless @instance.nil?
26
+ result["EIP"] = @eip.generate_ref unless @is_vpc
27
+ result["AllocationId"] = @eip.retrieve_attribute("AllocationId") if @is_vpc
28
+ result["NetworkInterfaceId"] = @network_interface.generate_ref unless @network_interface.nil?
29
+ result
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ require 'cf_factory/base/cf_inner'
2
+
3
+ module CfFactory
4
+ class CfInnerNetworkInterface
5
+ include CfInner
6
+
7
+ def additional_indent
8
+ 2
9
+ end
10
+
11
+ def initialize(network_interface, device_index, options = {})
12
+ @network_interface = network_interface
13
+ @device_index = device_index
14
+ @delete_on_termination = options[:delete_on_termination]
15
+ end
16
+
17
+ def get_cf_attributes
18
+ result = {}
19
+ result["NetworkInterfaceId"] = @network_interface.generate_ref
20
+ result["DeviceIndex"] = @device_index
21
+ result["DeleteOnTermination"] = @delete_on_termination unless @delete_on_termination.nil?
22
+ result
23
+ end
24
+
25
+ end
26
+ end