cumulus-aws 0.11.1
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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +202 -0
- data/README.md +41 -0
- data/autocomplete +137 -0
- data/bin/cumulus +658 -0
- data/cumulus +2 -0
- data/cumulus-aws.gemspec +20 -0
- data/lib/autoscaling/AutoScaling.rb +40 -0
- data/lib/autoscaling/loader/Loader.rb +56 -0
- data/lib/autoscaling/manager/Manager.rb +360 -0
- data/lib/autoscaling/models/AlarmConfig.rb +165 -0
- data/lib/autoscaling/models/AlarmDiff.rb +172 -0
- data/lib/autoscaling/models/AutoScalingDiff.rb +178 -0
- data/lib/autoscaling/models/GroupConfig.rb +330 -0
- data/lib/autoscaling/models/PolicyConfig.rb +135 -0
- data/lib/autoscaling/models/PolicyDiff.rb +73 -0
- data/lib/autoscaling/models/ScheduledActionDiff.rb +53 -0
- data/lib/autoscaling/models/ScheduledConfig.rb +96 -0
- data/lib/aws_extensions/ec2/DhcpOptions.rb +41 -0
- data/lib/aws_extensions/ec2/Instance.rb +29 -0
- data/lib/aws_extensions/ec2/NetworkAcl.rb +25 -0
- data/lib/aws_extensions/ec2/NetworkInterface.rb +14 -0
- data/lib/aws_extensions/ec2/RouteTable.rb +26 -0
- data/lib/aws_extensions/ec2/SecurityGroup.rb +16 -0
- data/lib/aws_extensions/ec2/Subnet.rb +28 -0
- data/lib/aws_extensions/ec2/Volume.rb +24 -0
- data/lib/aws_extensions/ec2/Vpc.rb +14 -0
- data/lib/aws_extensions/ec2/VpcEndpoint.rb +11 -0
- data/lib/aws_extensions/elb/BackendServerDescription.rb +12 -0
- data/lib/aws_extensions/elb/PolicyDescription.rb +14 -0
- data/lib/aws_extensions/kinesis/StreamDescription.rb +12 -0
- data/lib/aws_extensions/route53/AliasTarget.rb +21 -0
- data/lib/aws_extensions/s3/Bucket.rb +33 -0
- data/lib/aws_extensions/s3/BucketAcl.rb +28 -0
- data/lib/aws_extensions/s3/BucketCors.rb +17 -0
- data/lib/aws_extensions/s3/BucketLifecycle.rb +21 -0
- data/lib/aws_extensions/s3/BucketLogging.rb +18 -0
- data/lib/aws_extensions/s3/BucketNotification.rb +23 -0
- data/lib/aws_extensions/s3/BucketPolicy.rb +18 -0
- data/lib/aws_extensions/s3/BucketTagging.rb +15 -0
- data/lib/aws_extensions/s3/BucketVersioning.rb +14 -0
- data/lib/aws_extensions/s3/BucketWebsite.rb +49 -0
- data/lib/aws_extensions/s3/CORSRule.rb +27 -0
- data/lib/aws_extensions/s3/ReplicationConfiguration.rb +22 -0
- data/lib/cloudfront/CloudFront.rb +83 -0
- data/lib/cloudfront/loader/Loader.rb +31 -0
- data/lib/cloudfront/manager/Manager.rb +183 -0
- data/lib/cloudfront/models/CacheBehaviorConfig.rb +237 -0
- data/lib/cloudfront/models/CacheBehaviorDiff.rb +211 -0
- data/lib/cloudfront/models/CustomOriginConfig.rb +51 -0
- data/lib/cloudfront/models/CustomOriginDiff.rb +74 -0
- data/lib/cloudfront/models/DistributionConfig.rb +183 -0
- data/lib/cloudfront/models/DistributionDiff.rb +131 -0
- data/lib/cloudfront/models/InvalidationConfig.rb +37 -0
- data/lib/cloudfront/models/OriginConfig.rb +144 -0
- data/lib/cloudfront/models/OriginDiff.rb +86 -0
- data/lib/cloudfront/models/OriginSslProtocols.rb +28 -0
- data/lib/cloudfront/models/OriginSslProtocolsDiff.rb +39 -0
- data/lib/common/BaseLoader.rb +80 -0
- data/lib/common/manager/Manager.rb +148 -0
- data/lib/common/models/Diff.rb +114 -0
- data/lib/common/models/ListChange.rb +21 -0
- data/lib/common/models/TagsDiff.rb +55 -0
- data/lib/common/models/UTCTimeSource.rb +17 -0
- data/lib/conf/Configuration.rb +365 -0
- data/lib/ec2/EC2.rb +503 -0
- data/lib/ec2/IPProtocolMapping.rb +165 -0
- data/lib/ec2/loaders/EbsLoader.rb +19 -0
- data/lib/ec2/loaders/InstanceLoader.rb +32 -0
- data/lib/ec2/managers/EbsManager.rb +176 -0
- data/lib/ec2/managers/InstanceManager.rb +509 -0
- data/lib/ec2/models/EbsGroupConfig.rb +133 -0
- data/lib/ec2/models/EbsGroupDiff.rb +48 -0
- data/lib/ec2/models/InstanceConfig.rb +202 -0
- data/lib/ec2/models/InstanceDiff.rb +95 -0
- data/lib/elb/ELB.rb +148 -0
- data/lib/elb/loader/Loader.rb +65 -0
- data/lib/elb/manager/Manager.rb +581 -0
- data/lib/elb/models/AccessLogConfig.rb +82 -0
- data/lib/elb/models/AccessLogDiff.rb +47 -0
- data/lib/elb/models/HealthCheckConfig.rb +91 -0
- data/lib/elb/models/HealthCheckDiff.rb +50 -0
- data/lib/elb/models/ListenerConfig.rb +99 -0
- data/lib/elb/models/ListenerDiff.rb +91 -0
- data/lib/elb/models/LoadBalancerConfig.rb +239 -0
- data/lib/elb/models/LoadBalancerDiff.rb +265 -0
- data/lib/iam/IAM.rb +36 -0
- data/lib/iam/loader/Loader.rb +117 -0
- data/lib/iam/manager/IamGroups.rb +98 -0
- data/lib/iam/manager/IamResource.rb +288 -0
- data/lib/iam/manager/IamRoles.rb +112 -0
- data/lib/iam/manager/IamUsers.rb +54 -0
- data/lib/iam/manager/Manager.rb +29 -0
- data/lib/iam/migration/AssumeRoleUnifier.rb +34 -0
- data/lib/iam/migration/PolicyUnifier.rb +90 -0
- data/lib/iam/models/GroupConfig.rb +40 -0
- data/lib/iam/models/IamDiff.rb +132 -0
- data/lib/iam/models/PolicyConfig.rb +67 -0
- data/lib/iam/models/ResourceWithPolicy.rb +208 -0
- data/lib/iam/models/RoleConfig.rb +53 -0
- data/lib/iam/models/StatementConfig.rb +35 -0
- data/lib/iam/models/UserConfig.rb +21 -0
- data/lib/kinesis/Kinesis.rb +94 -0
- data/lib/kinesis/loader/Loader.rb +19 -0
- data/lib/kinesis/manager/Manager.rb +206 -0
- data/lib/kinesis/models/StreamConfig.rb +75 -0
- data/lib/kinesis/models/StreamDiff.rb +58 -0
- data/lib/lambda/Lambda.rb +41 -0
- data/lib/route53/loader/Loader.rb +32 -0
- data/lib/route53/manager/Manager.rb +241 -0
- data/lib/route53/models/AliasTarget.rb +86 -0
- data/lib/route53/models/RecordConfig.rb +178 -0
- data/lib/route53/models/RecordDiff.rb +140 -0
- data/lib/route53/models/Vpc.rb +24 -0
- data/lib/route53/models/ZoneConfig.rb +156 -0
- data/lib/route53/models/ZoneDiff.rb +118 -0
- data/lib/s3/S3.rb +89 -0
- data/lib/s3/loader/Loader.rb +66 -0
- data/lib/s3/manager/Manager.rb +296 -0
- data/lib/s3/models/BucketConfig.rb +321 -0
- data/lib/s3/models/BucketDiff.rb +167 -0
- data/lib/s3/models/GrantConfig.rb +189 -0
- data/lib/s3/models/GrantDiff.rb +50 -0
- data/lib/s3/models/LifecycleConfig.rb +142 -0
- data/lib/s3/models/LifecycleDiff.rb +46 -0
- data/lib/s3/models/LoggingConfig.rb +81 -0
- data/lib/s3/models/NotificationConfig.rb +157 -0
- data/lib/s3/models/NotificationDiff.rb +62 -0
- data/lib/s3/models/ReplicationConfig.rb +133 -0
- data/lib/s3/models/ReplicationDiff.rb +60 -0
- data/lib/s3/models/WebsiteConfig.rb +107 -0
- data/lib/security/SecurityGroups.rb +39 -0
- data/lib/security/loader/Loader.rb +94 -0
- data/lib/security/manager/Manager.rb +246 -0
- data/lib/security/models/RuleConfig.rb +161 -0
- data/lib/security/models/RuleDiff.rb +72 -0
- data/lib/security/models/RuleMigration.rb +127 -0
- data/lib/security/models/SecurityGroupConfig.rb +172 -0
- data/lib/security/models/SecurityGroupDiff.rb +112 -0
- data/lib/sns/SNS.rb +40 -0
- data/lib/sqs/SQS.rb +62 -0
- data/lib/sqs/loader/Loader.rb +34 -0
- data/lib/sqs/manager/Manager.rb +128 -0
- data/lib/sqs/models/DeadLetterConfig.rb +70 -0
- data/lib/sqs/models/DeadLetterDiff.rb +35 -0
- data/lib/sqs/models/QueueConfig.rb +115 -0
- data/lib/sqs/models/QueueDiff.rb +89 -0
- data/lib/util/Colors.rb +111 -0
- data/lib/util/StatusCodes.rb +51 -0
- data/lib/vpc/loader/Loader.rb +73 -0
- data/lib/vpc/manager/Manager.rb +954 -0
- data/lib/vpc/models/AclEntryConfig.rb +150 -0
- data/lib/vpc/models/AclEntryDiff.rb +54 -0
- data/lib/vpc/models/DhcpConfig.rb +100 -0
- data/lib/vpc/models/DhcpDiff.rb +90 -0
- data/lib/vpc/models/EndpointConfig.rb +76 -0
- data/lib/vpc/models/EndpointDiff.rb +69 -0
- data/lib/vpc/models/NetworkAclConfig.rb +87 -0
- data/lib/vpc/models/NetworkAclDiff.rb +116 -0
- data/lib/vpc/models/RouteConfig.rb +82 -0
- data/lib/vpc/models/RouteDiff.rb +50 -0
- data/lib/vpc/models/RouteTableConfig.rb +92 -0
- data/lib/vpc/models/RouteTableDiff.rb +101 -0
- data/lib/vpc/models/SubnetConfig.rb +113 -0
- data/lib/vpc/models/SubnetDiff.rb +78 -0
- data/lib/vpc/models/VpcConfig.rb +173 -0
- data/lib/vpc/models/VpcDiff.rb +315 -0
- data/rakefile.rb +8 -0
- metadata +245 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
require "common/models/Diff"
|
|
2
|
+
require "common/models/ListChange"
|
|
3
|
+
require "util/Colors"
|
|
4
|
+
|
|
5
|
+
module Cumulus
|
|
6
|
+
module CloudFront
|
|
7
|
+
|
|
8
|
+
# Public: The types of changes that can be made to zones
|
|
9
|
+
module DistributionChange
|
|
10
|
+
include Common::DiffChange
|
|
11
|
+
|
|
12
|
+
ALIASES = Common::DiffChange::next_change_id
|
|
13
|
+
ORIGINS = Common::DiffChange::next_change_id
|
|
14
|
+
CACHE_DEFAULT = Common::DiffChange::next_change_id
|
|
15
|
+
CACHES = Common::DiffChange::next_change_id
|
|
16
|
+
COMMENT = Common::DiffChange::next_change_id
|
|
17
|
+
ENABLED = Common::DiffChange::next_change_id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Public: Represents a single difference between local configuration and AWS
|
|
21
|
+
# configuration of zones.
|
|
22
|
+
class DistributionDiff < Common::Diff
|
|
23
|
+
include DistributionChange
|
|
24
|
+
|
|
25
|
+
attr_accessor :changed_origins
|
|
26
|
+
attr_accessor :added_aliases
|
|
27
|
+
attr_accessor :removed_aliases
|
|
28
|
+
attr_accessor :default_cache
|
|
29
|
+
attr_accessor :cache
|
|
30
|
+
|
|
31
|
+
# Public: Static method that produces a diff representing changes in origins
|
|
32
|
+
#
|
|
33
|
+
# changes - the OriginDiffs
|
|
34
|
+
# local - the local configuration for the distribution
|
|
35
|
+
#
|
|
36
|
+
# Returns the diff
|
|
37
|
+
def self.origins(changes, local)
|
|
38
|
+
diff = DistributionDiff.new(ORIGINS, nil, local)
|
|
39
|
+
diff.changed_origins = changes
|
|
40
|
+
diff
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.aliases(added, removed, local)
|
|
44
|
+
diff = DistributionDiff.new(ALIASES, nil, local)
|
|
45
|
+
diff.added_aliases = added
|
|
46
|
+
diff.removed_aliases = removed
|
|
47
|
+
diff
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.default_cache(diffs, local)
|
|
51
|
+
diff = DistributionDiff.new(CACHE_DEFAULT, nil, local)
|
|
52
|
+
diff.default_cache = diffs
|
|
53
|
+
diff
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.caches(removed, added, diffs, local)
|
|
57
|
+
diff = DistributionDiff.new(CACHES, nil, local)
|
|
58
|
+
diff.cache = Common::ListChange.new(removed, added, diffs)
|
|
59
|
+
diff
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def diff_string
|
|
63
|
+
case @type
|
|
64
|
+
when ALIASES
|
|
65
|
+
[
|
|
66
|
+
"aliases:",
|
|
67
|
+
@removed_aliases.map { |removed| Colors.removed("\t#{removed}") },
|
|
68
|
+
@added_aliases.map { |added| Colors.added("\t#{added}") },
|
|
69
|
+
].flatten.join("\n")
|
|
70
|
+
when ORIGINS
|
|
71
|
+
[
|
|
72
|
+
"origins:",
|
|
73
|
+
@changed_origins.map do |o|
|
|
74
|
+
if o.type == ADD or o.type == UNMANAGED
|
|
75
|
+
o.to_s.lines.map { |l| "\t#{l}".chomp("\n")}
|
|
76
|
+
else
|
|
77
|
+
[
|
|
78
|
+
"\t#{o.local_name}",
|
|
79
|
+
o.to_s.lines.map { |l| "\t\t#{l}".chomp("\n")}
|
|
80
|
+
].join("\n")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
].flatten.join("\n")
|
|
84
|
+
when CACHE_DEFAULT
|
|
85
|
+
[
|
|
86
|
+
"default cache behavior:",
|
|
87
|
+
(@default_cache.map do |c|
|
|
88
|
+
c.to_s.lines.map { |l| "\t#{l}".chomp("\n")}
|
|
89
|
+
end).join("\n"),
|
|
90
|
+
].join("\n")
|
|
91
|
+
when CACHES
|
|
92
|
+
[
|
|
93
|
+
"cache behaviors:",
|
|
94
|
+
@cache.removed.map { |removed| Colors.removed("\t#{removed}") },
|
|
95
|
+
@cache.added.map { |added| Colors.added("\t#{added}") },
|
|
96
|
+
@cache.modified.map do |cache_name, cdiffs|
|
|
97
|
+
[
|
|
98
|
+
"\t#{cache_name}",
|
|
99
|
+
cdiffs.map do |cdiff|
|
|
100
|
+
cdiff.to_s.lines.map { |l| "\t\t#{l.chomp}"}
|
|
101
|
+
end
|
|
102
|
+
]
|
|
103
|
+
end
|
|
104
|
+
].flatten.join("\n")
|
|
105
|
+
when COMMENT
|
|
106
|
+
[
|
|
107
|
+
"comment:",
|
|
108
|
+
Colors.aws_changes("\tAWS - #{@aws.comment}"),
|
|
109
|
+
Colors.local_changes("\tLocal - #{@local.comment}"),
|
|
110
|
+
].join("\n")
|
|
111
|
+
when ENABLED
|
|
112
|
+
[
|
|
113
|
+
"enabled:",
|
|
114
|
+
Colors.aws_changes("\tAWS - #{@aws.enabled}"),
|
|
115
|
+
Colors.local_changes("\tLocal - #{@local.enabled}"),
|
|
116
|
+
].join("\n")
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def asset_type
|
|
121
|
+
"Cloudfront Distribution"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def aws_name
|
|
125
|
+
@aws.id
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
module Cumulus
|
|
4
|
+
module CloudFront
|
|
5
|
+
# Public: An object representing configuration for a CloudFront invalidation
|
|
6
|
+
class InvalidationConfig
|
|
7
|
+
attr_reader :distribution_id
|
|
8
|
+
attr_reader :paths
|
|
9
|
+
attr_reader :name
|
|
10
|
+
|
|
11
|
+
# Public: Constructor
|
|
12
|
+
#
|
|
13
|
+
# json - a hash containing the JSON configuration for the invalidation
|
|
14
|
+
def initialize(name, json = nil)
|
|
15
|
+
if json
|
|
16
|
+
@name = name
|
|
17
|
+
|
|
18
|
+
begin
|
|
19
|
+
@distribution_id = json.fetch("distribution-id")
|
|
20
|
+
rescue KeyError
|
|
21
|
+
puts "Must supply 'distribution-id' in invalidation config"
|
|
22
|
+
exit
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
@paths = json.fetch("paths")
|
|
27
|
+
rescue KeyError
|
|
28
|
+
puts "Must supply 'paths' in invalidation config"
|
|
29
|
+
exit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require "conf/Configuration"
|
|
2
|
+
require "cloudfront/models/CustomOriginConfig"
|
|
3
|
+
require "cloudfront/models/OriginDiff"
|
|
4
|
+
require "cloudfront/models/OriginSslProtocols"
|
|
5
|
+
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module Cumulus
|
|
9
|
+
module CloudFront
|
|
10
|
+
# Public: An object representing configuration for a origin
|
|
11
|
+
class OriginConfig
|
|
12
|
+
attr_reader :name
|
|
13
|
+
attr_reader :id
|
|
14
|
+
attr_reader :domain_name
|
|
15
|
+
attr_reader :origin_path
|
|
16
|
+
attr_reader :s3_access_origin_identity
|
|
17
|
+
attr_reader :custom_origin_config
|
|
18
|
+
|
|
19
|
+
# Public: Constructor
|
|
20
|
+
#
|
|
21
|
+
# json - a hash containing the JSON configuration for the origin
|
|
22
|
+
def initialize(json = nil)
|
|
23
|
+
if !json.nil?
|
|
24
|
+
@id = json["id"]
|
|
25
|
+
@domain_name = json["domain-name"]
|
|
26
|
+
@origin_path = json["origin-path"]
|
|
27
|
+
@s3_access_origin_identity = json["s3-origin-access-identity"]
|
|
28
|
+
@custom_origin_config = if json["custom-origin-config"].nil?
|
|
29
|
+
nil
|
|
30
|
+
else
|
|
31
|
+
CustomOriginConfig.new(
|
|
32
|
+
json["custom-origin-config"]["http-port"],
|
|
33
|
+
json["custom-origin-config"]["https-port"],
|
|
34
|
+
json["custom-origin-config"]["protocol-policy"],
|
|
35
|
+
json["custom-origin-config"]["origin-ssl-protocols"] && OriginSslProtocols.new(
|
|
36
|
+
json["custom-origin-config"]["origin-ssl-protocols"]
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
@name = @id
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def populate!(aws)
|
|
45
|
+
@id = aws.id
|
|
46
|
+
@domain_name = aws.domain_name
|
|
47
|
+
@origin_path = aws.origin_path
|
|
48
|
+
@s3_access_origin_identity = if aws.s3_origin_config then aws.s3_origin_config.origin_access_identity end
|
|
49
|
+
@custom_origin_config = if aws.custom_origin_config
|
|
50
|
+
CustomOriginConfig.new(
|
|
51
|
+
aws.custom_origin_config.http_port,
|
|
52
|
+
aws.custom_origin_config.https_port,
|
|
53
|
+
aws.custom_origin_config.origin_protocol_policy,
|
|
54
|
+
aws.custom_origin_config.origin_ssl_protocols && OriginSslProtocols.new(
|
|
55
|
+
aws.custom_origin_config.origin_ssl_protocols.items
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
@name = @id
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Public: Get the config as a hash
|
|
63
|
+
#
|
|
64
|
+
# Returns the hash
|
|
65
|
+
def to_local
|
|
66
|
+
{
|
|
67
|
+
"id" => @id,
|
|
68
|
+
"domain-name" => @domain_name,
|
|
69
|
+
"origin-path" => @origin_path,
|
|
70
|
+
"s3-origin-access-identity" => @s3_access_origin_identity,
|
|
71
|
+
"custom-origin-config" => if @custom_origin_config.nil? then nil else @custom_origin_config.to_local end
|
|
72
|
+
}.reject { |k, v| v.nil? }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def to_aws
|
|
76
|
+
{
|
|
77
|
+
id: @id,
|
|
78
|
+
domain_name: @domain_name,
|
|
79
|
+
origin_path: @origin_path,
|
|
80
|
+
s3_origin_config: if @s3_access_origin_identity.nil? then nil else
|
|
81
|
+
{
|
|
82
|
+
origin_access_identity: @s3_access_origin_identity
|
|
83
|
+
}
|
|
84
|
+
end,
|
|
85
|
+
custom_origin_config: if @custom_origin_config.nil? then nil else
|
|
86
|
+
{
|
|
87
|
+
http_port: @custom_origin_config.http_port,
|
|
88
|
+
https_port: @custom_origin_config.https_port,
|
|
89
|
+
origin_protocol_policy: @custom_origin_config.protocol_policy,
|
|
90
|
+
origin_ssl_protocols: if @custom_origin_config.origin_ssl_protocols
|
|
91
|
+
{
|
|
92
|
+
quantity: @custom_origin_config.origin_ssl_protocols.quantity,
|
|
93
|
+
items: @custom_origin_config.origin_ssl_protocols.items,
|
|
94
|
+
}
|
|
95
|
+
end
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Public: Produce an array of differences between this local configuration and the
|
|
102
|
+
# configuration in AWS
|
|
103
|
+
#
|
|
104
|
+
# aws - the AWS resource
|
|
105
|
+
#
|
|
106
|
+
# Returns an array of the OriginDiffs that were found
|
|
107
|
+
def diff(aws)
|
|
108
|
+
diffs = []
|
|
109
|
+
|
|
110
|
+
if @domain_name != aws.domain_name
|
|
111
|
+
diffs << OriginDiff.new(OriginChange::DOMAIN, aws, self)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
if @origin_path != aws.origin_path
|
|
115
|
+
diffs << OriginDiff.new(OriginChange::PATH, aws, self)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# If s3 origin is defined here but not aws
|
|
119
|
+
if !aws.s3_origin_config.nil?
|
|
120
|
+
if @s3_access_origin_identity != aws.s3_origin_config.origin_access_identity
|
|
121
|
+
diffs << OriginDiff.new(OriginChange::S3, aws, self)
|
|
122
|
+
end
|
|
123
|
+
else
|
|
124
|
+
if !@s3_access_origin_identity.nil?
|
|
125
|
+
diffs << OriginDiff.new(OriginChange::S3, aws, self)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
if @custom_origin_config.nil?
|
|
130
|
+
if !aws.custom_origin_config.nil?
|
|
131
|
+
custom_diffs = CustomOriginConfig.new(nil, nil, nil).diff(aws.custom_origin_config)
|
|
132
|
+
diffs << OriginDiff.custom(custom_diffs, aws, self) if !custom_diffs.empty?
|
|
133
|
+
end
|
|
134
|
+
else
|
|
135
|
+
custom_diffs = @custom_origin_config.diff(aws.custom_origin_config)
|
|
136
|
+
diffs << OriginDiff.custom(custom_diffs, aws, self) if !custom_diffs.empty?
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
diffs.flatten
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require "common/models/Diff"
|
|
2
|
+
require "util/Colors"
|
|
3
|
+
|
|
4
|
+
module Cumulus
|
|
5
|
+
module CloudFront
|
|
6
|
+
|
|
7
|
+
# Public: The types of changes that can be made to zones
|
|
8
|
+
module OriginChange
|
|
9
|
+
include Common::DiffChange
|
|
10
|
+
|
|
11
|
+
DOMAIN = Common::DiffChange::next_change_id
|
|
12
|
+
PATH = Common::DiffChange::next_change_id
|
|
13
|
+
S3 = Common::DiffChange::next_change_id
|
|
14
|
+
CUSTOM = Common::DiffChange::next_change_id
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Public: Represents a single difference between local configuration and AWS
|
|
18
|
+
# configuration of zones.
|
|
19
|
+
class OriginDiff < Common::Diff
|
|
20
|
+
include OriginChange
|
|
21
|
+
|
|
22
|
+
attr_accessor :custom_changes
|
|
23
|
+
|
|
24
|
+
# Public: Static method that produces a diff representing changes in custom origin
|
|
25
|
+
#
|
|
26
|
+
# changed_origins - the CustomOriginDiffs
|
|
27
|
+
# local - the local configuration for the zone
|
|
28
|
+
#
|
|
29
|
+
# Returns the diff
|
|
30
|
+
def self.custom(changes, aws, local)
|
|
31
|
+
diff = OriginDiff.new(CUSTOM, aws, local)
|
|
32
|
+
diff.custom_changes = changes
|
|
33
|
+
diff
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def diff_string
|
|
37
|
+
case @type
|
|
38
|
+
when DOMAIN
|
|
39
|
+
[
|
|
40
|
+
"domain:",
|
|
41
|
+
Colors.aws_changes("\tAWS - #{@aws.domain_name}"),
|
|
42
|
+
Colors.local_changes("\tLocal - #{@local.domain_name}"),
|
|
43
|
+
].join("\n")
|
|
44
|
+
when PATH
|
|
45
|
+
[
|
|
46
|
+
"path:",
|
|
47
|
+
Colors.aws_changes("\tAWS - #{@aws.origin_path}"),
|
|
48
|
+
Colors.local_changes("\tLocal - #{@local.origin_path}"),
|
|
49
|
+
].join("\n")
|
|
50
|
+
when S3
|
|
51
|
+
aws_value = (@aws.s3_origin_config.origin_access_identity rescue nil)
|
|
52
|
+
[
|
|
53
|
+
"s3 origin access identity:",
|
|
54
|
+
Colors.aws_changes("\tAWS - #{aws_value}"),
|
|
55
|
+
Colors.local_changes("\tLocal - #{@local.s3_access_origin_identity}"),
|
|
56
|
+
].join("\n")
|
|
57
|
+
when CUSTOM
|
|
58
|
+
[
|
|
59
|
+
"custom origin config:",
|
|
60
|
+
(@custom_changes.flat_map do |c|
|
|
61
|
+
c.to_s.lines.map { |l| "\t#{l.chomp}"}
|
|
62
|
+
end).join("\n"),
|
|
63
|
+
].join("\n")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def asset_type
|
|
68
|
+
if (!@local.nil? and @local.s3_access_origin_identity.nil?) or (!@aws.nil? and @aws.s3_origin_config.nil?)
|
|
69
|
+
"Custom Origin"
|
|
70
|
+
else
|
|
71
|
+
"S3 Origin"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def local_name
|
|
76
|
+
@local.id
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def aws_name
|
|
80
|
+
@aws.id
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "cloudfront/models/OriginSslProtocolsDiff"
|
|
2
|
+
|
|
3
|
+
module Cumulus
|
|
4
|
+
module CloudFront
|
|
5
|
+
OriginSslProtocols = Struct.new(:items) do
|
|
6
|
+
def quantity
|
|
7
|
+
items && items.length || 0
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def diff(aws)
|
|
11
|
+
diffs = []
|
|
12
|
+
|
|
13
|
+
aws_items = aws && aws.items || []
|
|
14
|
+
added_items = self.items - aws_items
|
|
15
|
+
removed_items = aws_items - self.items
|
|
16
|
+
if !added_items.empty? || !removed_items.empty?
|
|
17
|
+
diffs << OriginSslProtocolsDiff.items(added_items, removed_items, self)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
diffs
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_local
|
|
24
|
+
self.items
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "common/models/Diff"
|
|
2
|
+
require "common/models/ListChange"
|
|
3
|
+
require "util/Colors"
|
|
4
|
+
|
|
5
|
+
module Cumulus
|
|
6
|
+
module CloudFront
|
|
7
|
+
# Public: The types of changes that can be made to origin ssl protocols
|
|
8
|
+
module OriginSslProtocolsChange
|
|
9
|
+
include Common::DiffChange
|
|
10
|
+
|
|
11
|
+
ITEMS = Common::DiffChange::next_change_id
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Public: Represents a single difference between local configuration and AWS
|
|
15
|
+
# configuration of origin ssl protocols
|
|
16
|
+
class OriginSslProtocolsDiff < Common::Diff
|
|
17
|
+
include OriginSslProtocolsChange
|
|
18
|
+
|
|
19
|
+
attr_accessor :items
|
|
20
|
+
|
|
21
|
+
def self.items(added, removed, local)
|
|
22
|
+
diff = OriginSslProtocolsDiff.new(ITEMS, nil, local)
|
|
23
|
+
diff.items = Common::ListChange.new(added, removed)
|
|
24
|
+
diff
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def diff_string
|
|
28
|
+
case @type
|
|
29
|
+
when ITEMS
|
|
30
|
+
[
|
|
31
|
+
"items:",
|
|
32
|
+
@items.removed.map { |removed| Colors.removed("\t#{removed}") },
|
|
33
|
+
@items.added.map { |added| Colors.added("\t#{added}") },
|
|
34
|
+
].flatten.join("\n")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|