cf_factory 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cf_factory +9 -9
- data/examples/base_vpc.rb +40 -40
- data/examples/cloudfront_private.rb +23 -23
- data/examples/cloudinit_script_for_one_instance.rb +77 -77
- data/examples/cloudinit_script_with_autoscaling.rb +85 -85
- data/examples/dynamodb_table.rb +24 -24
- data/examples/elastic_beanstalk_example.rb +23 -23
- data/examples/elb_with_cloudfront.rb +100 -100
- data/examples/instance_with_eip.rb +40 -40
- data/examples/instance_with_yum.rb +40 -40
- data/examples/just_an_instance.rb +31 -31
- data/examples/nat_mutual_monitoring.rb +69 -69
- data/examples/play_with_region_and_zones.rb +28 -28
- data/examples/ra_web_hosting.rb +148 -148
- data/examples/s3_with_cloudfront.rb +35 -35
- data/examples/test_vpc.rb +61 -61
- data/lib/cf_factory/as/cf_as_group.rb +80 -77
- data/lib/cf_factory/as/cf_as_launch_config.rb +55 -55
- data/lib/cf_factory/as/cf_as_scaling_policy.rb +35 -35
- data/lib/cf_factory/as/cf_as_update_policy.rb +23 -0
- data/lib/cf_factory/base/cf_base.rb +112 -102
- data/lib/cf_factory/base/cf_ec2_tag.rb +34 -34
- data/lib/cf_factory/base/cf_generator.rb +20 -20
- data/lib/cf_factory/base/cf_helper.rb +93 -93
- data/lib/cf_factory/base/cf_inner.rb +74 -74
- data/lib/cf_factory/base/cf_main.rb +103 -103
- data/lib/cf_factory/base/cf_mapping.rb +28 -28
- data/lib/cf_factory/base/cf_named_inner.rb +70 -1
- data/lib/cf_factory/base/cf_output.rb +26 -26
- data/lib/cf_factory/base/cf_parameter.rb +27 -27
- data/lib/cf_factory/base/cf_script_reader.rb +34 -34
- data/lib/cf_factory/cloudformation/cf_cloud_formation_init.rb +27 -27
- data/lib/cf_factory/cloudformation/cf_cloudformation_command.rb +39 -39
- data/lib/cf_factory/cloudformation/cf_cloudformation_commands.rb +27 -27
- data/lib/cf_factory/cloudformation/cf_cloudformation_config.rb +35 -35
- data/lib/cf_factory/cloudformation/cf_cloudformation_file.rb +40 -40
- data/lib/cf_factory/cloudformation/cf_cloudformation_files.rb +27 -27
- data/lib/cf_factory/cloudformation/cf_cloudformation_inner.rb +30 -30
- data/lib/cf_factory/cloudformation/cf_cloudformation_package.rb +36 -36
- data/lib/cf_factory/cloudformation/cf_cloudformation_packages.rb +44 -44
- data/lib/cf_factory/cloudformation/cf_cloudformation_sources.rb +32 -32
- data/lib/cf_factory/cloudformation/cf_init_script.rb +80 -80
- data/lib/cf_factory/cloudfront/cf_cache_behavior.rb +39 -39
- data/lib/cf_factory/cloudfront/cf_cache_behaviors.rb +30 -30
- data/lib/cf_factory/cloudfront/cf_cloudfront_distribution.rb +66 -66
- data/lib/cf_factory/cloudfront/cf_custom_origin_config.rb +39 -39
- data/lib/cf_factory/cloudfront/cf_default_cache_behavior.rb +34 -34
- data/lib/cf_factory/cloudfront/cf_distribution_config.rb +33 -33
- data/lib/cf_factory/cloudfront/cf_forwarded_values.rb +27 -27
- data/lib/cf_factory/cloudfront/cf_logging.rb +26 -26
- data/lib/cf_factory/cloudfront/cf_origin.rb +42 -42
- data/lib/cf_factory/cloudfront/cf_s3_origin_config.rb +27 -27
- data/lib/cf_factory/cloudwatch/cf_cloud_watch_alarm.rb +60 -60
- data/lib/cf_factory/dynamo/cf_dynamo_table.rb +45 -45
- data/lib/cf_factory/eb/cd_eb_solution_stack.rb +27 -28
- data/lib/cf_factory/eb/cf_eb_application.rb +41 -41
- data/lib/cf_factory/eb/cf_eb_application_version.rb +24 -24
- data/lib/cf_factory/eb/cf_eb_configuration_template.rb +36 -36
- data/lib/cf_factory/eb/cf_eb_environment.rb +56 -56
- data/lib/cf_factory/eb/cf_eb_option_setting.rb +19 -19
- data/lib/cf_factory/ec2/cf_ebs_volume.rb +56 -56
- data/lib/cf_factory/ec2/cf_ec2_instance.rb +80 -66
- data/lib/cf_factory/ec2/cf_ec2_security_group.rb +42 -42
- data/lib/cf_factory/ec2/cf_ec2_security_group_egress.rb +30 -30
- data/lib/cf_factory/ec2/cf_ec2_security_group_ingress.rb +41 -41
- data/lib/cf_factory/ec2/cf_eip.rb +28 -28
- data/lib/cf_factory/ec2/cf_eip_association.rb +33 -31
- data/lib/cf_factory/ec2/cf_inner_network_interface.rb +26 -0
- data/lib/cf_factory/ec2/cf_network_interface.rb +40 -0
- data/lib/cf_factory/elb/cf_app_cookie_stickiness_policy.rb +17 -17
- data/lib/cf_factory/elb/cf_elb.rb +51 -51
- data/lib/cf_factory/elb/cf_health_check.rb +25 -25
- data/lib/cf_factory/elb/cf_lb_cookie_stickiness_policy.rb +17 -17
- data/lib/cf_factory/elb/cf_listener.rb +28 -28
- data/lib/cf_factory/help/fixes.rb +15 -15
- data/lib/cf_factory/help/ip_mask.rb +167 -167
- data/lib/cf_factory/help/template_validation.rb +30 -30
- data/lib/cf_factory/iam/cf_iam_access_key.rb +34 -34
- data/lib/cf_factory/iam/cf_iam_group.rb +32 -32
- data/lib/cf_factory/iam/cf_iam_instance_profile.rb +32 -32
- data/lib/cf_factory/iam/cf_iam_policy.rb +20 -20
- data/lib/cf_factory/iam/cf_iam_role.rb +58 -58
- data/lib/cf_factory/iam/cf_iam_statement.rb +25 -25
- data/lib/cf_factory/iam/cf_iam_user.rb +36 -36
- data/lib/cf_factory/iam/cf_policy_document.rb +21 -21
- data/lib/cf_factory/modules/base_vpc.rb +63 -63
- data/lib/cf_factory/rds/cf_rds_instance.rb +55 -55
- data/lib/cf_factory/rds/cf_rds_security_group.rb +35 -35
- data/lib/cf_factory/rds/cf_rds_security_group_ingress.rb +31 -31
- data/lib/cf_factory/rds/cf_rds_subnet_group.rb +31 -31
- data/lib/cf_factory/route53/cf_elb_alias_target.rb +23 -23
- data/lib/cf_factory/route53/cf_record_set.rb +63 -63
- data/lib/cf_factory/route53/cf_route53_record_set.rb +63 -63
- data/lib/cf_factory/route53/cf_route53_record_set_group.rb +44 -44
- data/lib/cf_factory/s3/cf_s3_bucket.rb +34 -34
- data/lib/cf_factory/s3/cf_web_site_config.rb +26 -26
- data/lib/cf_factory/sqs/cf_sqs_queue.rb +28 -28
- data/lib/cf_factory/vpc/cf_attach_gateway.rb +30 -30
- data/lib/cf_factory/vpc/cf_internet_gateway.rb +32 -32
- data/lib/cf_factory/vpc/cf_network_acl.rb +41 -41
- data/lib/cf_factory/vpc/cf_network_acl_association.rb +26 -26
- data/lib/cf_factory/vpc/cf_network_acl_entry.rb +39 -39
- data/lib/cf_factory/vpc/cf_route.rb +45 -45
- data/lib/cf_factory/vpc/cf_route_table.rb +43 -43
- data/lib/cf_factory/vpc/cf_route_table_association.rb +26 -26
- data/lib/cf_factory/vpc/cf_subnet.rb +50 -50
- data/lib/cf_factory/vpc/cf_vpc.rb +66 -66
- data/lib/cf_factory.rb +12 -12
- metadata +120 -91
@@ -1,77 +1,80 @@
|
|
1
|
-
require 'cf_factory/base/cf_base'
|
2
|
-
require 'cf_factory/base/cf_helper'
|
3
|
-
|
4
|
-
module CfFactory
|
5
|
-
class CfAsGroup
|
6
|
-
include CfBase
|
7
|
-
|
8
|
-
def initialize(name, availability_zones, launch_config, load_balancers, max_size, min_size, options)
|
9
|
-
@name = name
|
10
|
-
@availability_zones = availability_zones
|
11
|
-
@launch_config = launch_config
|
12
|
-
@load_balancers = load_balancers
|
13
|
-
@max_size = max_size
|
14
|
-
@min_size = min_size
|
15
|
-
|
16
|
-
@cooldown = options[:cooldown]
|
17
|
-
@desired_capacity = options[:desired_capacity]
|
18
|
-
@health_check_grace_period = options[:health_check_grace_period]
|
19
|
-
@health_check_type = options[:health_check_type]
|
20
|
-
#TODO: NotificationConfiguration
|
21
|
-
@subnets = options[:subnets]
|
22
|
-
validate()
|
23
|
-
end
|
24
|
-
|
25
|
-
def set_tags(tag_list)
|
26
|
-
@tag_list = []
|
27
|
-
tag_list.each() {|tg|
|
28
|
-
tg2 = tg.clone
|
29
|
-
tg2.set_propagate_at_launch(true)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if @
|
41
|
-
raise Exception.new("
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
"
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
result["
|
64
|
-
result["
|
65
|
-
result
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
1
|
+
require 'cf_factory/base/cf_base'
|
2
|
+
require 'cf_factory/base/cf_helper'
|
3
|
+
|
4
|
+
module CfFactory
|
5
|
+
class CfAsGroup
|
6
|
+
include CfBase
|
7
|
+
|
8
|
+
def initialize(name, availability_zones, launch_config, load_balancers, max_size, min_size, options)
|
9
|
+
@name = name
|
10
|
+
@availability_zones = availability_zones
|
11
|
+
@launch_config = launch_config
|
12
|
+
@load_balancers = load_balancers
|
13
|
+
@max_size = max_size
|
14
|
+
@min_size = min_size
|
15
|
+
|
16
|
+
@cooldown = options[:cooldown]
|
17
|
+
@desired_capacity = options[:desired_capacity]
|
18
|
+
@health_check_grace_period = options[:health_check_grace_period]
|
19
|
+
@health_check_type = options[:health_check_type]
|
20
|
+
#TODO: NotificationConfiguration
|
21
|
+
@subnets = options[:subnets]
|
22
|
+
validate()
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_tags(tag_list)
|
26
|
+
@tag_list = []
|
27
|
+
tag_list.each() {|tg|
|
28
|
+
tg2 = tg.clone
|
29
|
+
tg2.set_propagate_at_launch(true)
|
30
|
+
@tag_list << tg2
|
31
|
+
}
|
32
|
+
@tag_list
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_update_policy(update_policy)
|
36
|
+
@update_policy = update_policy
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate
|
40
|
+
if @max_size < @min_size
|
41
|
+
raise Exception.new("max size (#{@max_size}) must be equal or larger min size (#{@min_size})")
|
42
|
+
end
|
43
|
+
if @health_check_type == "ELB" && @health_check_grace_period.nil?
|
44
|
+
raise Exception.new("HealthCheckGracePeriod must be specified for ElasticLoadBalancer based health checks.")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_cf_type
|
49
|
+
"AWS::AutoScaling::AutoScalingGroup"
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_cf_attributes
|
53
|
+
{}
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_cf_properties
|
57
|
+
result = {"AvailabilityZones" => @availability_zones,
|
58
|
+
"LaunchConfigurationName" => @launch_config.generate_ref,
|
59
|
+
"LoadBalancerNames" => CfHelper.generate_ref_array(@load_balancers),
|
60
|
+
"MaxSize" => @max_size,
|
61
|
+
"MinSize" => @min_size
|
62
|
+
}
|
63
|
+
result["Cooldown"] = @cooldown unless @cooldown.nil?
|
64
|
+
result["DesiredCapacity"] = @desired_capacity unless @desired_capacity.nil?
|
65
|
+
result["HealthCheckGracePeriod"] = @health_check_grace_period.to_i unless @health_check_grace_period.nil?
|
66
|
+
result["HealthCheckType"] = @health_check_type unless @health_check_type.nil?
|
67
|
+
result["VPCZoneIdentifier"] = CfHelper.generate_ref_array(@subnets) unless @subnets.nil?
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_ingress_rule(ingress_rule)
|
72
|
+
@ingress_rules << ingress_rule
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_egress_rule(egress_rule)
|
76
|
+
@egress_rules << egress_rule
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
require 'cf_factory/base/cf_base'
|
2
|
-
require 'cf_factory/base/cf_helper'
|
3
|
-
|
4
|
-
module CfFactory
|
5
|
-
class CfAsLaunchConfig
|
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
|
-
|
13
|
-
@user_data = options[:user_data]
|
14
|
-
@key_name = options[:key_name]
|
15
|
-
@security_groups = options[:security_groups]
|
16
|
-
@spot_price = options[:spot_price]
|
17
|
-
#TODO: a couple of properties missing
|
18
|
-
validate()
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_cf_type
|
22
|
-
"AWS::AutoScaling::LaunchConfiguration"
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_cf_attributes
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_cf_properties
|
30
|
-
result = {"ImageId" => @image_id,
|
31
|
-
"InstanceType" => @instance_type
|
32
|
-
}
|
33
|
-
result["UserData"] = CfHelper.base64(@user_data) unless @user_data.nil?
|
34
|
-
result["KeyName"] = @key_name unless @key_name.nil?
|
35
|
-
result["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
|
36
|
-
result["SpotPrice"] = @spot_price unless @spot_price.nil?
|
37
|
-
result
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_ingress_rule(ingress_rule)
|
41
|
-
@ingress_rules << ingress_rule
|
42
|
-
end
|
43
|
-
|
44
|
-
def add_egress_rule(egress_rule)
|
45
|
-
@egress_rules << egress_rule
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def validate
|
51
|
-
raise Exception.new("instance type #{@instance_type} is not supported") unless CfEc2Instance::SUPPORTED_TYPES.include?(@instance_type)
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
1
|
+
require 'cf_factory/base/cf_base'
|
2
|
+
require 'cf_factory/base/cf_helper'
|
3
|
+
|
4
|
+
module CfFactory
|
5
|
+
class CfAsLaunchConfig
|
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
|
+
|
13
|
+
@user_data = options[:user_data]
|
14
|
+
@key_name = options[:key_name]
|
15
|
+
@security_groups = options[:security_groups]
|
16
|
+
@spot_price = options[:spot_price]
|
17
|
+
#TODO: a couple of properties missing
|
18
|
+
validate()
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_cf_type
|
22
|
+
"AWS::AutoScaling::LaunchConfiguration"
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_cf_attributes
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_cf_properties
|
30
|
+
result = {"ImageId" => @image_id,
|
31
|
+
"InstanceType" => @instance_type
|
32
|
+
}
|
33
|
+
result["UserData"] = CfHelper.base64(@user_data) unless @user_data.nil?
|
34
|
+
result["KeyName"] = @key_name unless @key_name.nil?
|
35
|
+
result["SecurityGroups"] = CfHelper.generate_ref_array(@security_groups) unless @security_groups.nil?
|
36
|
+
result["SpotPrice"] = @spot_price unless @spot_price.nil?
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_ingress_rule(ingress_rule)
|
41
|
+
@ingress_rules << ingress_rule
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_egress_rule(egress_rule)
|
45
|
+
@egress_rules << egress_rule
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def validate
|
51
|
+
raise Exception.new("instance type #{@instance_type} is not supported") unless CfEc2Instance::SUPPORTED_TYPES.include?(@instance_type)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require 'cf_factory/base/cf_base'
|
2
|
-
require 'cf_factory/base/cf_helper'
|
3
|
-
|
4
|
-
module CfFactory
|
5
|
-
class CfAsScalingPolicy
|
6
|
-
include CfBase
|
7
|
-
|
8
|
-
def initialize(name, auto_scaling_group, adjustment_type, scaling_adjustment, options = {})
|
9
|
-
@name = name
|
10
|
-
@auto_scaling_group = auto_scaling_group
|
11
|
-
@adjustment_type = adjustment_type
|
12
|
-
@scaling_adjustment = scaling_adjustment
|
13
|
-
@cooldown = options[:cooldown]
|
14
|
-
end
|
15
|
-
|
16
|
-
def get_cf_type
|
17
|
-
"AWS::AutoScaling::ScalingPolicy"
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_cf_attributes
|
21
|
-
{}
|
22
|
-
end
|
23
|
-
|
24
|
-
def get_cf_properties
|
25
|
-
result = {
|
26
|
-
"AutoScalingGroupName" => @auto_scaling_group.generate_ref,
|
27
|
-
"AdjustmentType" => @adjustment_type,
|
28
|
-
"ScalingAdjustment" => @scaling_adjustment
|
29
|
-
}
|
30
|
-
result["Cooldown"] = @cooldown unless @cooldown.nil?
|
31
|
-
result
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require 'cf_factory/base/cf_base'
|
2
|
+
require 'cf_factory/base/cf_helper'
|
3
|
+
|
4
|
+
module CfFactory
|
5
|
+
class CfAsScalingPolicy
|
6
|
+
include CfBase
|
7
|
+
|
8
|
+
def initialize(name, auto_scaling_group, adjustment_type, scaling_adjustment, options = {})
|
9
|
+
@name = name
|
10
|
+
@auto_scaling_group = auto_scaling_group
|
11
|
+
@adjustment_type = adjustment_type
|
12
|
+
@scaling_adjustment = scaling_adjustment
|
13
|
+
@cooldown = options[:cooldown]
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cf_type
|
17
|
+
"AWS::AutoScaling::ScalingPolicy"
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_cf_attributes
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_cf_properties
|
25
|
+
result = {
|
26
|
+
"AutoScalingGroupName" => @auto_scaling_group.generate_ref,
|
27
|
+
"AdjustmentType" => @adjustment_type,
|
28
|
+
"ScalingAdjustment" => @scaling_adjustment
|
29
|
+
}
|
30
|
+
result["Cooldown"] = @cooldown unless @cooldown.nil?
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'cf_factory/base/cf_inner'
|
2
|
+
|
3
|
+
module CfFactory
|
4
|
+
class CfAsUpdatePolicy
|
5
|
+
include CfNamedInner
|
6
|
+
|
7
|
+
def initialize(update_policy_name, max_batch_size, min_instances_in_service, pause_time)
|
8
|
+
@name = update_policy_name
|
9
|
+
@max_batch_size = max_batch_size
|
10
|
+
@min_instances_in_service = min_instances_in_service
|
11
|
+
@pause_time = pause_time
|
12
|
+
@indent = 8
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_cf_attributes
|
16
|
+
result = {}
|
17
|
+
result["MaxBatchSize"] = @max_batch_size
|
18
|
+
result["MinInstancesInService"] = @min_instances_in_service
|
19
|
+
result["PauseTime"] = @pause_time
|
20
|
+
result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,102 +1,112 @@
|
|
1
|
-
require 'cf_factory/base/cf_helper'
|
2
|
-
|
3
|
-
module CfFactory
|
4
|
-
module CfBase
|
5
|
-
def get_name
|
6
|
-
@name
|
7
|
-
end
|
8
|
-
|
9
|
-
def get_cf_type
|
10
|
-
raise Exception.new("must be defined")
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_deletion_policy
|
14
|
-
@deletion_policy
|
15
|
-
end
|
16
|
-
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def
|
32
|
-
CfHelper.
|
33
|
-
end
|
34
|
-
|
35
|
-
def
|
36
|
-
@
|
37
|
-
end
|
38
|
-
|
39
|
-
def
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
output += " \"#{key}\" : #{
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
unless
|
73
|
-
@result += "#{
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
@result += "
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
1
|
+
require 'cf_factory/base/cf_helper'
|
2
|
+
|
3
|
+
module CfFactory
|
4
|
+
module CfBase
|
5
|
+
def get_name
|
6
|
+
@name
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_cf_type
|
10
|
+
raise Exception.new("must be defined")
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_deletion_policy
|
14
|
+
@deletion_policy
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_update_policy
|
18
|
+
@update_policy
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_cf_attributes
|
22
|
+
result = {}
|
23
|
+
result["Metadata"] = @meta_data.generate unless @meta_data.nil?
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_cf_properties
|
28
|
+
raise Exception.new("must be defined")
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_ref
|
32
|
+
CfHelper.generate_ref(self.get_name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def retrieve_attribute(attribute)
|
36
|
+
CfHelper.generate_att(@name, attribute)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_meta_data(meta_data)
|
40
|
+
@meta_data = meta_data
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_tags(tag_list)
|
44
|
+
#should be overwritten by those resources that support tags
|
45
|
+
end
|
46
|
+
|
47
|
+
def hash_to_string(hash, indent=0)
|
48
|
+
output = ""
|
49
|
+
hash.keys.each() do |key|
|
50
|
+
value = hash[key]
|
51
|
+
output += " " * indent
|
52
|
+
case value.class.to_s
|
53
|
+
when "Hash"
|
54
|
+
output += " \"#{key}\" : \n{#{hash_to_string(value,indent+5)}},\n"
|
55
|
+
when "EmbeddedProperty"
|
56
|
+
output += " \"#{key}\" : \n{#{hash_to_string(value.generate,indent+5)},\n"
|
57
|
+
else
|
58
|
+
output += " \"#{key}\" : #{set_quotes(value)},\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
output
|
62
|
+
output = output.chomp().chomp(",")
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def generate
|
67
|
+
@result = ""
|
68
|
+
@result += " \"#{@name}\" : {\n"
|
69
|
+
unless self.get_cf_type() == nil
|
70
|
+
@result += " \"Type\" : \"#{self.get_cf_type()}\",\n"
|
71
|
+
end
|
72
|
+
unless self.get_deletion_policy() == nil
|
73
|
+
@result += " \"DeletionPolicy\" : \"#{self.get_deletion_policy()}\",\n"
|
74
|
+
end
|
75
|
+
unless self.get_update_policy() == nil
|
76
|
+
self.get_update_policy.set_indent(8)
|
77
|
+
@result += " \"UpdatePolicy\" : {\n"
|
78
|
+
@result += "#{self.get_update_policy.generate()}\n"
|
79
|
+
@result += " },\n"
|
80
|
+
end
|
81
|
+
attributes = self.get_cf_attributes
|
82
|
+
unless attributes.size == 0
|
83
|
+
@result += "#{hash_to_string(attributes)},\n"
|
84
|
+
end
|
85
|
+
#
|
86
|
+
properties = self.get_cf_properties
|
87
|
+
properties["Tags"] = CfHelper.generate_inner_array(@tag_list) unless @tag_list.nil?
|
88
|
+
unless properties.size == 0
|
89
|
+
@result += " \"Properties\" : {\n"
|
90
|
+
@result += hash_to_string(properties)
|
91
|
+
@result += "\n }"
|
92
|
+
end
|
93
|
+
@result = @result.chomp.chomp(",")
|
94
|
+
@result += "\n },\n"
|
95
|
+
end
|
96
|
+
|
97
|
+
# Sets leading and trailing quotes
|
98
|
+
def set_quotes(value)
|
99
|
+
if value.class.to_s == "String"
|
100
|
+
if value.delete(" ").start_with?("{") || value.delete(" ").start_with?("[")
|
101
|
+
value
|
102
|
+
else
|
103
|
+
"\"#{value}\""
|
104
|
+
end
|
105
|
+
else
|
106
|
+
value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'cf_factory/base/cf_inner'
|
2
|
-
|
3
|
-
module CfFactory
|
4
|
-
class CfEc2Tag
|
5
|
-
include CfInner
|
6
|
-
|
7
|
-
def initialize(key, value, options = {})
|
8
|
-
@key = key
|
9
|
-
@value = value
|
10
|
-
@propagate_at_launch = options[:propagate_at_launch]
|
11
|
-
end
|
12
|
-
|
13
|
-
def set_propagate_at_launch(pal)
|
14
|
-
@propagate_at_launch = pal
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_cf_attributes
|
18
|
-
result = {"Key" => @key,
|
19
|
-
"Value" => @value
|
20
|
-
}
|
21
|
-
result["PropagateAtLaunch"] = @propagate_at_launch unless @propagate_at_launch.nil?
|
22
|
-
result
|
23
|
-
end
|
24
|
-
|
25
|
-
def clone
|
26
|
-
options = {}
|
27
|
-
if @propagate_at_launch
|
28
|
-
options[:propagate_at_launch] = @propagate_at_launch
|
29
|
-
end
|
30
|
-
CfEc2Tag.new(@key,@value,options)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
1
|
+
require 'cf_factory/base/cf_inner'
|
2
|
+
|
3
|
+
module CfFactory
|
4
|
+
class CfEc2Tag
|
5
|
+
include CfInner
|
6
|
+
|
7
|
+
def initialize(key, value, options = {})
|
8
|
+
@key = key
|
9
|
+
@value = value
|
10
|
+
@propagate_at_launch = options[:propagate_at_launch]
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_propagate_at_launch(pal)
|
14
|
+
@propagate_at_launch = pal
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_cf_attributes
|
18
|
+
result = {"Key" => @key,
|
19
|
+
"Value" => @value
|
20
|
+
}
|
21
|
+
result["PropagateAtLaunch"] = @propagate_at_launch unless @propagate_at_launch.nil?
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
def clone
|
26
|
+
options = {}
|
27
|
+
if @propagate_at_launch
|
28
|
+
options[:propagate_at_launch] = @propagate_at_launch
|
29
|
+
end
|
30
|
+
CfEc2Tag.new(@key,@value,options)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|