cumulus-aws 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +12 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +29 -0
  6. data/LICENSE +202 -0
  7. data/README.md +41 -0
  8. data/autocomplete +137 -0
  9. data/bin/cumulus +658 -0
  10. data/cumulus +2 -0
  11. data/cumulus-aws.gemspec +20 -0
  12. data/lib/autoscaling/AutoScaling.rb +40 -0
  13. data/lib/autoscaling/loader/Loader.rb +56 -0
  14. data/lib/autoscaling/manager/Manager.rb +360 -0
  15. data/lib/autoscaling/models/AlarmConfig.rb +165 -0
  16. data/lib/autoscaling/models/AlarmDiff.rb +172 -0
  17. data/lib/autoscaling/models/AutoScalingDiff.rb +178 -0
  18. data/lib/autoscaling/models/GroupConfig.rb +330 -0
  19. data/lib/autoscaling/models/PolicyConfig.rb +135 -0
  20. data/lib/autoscaling/models/PolicyDiff.rb +73 -0
  21. data/lib/autoscaling/models/ScheduledActionDiff.rb +53 -0
  22. data/lib/autoscaling/models/ScheduledConfig.rb +96 -0
  23. data/lib/aws_extensions/ec2/DhcpOptions.rb +41 -0
  24. data/lib/aws_extensions/ec2/Instance.rb +29 -0
  25. data/lib/aws_extensions/ec2/NetworkAcl.rb +25 -0
  26. data/lib/aws_extensions/ec2/NetworkInterface.rb +14 -0
  27. data/lib/aws_extensions/ec2/RouteTable.rb +26 -0
  28. data/lib/aws_extensions/ec2/SecurityGroup.rb +16 -0
  29. data/lib/aws_extensions/ec2/Subnet.rb +28 -0
  30. data/lib/aws_extensions/ec2/Volume.rb +24 -0
  31. data/lib/aws_extensions/ec2/Vpc.rb +14 -0
  32. data/lib/aws_extensions/ec2/VpcEndpoint.rb +11 -0
  33. data/lib/aws_extensions/elb/BackendServerDescription.rb +12 -0
  34. data/lib/aws_extensions/elb/PolicyDescription.rb +14 -0
  35. data/lib/aws_extensions/kinesis/StreamDescription.rb +12 -0
  36. data/lib/aws_extensions/route53/AliasTarget.rb +21 -0
  37. data/lib/aws_extensions/s3/Bucket.rb +33 -0
  38. data/lib/aws_extensions/s3/BucketAcl.rb +28 -0
  39. data/lib/aws_extensions/s3/BucketCors.rb +17 -0
  40. data/lib/aws_extensions/s3/BucketLifecycle.rb +21 -0
  41. data/lib/aws_extensions/s3/BucketLogging.rb +18 -0
  42. data/lib/aws_extensions/s3/BucketNotification.rb +23 -0
  43. data/lib/aws_extensions/s3/BucketPolicy.rb +18 -0
  44. data/lib/aws_extensions/s3/BucketTagging.rb +15 -0
  45. data/lib/aws_extensions/s3/BucketVersioning.rb +14 -0
  46. data/lib/aws_extensions/s3/BucketWebsite.rb +49 -0
  47. data/lib/aws_extensions/s3/CORSRule.rb +27 -0
  48. data/lib/aws_extensions/s3/ReplicationConfiguration.rb +22 -0
  49. data/lib/cloudfront/CloudFront.rb +83 -0
  50. data/lib/cloudfront/loader/Loader.rb +31 -0
  51. data/lib/cloudfront/manager/Manager.rb +183 -0
  52. data/lib/cloudfront/models/CacheBehaviorConfig.rb +237 -0
  53. data/lib/cloudfront/models/CacheBehaviorDiff.rb +211 -0
  54. data/lib/cloudfront/models/CustomOriginConfig.rb +51 -0
  55. data/lib/cloudfront/models/CustomOriginDiff.rb +74 -0
  56. data/lib/cloudfront/models/DistributionConfig.rb +183 -0
  57. data/lib/cloudfront/models/DistributionDiff.rb +131 -0
  58. data/lib/cloudfront/models/InvalidationConfig.rb +37 -0
  59. data/lib/cloudfront/models/OriginConfig.rb +144 -0
  60. data/lib/cloudfront/models/OriginDiff.rb +86 -0
  61. data/lib/cloudfront/models/OriginSslProtocols.rb +28 -0
  62. data/lib/cloudfront/models/OriginSslProtocolsDiff.rb +39 -0
  63. data/lib/common/BaseLoader.rb +80 -0
  64. data/lib/common/manager/Manager.rb +148 -0
  65. data/lib/common/models/Diff.rb +114 -0
  66. data/lib/common/models/ListChange.rb +21 -0
  67. data/lib/common/models/TagsDiff.rb +55 -0
  68. data/lib/common/models/UTCTimeSource.rb +17 -0
  69. data/lib/conf/Configuration.rb +365 -0
  70. data/lib/ec2/EC2.rb +503 -0
  71. data/lib/ec2/IPProtocolMapping.rb +165 -0
  72. data/lib/ec2/loaders/EbsLoader.rb +19 -0
  73. data/lib/ec2/loaders/InstanceLoader.rb +32 -0
  74. data/lib/ec2/managers/EbsManager.rb +176 -0
  75. data/lib/ec2/managers/InstanceManager.rb +509 -0
  76. data/lib/ec2/models/EbsGroupConfig.rb +133 -0
  77. data/lib/ec2/models/EbsGroupDiff.rb +48 -0
  78. data/lib/ec2/models/InstanceConfig.rb +202 -0
  79. data/lib/ec2/models/InstanceDiff.rb +95 -0
  80. data/lib/elb/ELB.rb +148 -0
  81. data/lib/elb/loader/Loader.rb +65 -0
  82. data/lib/elb/manager/Manager.rb +581 -0
  83. data/lib/elb/models/AccessLogConfig.rb +82 -0
  84. data/lib/elb/models/AccessLogDiff.rb +47 -0
  85. data/lib/elb/models/HealthCheckConfig.rb +91 -0
  86. data/lib/elb/models/HealthCheckDiff.rb +50 -0
  87. data/lib/elb/models/ListenerConfig.rb +99 -0
  88. data/lib/elb/models/ListenerDiff.rb +91 -0
  89. data/lib/elb/models/LoadBalancerConfig.rb +239 -0
  90. data/lib/elb/models/LoadBalancerDiff.rb +265 -0
  91. data/lib/iam/IAM.rb +36 -0
  92. data/lib/iam/loader/Loader.rb +117 -0
  93. data/lib/iam/manager/IamGroups.rb +98 -0
  94. data/lib/iam/manager/IamResource.rb +288 -0
  95. data/lib/iam/manager/IamRoles.rb +112 -0
  96. data/lib/iam/manager/IamUsers.rb +54 -0
  97. data/lib/iam/manager/Manager.rb +29 -0
  98. data/lib/iam/migration/AssumeRoleUnifier.rb +34 -0
  99. data/lib/iam/migration/PolicyUnifier.rb +90 -0
  100. data/lib/iam/models/GroupConfig.rb +40 -0
  101. data/lib/iam/models/IamDiff.rb +132 -0
  102. data/lib/iam/models/PolicyConfig.rb +67 -0
  103. data/lib/iam/models/ResourceWithPolicy.rb +208 -0
  104. data/lib/iam/models/RoleConfig.rb +53 -0
  105. data/lib/iam/models/StatementConfig.rb +35 -0
  106. data/lib/iam/models/UserConfig.rb +21 -0
  107. data/lib/kinesis/Kinesis.rb +94 -0
  108. data/lib/kinesis/loader/Loader.rb +19 -0
  109. data/lib/kinesis/manager/Manager.rb +206 -0
  110. data/lib/kinesis/models/StreamConfig.rb +75 -0
  111. data/lib/kinesis/models/StreamDiff.rb +58 -0
  112. data/lib/lambda/Lambda.rb +41 -0
  113. data/lib/route53/loader/Loader.rb +32 -0
  114. data/lib/route53/manager/Manager.rb +241 -0
  115. data/lib/route53/models/AliasTarget.rb +86 -0
  116. data/lib/route53/models/RecordConfig.rb +178 -0
  117. data/lib/route53/models/RecordDiff.rb +140 -0
  118. data/lib/route53/models/Vpc.rb +24 -0
  119. data/lib/route53/models/ZoneConfig.rb +156 -0
  120. data/lib/route53/models/ZoneDiff.rb +118 -0
  121. data/lib/s3/S3.rb +89 -0
  122. data/lib/s3/loader/Loader.rb +66 -0
  123. data/lib/s3/manager/Manager.rb +296 -0
  124. data/lib/s3/models/BucketConfig.rb +321 -0
  125. data/lib/s3/models/BucketDiff.rb +167 -0
  126. data/lib/s3/models/GrantConfig.rb +189 -0
  127. data/lib/s3/models/GrantDiff.rb +50 -0
  128. data/lib/s3/models/LifecycleConfig.rb +142 -0
  129. data/lib/s3/models/LifecycleDiff.rb +46 -0
  130. data/lib/s3/models/LoggingConfig.rb +81 -0
  131. data/lib/s3/models/NotificationConfig.rb +157 -0
  132. data/lib/s3/models/NotificationDiff.rb +62 -0
  133. data/lib/s3/models/ReplicationConfig.rb +133 -0
  134. data/lib/s3/models/ReplicationDiff.rb +60 -0
  135. data/lib/s3/models/WebsiteConfig.rb +107 -0
  136. data/lib/security/SecurityGroups.rb +39 -0
  137. data/lib/security/loader/Loader.rb +94 -0
  138. data/lib/security/manager/Manager.rb +246 -0
  139. data/lib/security/models/RuleConfig.rb +161 -0
  140. data/lib/security/models/RuleDiff.rb +72 -0
  141. data/lib/security/models/RuleMigration.rb +127 -0
  142. data/lib/security/models/SecurityGroupConfig.rb +172 -0
  143. data/lib/security/models/SecurityGroupDiff.rb +112 -0
  144. data/lib/sns/SNS.rb +40 -0
  145. data/lib/sqs/SQS.rb +62 -0
  146. data/lib/sqs/loader/Loader.rb +34 -0
  147. data/lib/sqs/manager/Manager.rb +128 -0
  148. data/lib/sqs/models/DeadLetterConfig.rb +70 -0
  149. data/lib/sqs/models/DeadLetterDiff.rb +35 -0
  150. data/lib/sqs/models/QueueConfig.rb +115 -0
  151. data/lib/sqs/models/QueueDiff.rb +89 -0
  152. data/lib/util/Colors.rb +111 -0
  153. data/lib/util/StatusCodes.rb +51 -0
  154. data/lib/vpc/loader/Loader.rb +73 -0
  155. data/lib/vpc/manager/Manager.rb +954 -0
  156. data/lib/vpc/models/AclEntryConfig.rb +150 -0
  157. data/lib/vpc/models/AclEntryDiff.rb +54 -0
  158. data/lib/vpc/models/DhcpConfig.rb +100 -0
  159. data/lib/vpc/models/DhcpDiff.rb +90 -0
  160. data/lib/vpc/models/EndpointConfig.rb +76 -0
  161. data/lib/vpc/models/EndpointDiff.rb +69 -0
  162. data/lib/vpc/models/NetworkAclConfig.rb +87 -0
  163. data/lib/vpc/models/NetworkAclDiff.rb +116 -0
  164. data/lib/vpc/models/RouteConfig.rb +82 -0
  165. data/lib/vpc/models/RouteDiff.rb +50 -0
  166. data/lib/vpc/models/RouteTableConfig.rb +92 -0
  167. data/lib/vpc/models/RouteTableDiff.rb +101 -0
  168. data/lib/vpc/models/SubnetConfig.rb +113 -0
  169. data/lib/vpc/models/SubnetDiff.rb +78 -0
  170. data/lib/vpc/models/VpcConfig.rb +173 -0
  171. data/lib/vpc/models/VpcDiff.rb +315 -0
  172. data/rakefile.rb +8 -0
  173. metadata +245 -0
@@ -0,0 +1,82 @@
1
+ require "elb/models/AccessLogDiff"
2
+
3
+ module Cumulus
4
+ module ELB
5
+ # Public: An object representing configuration for a load balancer
6
+ class AccessLogConfig
7
+ attr_reader :enabled
8
+ attr_reader :s3_bucket
9
+ attr_reader :emit_interval
10
+ attr_reader :bucket_prefix
11
+
12
+ # Public: Constructor
13
+ #
14
+ # json - a hash containing the JSON configuration for the load balancer
15
+ def initialize(json = nil)
16
+ @enabled = !json.nil?
17
+ if !json.nil?
18
+ @s3_bucket = json["s3-bucket"]
19
+ @emit_interval = json["emit-interval"]
20
+ @bucket_prefix = json["bucket-prefix"]
21
+ end
22
+ end
23
+
24
+ def to_hash
25
+ if @enabled
26
+ {
27
+ "s3-bucket" => @s3_bucket,
28
+ "emit-interval" => @emit_interval,
29
+ "bucket-prefix" => @bucket_prefix,
30
+ }.reject { |k, v| v.nil? }
31
+ else
32
+ false
33
+ end
34
+ end
35
+
36
+ def to_aws
37
+ {
38
+ enabled: @enabled,
39
+ s3_bucket_name: @s3_bucket,
40
+ emit_interval: @emit_interval,
41
+ s3_bucket_prefix: @bucket_prefix,
42
+ }.reject { |k, v| v.nil? }
43
+ end
44
+
45
+ def populate!(aws)
46
+ @enabled = aws.enabled
47
+ @s3_bucket = aws.s3_bucket_name
48
+ @emit_interval = aws.emit_interval
49
+ @bucket_prefix = aws.s3_bucket_prefix
50
+ end
51
+
52
+ # Public: Produce an array of differences between this local configuration and the
53
+ # configuration in AWS
54
+ #
55
+ # aws - the AWS resource
56
+ #
57
+ # Returns an array of the HealthCheckDiffs that were found
58
+ def diff(aws)
59
+ diffs = []
60
+
61
+ if @enabled != aws.enabled
62
+ diffs << AccessLogDiff.new(AccessLogChange::ENABLED, aws.enabled, @enabled)
63
+ end
64
+
65
+ if @s3_bucket != aws.s3_bucket_name
66
+ diffs << AccessLogDiff.new(AccessLogChange::BUCKET, aws.s3_bucket_name, @s3_bucket)
67
+ end
68
+
69
+ if @emit_interval != aws.emit_interval
70
+ diffs << AccessLogDiff.new(AccessLogChange::EMIT, aws.emit_interval, @emit_interval)
71
+ end
72
+
73
+ if @bucket_prefix != aws.s3_bucket_prefix
74
+ diffs << AccessLogDiff.new(AccessLogChange::PREFIX, aws.s3_bucket_prefix, @bucket_prefix)
75
+ end
76
+
77
+ diffs.flatten
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,47 @@
1
+ require "common/models/Diff"
2
+ require "util/Colors"
3
+
4
+ module Cumulus
5
+ module ELB
6
+ # Public: The types of changes that can be made to an access log config
7
+ module AccessLogChange
8
+ include Common::DiffChange
9
+
10
+ ENABLED = Common::DiffChange.next_change_id
11
+ BUCKET = Common::DiffChange.next_change_id
12
+ EMIT = Common::DiffChange.next_change_id
13
+ PREFIX = Common::DiffChange.next_change_id
14
+ end
15
+
16
+ # Public: Represents a single difference between local configuration and
17
+ # an AWS Load Balancer Access Log.
18
+ class AccessLogDiff < Common::Diff
19
+ include AccessLogChange
20
+
21
+ def asset_type
22
+ "Access Log Config"
23
+ end
24
+
25
+ def change_string
26
+ case @type
27
+ when ENABLED
28
+ "enabled:"
29
+ when BUCKET
30
+ "S3 bucket:"
31
+ when EMIT
32
+ "emit interval:"
33
+ when PREFIX
34
+ "bucket prefix:"
35
+ end
36
+ end
37
+
38
+ def diff_string
39
+ [
40
+ change_string,
41
+ Colors.aws_changes("\tAWS - #{aws}"),
42
+ Colors.local_changes("\tLocal - #{local}"),
43
+ ].join("\n")
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,91 @@
1
+ require "elb/models/HealthCheckDiff"
2
+
3
+ require "json"
4
+
5
+ module Cumulus
6
+ module ELB
7
+ # Public: An object representing configuration for a load balancer
8
+ class HealthCheckConfig
9
+ attr_reader :target
10
+ attr_reader :interval
11
+ attr_reader :timeout
12
+ attr_reader :healthy
13
+ attr_reader :unhealthy
14
+
15
+ # Public: Constructor
16
+ #
17
+ # json - a hash containing the JSON configuration for the load balancer
18
+ def initialize(json = nil)
19
+ if !json.nil?
20
+ @target = json["target"]
21
+ @interval = json["interval"]
22
+ @timeout = json["timeout"]
23
+ @healthy = json["healthy"]
24
+ @unhealthy = json["unhealthy"]
25
+ end
26
+ end
27
+
28
+ def to_hash
29
+ {
30
+ "target" => @target,
31
+ "interval" => @interval,
32
+ "timeout" => @timeout,
33
+ "healthy" => @healthy,
34
+ "unhealthy" => @unhealthy,
35
+ }.reject { |k, v| v.nil? }
36
+ end
37
+
38
+ def to_aws
39
+ {
40
+ target: @target,
41
+ interval: @interval,
42
+ timeout: @timeout,
43
+ healthy_threshold: @healthy,
44
+ unhealthy_threshold: @unhealthy,
45
+ }
46
+ end
47
+
48
+ def populate!(aws)
49
+ @target = aws.target
50
+ @interval = aws.interval
51
+ @timeout = aws.timeout
52
+ @healthy = aws.healthy_threshold
53
+ @unhealthy = aws.unhealthy_threshold
54
+ end
55
+
56
+ # Public: Produce an array of differences between this local configuration and the
57
+ # configuration in AWS
58
+ #
59
+ # aws - the AWS resource
60
+ #
61
+ # Returns an array of the HealthCheckDiffs that were found
62
+ def diff(aws)
63
+ diffs = []
64
+
65
+ if @target != aws.target
66
+ diffs << HealthCheckDiff.new(HealthCheckChange::TARGET, aws.target, @target)
67
+ end
68
+
69
+ if @interval != aws.interval
70
+ diffs << HealthCheckDiff.new(HealthCheckChange::INTERVAL, aws.interval, @interval)
71
+ end
72
+
73
+ if @timeout != aws.timeout
74
+ diffs << HealthCheckDiff.new(HealthCheckChange::TIMEOUT, aws.timeout, @timeout)
75
+ end
76
+
77
+ if @healthy != aws.healthy_threshold
78
+ diffs << HealthCheckDiff.new(HealthCheckChange::HEALTHY, aws.healthy_threshold, @healthy)
79
+ end
80
+
81
+ if @unhealthy != aws.unhealthy_threshold
82
+ diffs << HealthCheckDiff.new(HealthCheckChange::UNHEALTHY, aws.unhealthy_threshold, @unhealthy)
83
+ end
84
+
85
+ diffs
86
+ end
87
+
88
+
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,50 @@
1
+ require "common/models/Diff"
2
+ require "util/Colors"
3
+
4
+ module Cumulus
5
+ module ELB
6
+ # Public: The types of changes that can be made to an access log config
7
+ module HealthCheckChange
8
+ include Common::DiffChange
9
+
10
+ TARGET = Common::DiffChange.next_change_id
11
+ INTERVAL = Common::DiffChange.next_change_id
12
+ TIMEOUT = Common::DiffChange.next_change_id
13
+ HEALTHY = Common::DiffChange.next_change_id
14
+ UNHEALTHY = Common::DiffChange.next_change_id
15
+ end
16
+
17
+ # Public: Represents a single difference between local configuration and
18
+ # an AWS Load Balancer Health Check
19
+ class HealthCheckDiff < Common::Diff
20
+ include HealthCheckChange
21
+
22
+ def asset_type
23
+ "Health Check Config"
24
+ end
25
+
26
+ def change_string
27
+ case @type
28
+ when TARGET
29
+ "target:"
30
+ when INTERVAL
31
+ "interval:"
32
+ when TIMEOUT
33
+ "timeout:"
34
+ when HEALTHY
35
+ "healthy threshold:"
36
+ when UNHEALTHY
37
+ "unhealthy threshold:"
38
+ end
39
+ end
40
+
41
+ def diff_string
42
+ [
43
+ change_string,
44
+ Colors.aws_changes("\tAWS - #{aws}"),
45
+ Colors.local_changes("\tLocal - #{local}"),
46
+ ].join("\n")
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,99 @@
1
+ require "elb/models/ListenerDiff"
2
+
3
+ require "json"
4
+
5
+ module Cumulus
6
+ module ELB
7
+ # Public: An object representing configuration for a listener
8
+ class ListenerConfig
9
+ attr_reader :load_balancer_protocol
10
+ attr_reader :load_balancer_port
11
+ attr_reader :instance_protocol
12
+ attr_reader :instance_port
13
+ attr_reader :ssl_certificate_id
14
+ attr_reader :policies
15
+
16
+ # Public: Constructor
17
+ #
18
+ # json - a hash containing the JSON configuration for the listener
19
+ def initialize(json = nil)
20
+ if !json.nil?
21
+ @load_balancer_protocol = json["load-balancer-protocol"]
22
+ @load_balancer_port = json["load-balancer-port"]
23
+ @instance_protocol = json["instance-protocol"]
24
+ @instance_port = json["instance-port"]
25
+ @ssl_certificate_id = json["ssl-certificate-id"]
26
+ @policies = json["policies"] || []
27
+ end
28
+ end
29
+
30
+ def to_hash
31
+ {
32
+ "load-balancer-protocol" => @load_balancer_protocol,
33
+ "load-balancer-port" => @load_balancer_port,
34
+ "instance-protocol" => @instance_protocol,
35
+ "instance-port" => @instance_port,
36
+ "ssl-certificate-id" => @ssl_certificate_id,
37
+ "policies" => @policies,
38
+ }.reject { |k, v| v.nil? }
39
+ end
40
+
41
+ def to_aws
42
+ {
43
+ protocol: @load_balancer_protocol,
44
+ load_balancer_port: @load_balancer_port,
45
+ instance_protocol: @instance_protocol,
46
+ instance_port: @instance_port,
47
+ ssl_certificate_id: @ssl_certificate_id,
48
+ }.reject { |k, v| v.nil? }
49
+ end
50
+
51
+ def populate!(aws)
52
+ @load_balancer_protocol = aws.listener.protocol
53
+ @load_balancer_port = aws.listener.load_balancer_port
54
+ @instance_protocol = aws.listener.instance_protocol
55
+ @instance_port = aws.listener.instance_port
56
+ @ssl_certificate_id = aws.listener.ssl_certificate_id
57
+ @policies = aws.policy_names
58
+ end
59
+
60
+ # Public: Produce an array of differences between this local configuration and the
61
+ # configuration in AWS
62
+ #
63
+ # aws - the AWS resource
64
+ #
65
+ # Returns an array of the ListenerDiffs that were found
66
+ def diff(aws)
67
+ diffs = []
68
+
69
+ if @load_balancer_protocol != aws.listener.protocol
70
+ diffs << ListenerDiff.new(ListenerChange::LB_PROTOCOL, aws.listener.protocol, @load_balancer_protocol)
71
+ end
72
+
73
+ if @load_balancer_port != aws.listener.load_balancer_port
74
+ diffs << ListenerDiff.new(ListenerChange::LB_PORT, aws.listener.load_balancer_port, @load_balancer_port)
75
+ end
76
+
77
+ if @instance_protocol != aws.listener.instance_protocol
78
+ diffs << ListenerDiff.new(ListenerChange::INST_PROTOCOL, aws.listener.instance_protocol, @instance_protocol)
79
+ end
80
+
81
+ if @instance_port != aws.listener.instance_port
82
+ diffs << ListenerDiff.new(ListenerChange::INST_PORT, aws.listener.instance_port, @instance_port)
83
+ end
84
+
85
+ if @ssl_certificate_id != aws.listener.ssl_certificate_id
86
+ diffs << ListenerDiff.new(ListenerChange::SSL, aws.listener.ssl_certificate_id, @ssl_certificate_id)
87
+ end
88
+
89
+ if @policies.sort != aws.policy_names.sort
90
+ diffs << ListenerDiff.policies(aws.policy_names, @policies)
91
+ end
92
+
93
+ diffs
94
+ end
95
+
96
+
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,91 @@
1
+ require "common/models/Diff"
2
+ require "util/Colors"
3
+
4
+ module Cumulus
5
+ module ELB
6
+ # Public: The types of changes that can be made to an access log config
7
+ module ListenerChange
8
+ include Common::DiffChange
9
+
10
+ LB_PROTOCOL = Common::DiffChange.next_change_id
11
+ LB_PORT = Common::DiffChange.next_change_id
12
+ INST_PROTOCOL = Common::DiffChange.next_change_id
13
+ INST_PORT = Common::DiffChange.next_change_id
14
+ SSL = Common::DiffChange.next_change_id
15
+ POLICIES = Common::DiffChange.next_change_id
16
+ end
17
+
18
+ # Public: Represents a single difference between local configuration and
19
+ # an AWS Load Balancer Listener
20
+ class ListenerDiff < Common::Diff
21
+ include ListenerChange
22
+
23
+ attr_accessor :policies
24
+
25
+ def asset_type
26
+ "Listener for port"
27
+ end
28
+
29
+ def aws_name
30
+ "#{aws.listener.load_balancer_port}"
31
+ end
32
+
33
+ def local_name
34
+ "#{local.load_balancer_port}"
35
+ end
36
+
37
+ def unmanaged_string
38
+ "will be deleted."
39
+ end
40
+
41
+ def self.policies(aws, local)
42
+ added = local - aws
43
+ removed = aws - local
44
+ diff = ListenerDiff.new(POLICIES, aws, local)
45
+ diff.policies = Common::ListChange.new(added, removed)
46
+ diff
47
+ end
48
+
49
+ def diff_string
50
+ case @type
51
+ when LB_PROTOCOL
52
+ [
53
+ "load balancer protocol:",
54
+ Colors.aws_changes("\tAWS - #{aws}"),
55
+ Colors.local_changes("\tLocal - #{local}"),
56
+ ].join("\n")
57
+ when LB_PORT
58
+ [
59
+ "load balancer port:",
60
+ Colors.aws_changes("\tAWS - #{aws}"),
61
+ Colors.local_changes("\tLocal - #{local}"),
62
+ ].join("\n")
63
+ when INST_PROTOCOL
64
+ [
65
+ "instance protocol:",
66
+ Colors.aws_changes("\tAWS - #{aws}"),
67
+ Colors.local_changes("\tLocal - #{local}"),
68
+ ].join("\n")
69
+ when INST_PORT
70
+ [
71
+ "instance port:",
72
+ Colors.aws_changes("\tAWS - #{aws}"),
73
+ Colors.local_changes("\tLocal - #{local}"),
74
+ ].join("\n")
75
+ when SSL
76
+ [
77
+ "ssl certificate id:",
78
+ Colors.aws_changes("\tAWS - #{aws}"),
79
+ Colors.local_changes("\tLocal - #{local}"),
80
+ ].join("\n")
81
+ when POLICIES
82
+ [
83
+ "policies:",
84
+ @policies.removed.map { |p| Colors.removed("\t#{p}") },
85
+ @policies.added.map { |p| Colors.added("\t#{p}") },
86
+ ].flatten.join("\n")
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end