cf_factory 0.0.2
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.
- data/examples/base_vpc.rb +40 -0
- data/examples/cloudinit_script_for_one_instance.rb +77 -0
- data/examples/cloudinit_script_with_autoscaling.rb +85 -0
- data/examples/elb_with_cloudfront.rb +101 -0
- data/examples/instance_with_eip.rb +38 -0
- data/examples/instance_with_yum.rb +38 -0
- data/examples/just_an_instance.rb +29 -0
- data/examples/play_with_region_and_zones.rb +26 -0
- data/examples/ra_web_hosting.rb +146 -0
- data/examples/s3_with_cloudfront.rb +36 -0
- data/examples/test_vpc.rb +53 -0
- data/lib/cf_factory/as/cf_as_group.rb +75 -0
- data/lib/cf_factory/as/cf_as_launch_config.rb +53 -0
- data/lib/cf_factory/as/cf_as_scaling_policy.rb +33 -0
- data/lib/cf_factory/base/cf_base.rb +97 -0
- data/lib/cf_factory/base/cf_ec2_tag.rb +32 -0
- data/lib/cf_factory/base/cf_generator.rb +18 -0
- data/lib/cf_factory/base/cf_helper.rb +91 -0
- data/lib/cf_factory/base/cf_inner.rb +55 -0
- data/lib/cf_factory/base/cf_main.rb +101 -0
- data/lib/cf_factory/base/cf_mapping.rb +26 -0
- data/lib/cf_factory/base/cf_named_inner.rb +0 -0
- data/lib/cf_factory/base/cf_output.rb +24 -0
- data/lib/cf_factory/base/cf_parameter.rb +25 -0
- data/lib/cf_factory/base/cf_script_reader.rb +32 -0
- data/lib/cf_factory/cloudformation/cf_cloud_formation_init.rb +25 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_command.rb +37 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_commands.rb +25 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_config.rb +33 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_file.rb +38 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_files.rb +25 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_inner.rb +28 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_package.rb +34 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_packages.rb +42 -0
- data/lib/cf_factory/cloudformation/cf_cloudformation_sources.rb +30 -0
- data/lib/cf_factory/cloudformation/cf_init_script.rb +73 -0
- data/lib/cf_factory/cloudfront/cf_cache_behavior.rb +37 -0
- data/lib/cf_factory/cloudfront/cf_cache_behaviors.rb +28 -0
- data/lib/cf_factory/cloudfront/cf_cloudfront_distribution.rb +64 -0
- data/lib/cf_factory/cloudfront/cf_custom_origin_config.rb +37 -0
- data/lib/cf_factory/cloudfront/cf_default_cache_behavior.rb +32 -0
- data/lib/cf_factory/cloudfront/cf_distribution_config.rb +31 -0
- data/lib/cf_factory/cloudfront/cf_forwarded_values.rb +25 -0
- data/lib/cf_factory/cloudfront/cf_logging.rb +24 -0
- data/lib/cf_factory/cloudfront/cf_origin.rb +40 -0
- data/lib/cf_factory/cloudfront/cf_s3_origin_config.rb +25 -0
- data/lib/cf_factory/cloudwatch/cf_cloud_watch_alarm.rb +58 -0
- data/lib/cf_factory/ec2/cf_ebs_volume.rb +54 -0
- data/lib/cf_factory/ec2/cf_ec2_instance.rb +62 -0
- data/lib/cf_factory/ec2/cf_ec2_security_group.rb +40 -0
- data/lib/cf_factory/ec2/cf_ec2_security_group_egress.rb +28 -0
- data/lib/cf_factory/ec2/cf_ec2_security_group_ingress.rb +39 -0
- data/lib/cf_factory/ec2/cf_eip.rb +26 -0
- data/lib/cf_factory/ec2/cf_eip_association.rb +29 -0
- data/lib/cf_factory/elb/cf_app_cookie_stickiness_policy.rb +15 -0
- data/lib/cf_factory/elb/cf_elb.rb +49 -0
- data/lib/cf_factory/elb/cf_health_check.rb +23 -0
- data/lib/cf_factory/elb/cf_lb_cookie_stickiness_policy.rb +15 -0
- data/lib/cf_factory/elb/cf_listener.rb +26 -0
- data/lib/cf_factory/help/fixes.rb +14 -0
- data/lib/cf_factory/help/ip_mask.rb +165 -0
- data/lib/cf_factory/help/template_validation.rb +28 -0
- data/lib/cf_factory/iam/cf_iam_access_key.rb +32 -0
- data/lib/cf_factory/iam/cf_iam_group.rb +30 -0
- data/lib/cf_factory/iam/cf_iam_instance_profile.rb +30 -0
- data/lib/cf_factory/iam/cf_iam_policy.rb +18 -0
- data/lib/cf_factory/iam/cf_iam_role.rb +56 -0
- data/lib/cf_factory/iam/cf_iam_statement.rb +23 -0
- data/lib/cf_factory/iam/cf_iam_user.rb +34 -0
- data/lib/cf_factory/iam/cf_policy_document.rb +19 -0
- data/lib/cf_factory/modules/base_vpc.rb +61 -0
- data/lib/cf_factory/rds/cf_rds_instance.rb +53 -0
- data/lib/cf_factory/rds/cf_rds_security_group.rb +33 -0
- data/lib/cf_factory/rds/cf_rds_security_group_ingress.rb +29 -0
- data/lib/cf_factory/rds/cf_rds_subnet_group.rb +29 -0
- data/lib/cf_factory/route53/cf_elb_alias_target.rb +21 -0
- data/lib/cf_factory/route53/cf_record_set.rb +61 -0
- data/lib/cf_factory/route53/cf_route53_record_set.rb +61 -0
- data/lib/cf_factory/route53/cf_route53_record_set_group.rb +42 -0
- data/lib/cf_factory/s3/cf_s3_bucket.rb +32 -0
- data/lib/cf_factory/s3/cf_web_site_config.rb +24 -0
- data/lib/cf_factory/sqs/cf_sqs_queue.rb +26 -0
- data/lib/cf_factory/vpc/cf_attach_gateway.rb +28 -0
- data/lib/cf_factory/vpc/cf_internet_gateway.rb +30 -0
- data/lib/cf_factory/vpc/cf_network_acl.rb +39 -0
- data/lib/cf_factory/vpc/cf_network_acl_association.rb +24 -0
- data/lib/cf_factory/vpc/cf_network_acl_entry.rb +37 -0
- data/lib/cf_factory/vpc/cf_route.rb +43 -0
- data/lib/cf_factory/vpc/cf_route_table.rb +41 -0
- data/lib/cf_factory/vpc/cf_route_table_association.rb +24 -0
- data/lib/cf_factory/vpc/cf_subnet.rb +48 -0
- data/lib/cf_factory/vpc/cf_vpc.rb +64 -0
- data/lib/cf_factory.rb +103 -0
- metadata +140 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfLogging
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
attr_reader(:id)
|
|
7
|
+
|
|
8
|
+
def additional_indent
|
|
9
|
+
4
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize(bucket, prefix)
|
|
13
|
+
@bucket = bucket
|
|
14
|
+
@prefix = prefix
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_cf_attributes
|
|
18
|
+
result = {}
|
|
19
|
+
result["Bucket"] = @bucket.retrieve_attribute("DomainName")
|
|
20
|
+
result["Prefix"] = @prefix
|
|
21
|
+
result
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfOrigin
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
attr_reader(:id)
|
|
7
|
+
|
|
8
|
+
def additional_indent
|
|
9
|
+
4
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize(domain_name, id, origin, options = {})
|
|
13
|
+
@domain_name = domain_name
|
|
14
|
+
@id = id
|
|
15
|
+
@origin = origin
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.create_s3_origin(s3_bucket, options = {})
|
|
19
|
+
s3_origin_config = CfS3OriginConfig.new
|
|
20
|
+
CfOrigin.new(s3_bucket.short_domain_name(),s3_bucket.generate_ref,s3_origin_config, options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.create_elb_origin(elb, options = {})
|
|
24
|
+
custom_origin_config = CfCustomOriginConfig.new("http-only")
|
|
25
|
+
CfOrigin.new(elb.retrieve_attribute("DNSName"),elb.generate_ref,custom_origin_config, options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_cf_attributes
|
|
29
|
+
result = {}
|
|
30
|
+
result["DomainName"] = @domain_name
|
|
31
|
+
result["Id"] = id
|
|
32
|
+
if @origin.is_custom?
|
|
33
|
+
result["CustomOriginConfig"] = @origin.generate
|
|
34
|
+
else
|
|
35
|
+
result["S3OriginConfig"] = @origin.generate
|
|
36
|
+
end
|
|
37
|
+
result
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfS3OriginConfig
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def additional_indent
|
|
7
|
+
6
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def initialize(options = {})
|
|
12
|
+
@origin_access_identity = options[:origin_access_identity]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_cf_attributes
|
|
16
|
+
result = {}
|
|
17
|
+
result["OriginAccessIdentity"] = @origin_access_identity unless @origin_access_identify.nil?
|
|
18
|
+
result
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def is_custom?
|
|
22
|
+
false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
require 'cf_factory/base/cf_helper'
|
|
3
|
+
|
|
4
|
+
class CfCloudWatchAlarm
|
|
5
|
+
include CfBase
|
|
6
|
+
|
|
7
|
+
GREATER_THAN_OR_EQUAL_TO_THRESHOLD = "GreaterThanOrEqualToThreshold"
|
|
8
|
+
GREATER_THAN_THRESHOLD = "GreaterThanThreshold"
|
|
9
|
+
LESS_THAN_THRESHOLD = "LessThanThreshold"
|
|
10
|
+
LESS_THAN_OR_EQUAL_TO_THRESHOLD = "LessThanOrEqualToThreshold"
|
|
11
|
+
|
|
12
|
+
def initialize(name, comparison_operator, evaluation_periods, metric_name, metric_name_space,
|
|
13
|
+
period, statistic, threshold, options = {})
|
|
14
|
+
@name = name
|
|
15
|
+
@comparison_operator = comparison_operator
|
|
16
|
+
@evaluation_periods = evaluation_periods
|
|
17
|
+
@metric_name = metric_name
|
|
18
|
+
@metric_name_space = metric_name_space
|
|
19
|
+
@period = period
|
|
20
|
+
@statistic = statistic
|
|
21
|
+
@threshold = threshold
|
|
22
|
+
#TODO: optional values
|
|
23
|
+
@alarm_actions = options[:alarm_actions]
|
|
24
|
+
validate()
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def validate
|
|
28
|
+
if ![GREATER_THAN_OR_EQUAL_TO_THRESHOLD, GREATER_THAN_THRESHOLD, LESS_THAN_OR_EQUAL_TO_THRESHOLD, LESS_THAN_THRESHOLD].include?(@comparison_operator)
|
|
29
|
+
raise Exception.new("comparison operator #{@comparison_operator} not valid")
|
|
30
|
+
end
|
|
31
|
+
if !["SampleCount", "Average", "Sum", "Minimum", "Maximum"].include?(@statistic)
|
|
32
|
+
raise Exception.new("statistic #{@statistic} not a valid value")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_cf_type
|
|
37
|
+
"AWS::CloudWatch::Alarm"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_cf_attributes
|
|
41
|
+
{}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_cf_properties
|
|
45
|
+
result = {
|
|
46
|
+
"ComparisonOperator" => @comparison_operator,
|
|
47
|
+
"EvaluationPeriods" => @evaluation_periods,
|
|
48
|
+
"MetricName" => @metric_name,
|
|
49
|
+
"Namespace" => @metric_name_space,
|
|
50
|
+
"Period" => @period,
|
|
51
|
+
"Statistic" => @statistic,
|
|
52
|
+
"Threshold" => @threshold
|
|
53
|
+
}
|
|
54
|
+
result["AlarmActions"] = CfHelper.generate_ref_array(@alarm_actions) unless @alarm_actions.nil?
|
|
55
|
+
result
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
class CfEbsVolume
|
|
3
|
+
include CfBase
|
|
4
|
+
|
|
5
|
+
def initialize(name, availability_zone, options = {})
|
|
6
|
+
@name = name
|
|
7
|
+
@availability_zone = availability_zone
|
|
8
|
+
|
|
9
|
+
@size = options[:size]
|
|
10
|
+
@snapshot_id = options[:snapshot_id]
|
|
11
|
+
@iops = options[:iops]
|
|
12
|
+
@volume_type = options[:volume_type]
|
|
13
|
+
set_deletion_policy("Delete")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.create_normal(name, availability_zone, size)
|
|
17
|
+
CfEbsVolume.new(name, availability_zone, {:size => size})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.create_piops(name, availability_zone, size, iops)
|
|
21
|
+
CfEbsVolume.new(name, availability_zone, {:size => size, :volume_type => "io1", :iops => iops})
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.create_from_snapshot(name, availability_zone, snapshot_id)
|
|
25
|
+
CfEbsVolume.new(name, availability_zone, {:snapshot_id => snapshot_id})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def set_tags(tag_list)
|
|
29
|
+
@tag_list = tag_list
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def set_deletion_policy(deletion_policy)
|
|
33
|
+
@deletion_policy = deletion_policy
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_cf_type
|
|
37
|
+
"AWS::EC2::Volume"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_cf_attributes
|
|
41
|
+
result = super
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_cf_properties
|
|
45
|
+
result = {}
|
|
46
|
+
result["AvailabilityZone"] = @availability_zone
|
|
47
|
+
result["Size"] = @size unless @size.nil?
|
|
48
|
+
result["VolumeType"] = @volume_type unless @volume_type.nil?
|
|
49
|
+
result["SnapshotId"] = @snapshot_id unless @snapshot_id.nil?
|
|
50
|
+
result["Iops"] = @iops unless @iops.nil?
|
|
51
|
+
result
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
class CfEc2Instance
|
|
3
|
+
SUPPORTED_TYPES = ["t1.micro","m1.small","m1.medium","m1.large","m1.xlarge",
|
|
4
|
+
"m2.xlarge","m2.2xlarge","m2.4xlarge","m3.xlarge","m3.2xlarge","c1.medium", "c1.xlarge",
|
|
5
|
+
"cc1.4xlarge","cc2.8xlarge", "cg1.4xlarge", "hi1.4xlarge"]
|
|
6
|
+
include CfBase
|
|
7
|
+
|
|
8
|
+
def initialize(name, image_id, instance_type, options = {})
|
|
9
|
+
@name = name
|
|
10
|
+
@image_id = image_id
|
|
11
|
+
@instance_type = instance_type
|
|
12
|
+
@keyname = options[:keyname]
|
|
13
|
+
@subnet = options[:subnet]
|
|
14
|
+
@vpc_security_groups = options[:vpc_security_groups]
|
|
15
|
+
@security_groups = options[:security_groups]
|
|
16
|
+
@source_dest_check = options[:source_dest_check]
|
|
17
|
+
@user_data = options[:user_data]
|
|
18
|
+
@availability_zone = options[:availability_zone]
|
|
19
|
+
validate()
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def set_tags(tag_list)
|
|
23
|
+
@tag_list = tag_list
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_deletion_policy(deletion_policy)
|
|
27
|
+
@deletion_policy = deletion_policy
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_cf_type
|
|
31
|
+
"AWS::EC2::Instance"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_cf_attributes
|
|
35
|
+
result = super
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_cf_properties
|
|
39
|
+
result = {"ImageId" => CfHelper.clean(@image_id),
|
|
40
|
+
"InstanceType" => @instance_type,
|
|
41
|
+
}
|
|
42
|
+
result["KeyName"] = @keyname unless @keyname.nil?
|
|
43
|
+
result["SubnetId"] = @subnet.generate_ref unless @subnet.nil?
|
|
44
|
+
result["SecurityGroupIds"] = CfHelper.generate_ref_array(@vpc_security_groups) unless @vpc_security_groups.nil?
|
|
45
|
+
result["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
|
|
46
|
+
result["SourceDestCheck"] = @source_dest_check unless @source_dest_check.nil?
|
|
47
|
+
result["UserData"] = CfHelper.base64(@user_data) unless @user_data.nil?
|
|
48
|
+
result["AvailabilityZone"] = @availability_zone unless @availability_zone.nil?
|
|
49
|
+
result
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def assign_eip
|
|
53
|
+
#TODo
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def validate
|
|
59
|
+
raise Exception.new("instance type not supported #{@instance_type}") unless SUPPORTED_TYPES.include?(@instance_type)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
class CfEc2SecurityGroup
|
|
3
|
+
include CfBase
|
|
4
|
+
|
|
5
|
+
def initialize(name, description, vpc = nil)
|
|
6
|
+
@name = name
|
|
7
|
+
@description = description
|
|
8
|
+
@vpc = vpc
|
|
9
|
+
@ingress_rules = []
|
|
10
|
+
@egress_rules = []
|
|
11
|
+
#TODO: already check name/description for invalid characters
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_cf_type
|
|
15
|
+
"AWS::EC2::SecurityGroup"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_cf_attributes
|
|
19
|
+
{}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get_cf_properties
|
|
23
|
+
result = {"GroupDescription" => @description}
|
|
24
|
+
result["VpcId"] = @vpc.generate_ref unless @vpc.nil?
|
|
25
|
+
ingress = CfHelper.generate_inner_array(@ingress_rules)
|
|
26
|
+
result["SecurityGroupIngress"] = ingress unless @ingress_rules.size == 0
|
|
27
|
+
egress = CfHelper.generate_inner_array(@egress_rules)
|
|
28
|
+
result["SecurityGroupEgress"] = egress unless @egress_rules.size == 0
|
|
29
|
+
result
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def add_ingress_rule(ingress_rule)
|
|
33
|
+
@ingress_rules << ingress_rule
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def add_egress_rule(egress_rule)
|
|
37
|
+
@egress_rules << egress_rule
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfEc2SecurityGroupEgress
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def additional_indent
|
|
7
|
+
2
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def initialize(ip_protocol, from_port, to_port, cidr = nil, dest_group = nil)
|
|
11
|
+
@ip_protocol = ip_protocol
|
|
12
|
+
@from_port = from_port
|
|
13
|
+
@to_port = to_port
|
|
14
|
+
@cidr = cidr
|
|
15
|
+
@dest_group = dest_group
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_cf_attributes
|
|
19
|
+
result = {}
|
|
20
|
+
result["CidrIp"] = @cidr unless @cidr.nil?
|
|
21
|
+
result["DestinationSecurityGroupId"] = @dest_group.generate_ref unless @dest_group.nil?
|
|
22
|
+
result["FromPort"] = @from_port
|
|
23
|
+
result["ToPort"] = @to_port
|
|
24
|
+
result["IpProtocol"] = @ip_protocol
|
|
25
|
+
result
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfEc2SecurityGroupIngress
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def additional_indent
|
|
7
|
+
2
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def initialize(ip_protocol, from_port, to_port, cidr = nil, source_group = nil, options = {})
|
|
11
|
+
@ip_protocol = ip_protocol
|
|
12
|
+
@from_port = from_port
|
|
13
|
+
@to_port = to_port
|
|
14
|
+
@cidr = cidr
|
|
15
|
+
@source_group = source_group
|
|
16
|
+
@source_group_owner_id = options[:source_group_owner_id]
|
|
17
|
+
@use_sg_id = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def set_use_sg_id(flag)
|
|
21
|
+
@use_sg_id = flag
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_cf_attributes
|
|
25
|
+
result = {}
|
|
26
|
+
result["CidrIp"] = @cidr unless @cidr.nil?
|
|
27
|
+
if @use_sg_id
|
|
28
|
+
result["SourceSecurityGroupId"] = @source_group.generate_ref unless @source_group.nil?
|
|
29
|
+
else
|
|
30
|
+
result["SourceSecurityGroupName"] = @source_group.generate_ref unless @source_group.nil?
|
|
31
|
+
end
|
|
32
|
+
result["SourceSecurityGroupOwnerId"] = @source_group_owner_id unless @source_group_owner_id.nil?
|
|
33
|
+
result["FromPort"] = @from_port
|
|
34
|
+
result["ToPort"] = @to_port
|
|
35
|
+
result["IpProtocol"] = @ip_protocol
|
|
36
|
+
result
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
class CfEip
|
|
3
|
+
include CfBase
|
|
4
|
+
|
|
5
|
+
def initialize(name, instance = nil, is_vpc = false)
|
|
6
|
+
@name = name
|
|
7
|
+
@instance = instance
|
|
8
|
+
@domain = is_vpc ? "vpc" : nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def get_cf_type
|
|
12
|
+
"AWS::EC2::EIP"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_cf_attributes
|
|
16
|
+
{}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_cf_properties
|
|
20
|
+
result = {}
|
|
21
|
+
result["InstanceId"] = @instance.generate_ref unless @instance.nil?
|
|
22
|
+
result["Domain"] = @domain unless @domain.nil?
|
|
23
|
+
result
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
|
|
3
|
+
class CfEipAssociation
|
|
4
|
+
include CfBase
|
|
5
|
+
|
|
6
|
+
def initialize(name, eip, instance, network_interface, is_vpc = false) #TODO: network interface
|
|
7
|
+
@name = name
|
|
8
|
+
@eip = eip
|
|
9
|
+
@instance = instance
|
|
10
|
+
@is_vpc = is_vpc
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_cf_type
|
|
14
|
+
"AWS::EC2::EIPAssociation"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_cf_attributes
|
|
18
|
+
{}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get_cf_properties
|
|
22
|
+
result = {}
|
|
23
|
+
result["InstanceId"] = @instance.generate_ref unless @instance.nil?
|
|
24
|
+
result["EIP"] = @eip.generate_ref unless @is_vpc
|
|
25
|
+
result["AllocationId"] = @eip.retrieve_attribute("AllocationId") if @is_vpc
|
|
26
|
+
result
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfAppCookieStickinessPolicy
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def initialize(cookie_name, policy_name)
|
|
7
|
+
@cookie_name = cookie_name
|
|
8
|
+
@policy_name = policy_name
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def get_cf_attributes
|
|
12
|
+
{"CookieName" => @cookie_name, "PolicyName" => @policy_name}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_base'
|
|
2
|
+
require 'cf_factory/base/cf_helper'
|
|
3
|
+
require 'cf_factory/elb/cf_app_cookie_stickiness_policy'
|
|
4
|
+
|
|
5
|
+
class CfElb
|
|
6
|
+
include CfBase
|
|
7
|
+
|
|
8
|
+
def initialize(name, options)
|
|
9
|
+
@name = name
|
|
10
|
+
@app_cookie_stickiness_policy = options[:app_cookie_stickiness_policy]
|
|
11
|
+
@lb_cookie_stickiness_policy = options[:lb_cookie_stickiness_policy]
|
|
12
|
+
@availability_zones = options[:availability_zones]
|
|
13
|
+
@subnets = options[:subnets]
|
|
14
|
+
@health_check = options[:health_check]
|
|
15
|
+
@listeners = options[:listeners]
|
|
16
|
+
@is_internal = options[:is_internal] || false
|
|
17
|
+
@security_groups = options[:security_groups]
|
|
18
|
+
@instances = options[:instances]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get_cf_type
|
|
22
|
+
"AWS::ElasticLoadBalancing::LoadBalancer"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def set_tags(tag_list)
|
|
26
|
+
@tag_list = tag_list
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def get_cf_attributes
|
|
30
|
+
{}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_cf_properties
|
|
34
|
+
optional = {}
|
|
35
|
+
optional["AppCookieStickinessPolicy"] = CfHelper.generate_inner_array(@app_cookie_stickiness_policy) unless @app_cookie_stickiness_policy.nil?
|
|
36
|
+
optional["LBCookieStickinessPolicy"] = CfHelper.generate_inner_array(@lb_cookie_stickiness_policy) unless @lb_cookie_stickiness_policy.nil?
|
|
37
|
+
optional["AvailabilityZones"] = @availability_zones unless @availability_zones.nil?
|
|
38
|
+
optional["Subnets"] = CfHelper.generate_ref_array(@subnets) unless @subnets.nil?
|
|
39
|
+
optional["HealthCheck"] = @health_check.generate
|
|
40
|
+
optional["Listeners"] = CfHelper.generate_inner_array(@listeners) unless @listeners.nil? || @listeners.size == 0
|
|
41
|
+
optional["Scheme"] = "internal" if @is_internal
|
|
42
|
+
optional["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
|
|
43
|
+
optional["Instances"] = CfHelper.generate_ref_array(@instances) unless @instances.nil?
|
|
44
|
+
all = {}
|
|
45
|
+
all.merge!(optional)
|
|
46
|
+
return all
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfHealthCheck
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def initialize(healthy_threshold, interval, target, timeout, unhealthy_threshold)
|
|
7
|
+
@healthy_threshold = healthy_threshold
|
|
8
|
+
@interval = interval
|
|
9
|
+
@target = target
|
|
10
|
+
@timeout = timeout
|
|
11
|
+
@unhealthy_threshold = unhealthy_threshold
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_cf_attributes
|
|
15
|
+
{"HealthyThreshold" => @healthy_threshold,
|
|
16
|
+
"Interval" => @interval,
|
|
17
|
+
"Target" => @target,
|
|
18
|
+
"Timeout" => @timeout,
|
|
19
|
+
"UnhealthyThreshold" => @unhealthy_threshold
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfLbCookieStickinessPolicy
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def initialize(cookie_expiration_period, policy_name)
|
|
7
|
+
@cookie_expiration_period = cookie_expiration_period
|
|
8
|
+
@policy_name = policy_name
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def get_cf_attributes
|
|
12
|
+
{"CookieExpirationPeriod" => @cookie_expiration_period, "PolicyName" => @policy_name}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
|
2
|
+
|
|
3
|
+
class CfListener
|
|
4
|
+
include CfInner
|
|
5
|
+
|
|
6
|
+
def initialize(instance_port, instance_protocol, load_balancer_port, protocol, policy_names = nil, ssl_certificate_id = nil)
|
|
7
|
+
@instance_port = instance_port
|
|
8
|
+
@instance_protocol = instance_protocol
|
|
9
|
+
@load_balancer_port = load_balancer_port
|
|
10
|
+
@protocol = protocol
|
|
11
|
+
@policy_names = policy_names
|
|
12
|
+
@ssl_certificate_id = ssl_certificate_id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_cf_attributes
|
|
16
|
+
result = {"InstancePort" => @instance_port,
|
|
17
|
+
"InstanceProtocol" => @instance_protocol,
|
|
18
|
+
"LoadBalancerPort" => @load_balancer_port,
|
|
19
|
+
"Protocol" => @protocol,
|
|
20
|
+
}
|
|
21
|
+
result["PolicyNames"] = @policy_names unless @policy_names.nil?
|
|
22
|
+
result["SSLCertificateId"] = @ssl_certificate_id unless @ssl_certificate_id.nil?
|
|
23
|
+
result
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|