lucid-cumulus 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +11 -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/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/lucid-cumulus.gemspec +20 -0
- data/rakefile.rb +8 -0
- metadata +245 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module AwsExtensions
|
2
|
+
module ELB
|
3
|
+
module PolicyDescription
|
4
|
+
# Public: Convert this Aws::ELB::Types::PolicyDescription
|
5
|
+
# into a json version for migrating to Cumulus
|
6
|
+
def to_cumulus_hash
|
7
|
+
{
|
8
|
+
"type" => self.policy_type_name,
|
9
|
+
"attributes" => Hash[self.policy_attribute_descriptions.map { |a| [a.attribute_name, a.attribute_value] }]
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AwsExtensions
|
2
|
+
module Kinesis
|
3
|
+
module StreamDescription
|
4
|
+
|
5
|
+
# Public: Get the list of open shards sorted by hash key range, ascending
|
6
|
+
def sorted_shards
|
7
|
+
self.shards.select { |shard| shard.sequence_number_range.ending_sequence_number.nil? }
|
8
|
+
.sort_by { |shard| shard.hash_key_range.starting_hash_key.to_i }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AwsExtensions
|
2
|
+
module Route53
|
3
|
+
module AliasTarget
|
4
|
+
# Public: Method that will reformat the dns_name of an ELB from Route53 alias
|
5
|
+
# to be the same as the dns_name on a regular ELB.
|
6
|
+
#
|
7
|
+
# Returns the string reformatted dns_name
|
8
|
+
def elb_dns_name
|
9
|
+
dns_name.sub(/^dualstack\./, '').chomp(".")
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Method that will reformat the dns_name to remove the trailing "." from
|
13
|
+
# the dns_name if it is present.
|
14
|
+
#
|
15
|
+
# Returns the string reformatted dns_name
|
16
|
+
def chomped_dns
|
17
|
+
dns_name.chomp(".")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "conf/Configuration"
|
2
|
+
require "s3/S3"
|
3
|
+
|
4
|
+
module AwsExtensions
|
5
|
+
module S3
|
6
|
+
module Types
|
7
|
+
module Bucket
|
8
|
+
# Public: Method that will request the location of the bucket. Used to monkey patch
|
9
|
+
# Aws::S3::Types::Bucket
|
10
|
+
def location
|
11
|
+
location = Cumulus::S3::client.get_bucket_location({bucket: name}).location_constraint
|
12
|
+
if location == ""
|
13
|
+
Cumulus::Configuration.instance.client[:region]
|
14
|
+
else
|
15
|
+
location
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Bucket
|
22
|
+
# Public: Method used to extend the Bucket class so that it will return
|
23
|
+
# replication rules.
|
24
|
+
#
|
25
|
+
# Returns the associated Aws::S3::Types::ReplicationConfiguration
|
26
|
+
def replication
|
27
|
+
Cumulus::S3::client(location).get_bucket_replication({bucket: name}).replication_configuration
|
28
|
+
rescue Aws::S3::Errors::ReplicationConfigurationNotFoundError
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "s3/models/GrantConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketAcl
|
6
|
+
# Public: Turn the grants in the Aws::S3::BucketAcl into an array of
|
7
|
+
# Cumulus::S3::Grant so we can use them.
|
8
|
+
#
|
9
|
+
# Returns an array of Grants
|
10
|
+
def to_cumulus
|
11
|
+
grants_hash = {}
|
12
|
+
|
13
|
+
grants.each do |grant|
|
14
|
+
cumulus = Cumulus::S3::GrantConfig.new
|
15
|
+
cumulus.populate!(grant)
|
16
|
+
|
17
|
+
if grants_hash.include? cumulus.name
|
18
|
+
grants_hash[cumulus.name].add_permissions!(cumulus.permissions)
|
19
|
+
else
|
20
|
+
grants_hash[cumulus.name] = cumulus
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
grants_hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketCors
|
6
|
+
# Public: Method that will return the bucket cors. We have this method
|
7
|
+
# because if there are no CORS rules, an exception is thrown.
|
8
|
+
#
|
9
|
+
# Returns an array of Aws::S3::CORSRule
|
10
|
+
def rules
|
11
|
+
cors_rules
|
12
|
+
rescue Aws::S3::Errors::NoSuchCORSConfiguration
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "s3/models/LifecycleConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketLifecycle
|
6
|
+
# Public: Convert this Aws::S3::BucketLifecycle into an array of
|
7
|
+
# Cumulus::S3::LifecycleConfig
|
8
|
+
#
|
9
|
+
# Returns the array of LifecycleConfig
|
10
|
+
def to_cumulus
|
11
|
+
Hash[rules.reject { |r| r.status.downcase != "enabled" }.map do |rule|
|
12
|
+
cumulus = Cumulus::S3::LifecycleConfig.new
|
13
|
+
cumulus.populate!(rule)
|
14
|
+
[cumulus.name, cumulus]
|
15
|
+
end]
|
16
|
+
rescue Aws::S3::Errors::NoSuchLifecycleConfiguration
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "s3/models/LoggingConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketLogging
|
6
|
+
# Public: Convert this Aws::S3::BucketLogging into a Cumulus::S3::LoggingConfig
|
7
|
+
#
|
8
|
+
# Returns a LoggingConfig
|
9
|
+
def to_cumulus
|
10
|
+
if logging_enabled
|
11
|
+
cumulus = Cumulus::S3::LoggingConfig.new
|
12
|
+
cumulus.populate!(self)
|
13
|
+
cumulus
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "s3/models/NotificationConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketNotification
|
6
|
+
# Public: Convert this Aws::S3::BucketNotification into an array of
|
7
|
+
# Cumulus::S3::NotificationConfig
|
8
|
+
#
|
9
|
+
# Returns the array of NotificationConfigs
|
10
|
+
def to_cumulus
|
11
|
+
Hash[(
|
12
|
+
lambda_function_configurations +
|
13
|
+
queue_configurations +
|
14
|
+
topic_configurations
|
15
|
+
).map do |configuration|
|
16
|
+
cumulus = Cumulus::S3::NotificationConfig.new
|
17
|
+
cumulus.populate!(configuration)
|
18
|
+
cumulus
|
19
|
+
end.map { |configuration| [configuration.name, configuration] }]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketPolicy
|
6
|
+
# Public: Method that will either return the bucket policy, or an empty
|
7
|
+
# string if there is no policy. We have to do this because catching an
|
8
|
+
# exception is the ONLY way to determine if there is a policy.
|
9
|
+
#
|
10
|
+
# Returns the policy as a string.
|
11
|
+
def policy_string
|
12
|
+
policy.string
|
13
|
+
rescue Aws::S3::Errors::NoSuchBucketPolicy
|
14
|
+
""
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AwsExtensions
|
2
|
+
module S3
|
3
|
+
module BucketTagging
|
4
|
+
# Public: Safely get the tag set for the BucketTagging object (ignore the
|
5
|
+
# exception that occurs when there aren't any tags)
|
6
|
+
#
|
7
|
+
# Returns the tags or an empty array if there are none
|
8
|
+
def safe_tags
|
9
|
+
tag_set
|
10
|
+
rescue Aws::S3::Errors::NoSuchTagSet
|
11
|
+
[]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AwsExtensions
|
2
|
+
module S3
|
3
|
+
module BucketVersioning
|
4
|
+
# Public: Return whether versioning is currently on. We need this method
|
5
|
+
# because AWS returns nil when you've never versioned or the string
|
6
|
+
# 'Suspended' if you had in the past, but have turned it off.
|
7
|
+
#
|
8
|
+
# Returns whether versioning is currently on
|
9
|
+
def enabled
|
10
|
+
!(status.nil? or status.downcase == "suspended")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "s3/models/WebsiteConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module BucketWebsite
|
6
|
+
# Public: Convert this Aws::S3::BucketWebsite into a Cumulus::S3:WebsiteConfig
|
7
|
+
#
|
8
|
+
# Returns a WebsiteConfig
|
9
|
+
def to_cumulus
|
10
|
+
if safe_index or safe_redirection
|
11
|
+
cumulus = Cumulus::S3::WebsiteConfig.new
|
12
|
+
cumulus.populate!(self)
|
13
|
+
cumulus
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Public: Get the index_document if it is present, or nil if it is not
|
18
|
+
#
|
19
|
+
# Returns the value
|
20
|
+
def safe_index
|
21
|
+
index_document.suffix
|
22
|
+
rescue Aws::S3::Errors::NoSuchWebsiteConfiguration, NoMethodError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# Public: Get the error_document if it is present, or nil if it is not
|
27
|
+
#
|
28
|
+
# Returns the value
|
29
|
+
def safe_error
|
30
|
+
error_document.key
|
31
|
+
rescue Aws::S3::Errors::NoSuchWebsiteConfiguration, NoMethodError
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Public: Get the redirection if it is present, or nil if it is not
|
36
|
+
#
|
37
|
+
# Returns the value
|
38
|
+
def safe_redirection
|
39
|
+
if redirect_all_requests_to.protocol
|
40
|
+
"#{redirect_all_requests_to.protocol}://#{redirect_all_requests_to.host_name}"
|
41
|
+
else
|
42
|
+
redirect_all_requests_to.host_name
|
43
|
+
end
|
44
|
+
rescue Aws::S3::Errors::NoSuchWebsiteConfiguration, NoMethodError
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module CORSRule
|
6
|
+
def to_s
|
7
|
+
[
|
8
|
+
"Origins: #{allowed_origins.join(",")}",
|
9
|
+
"Methods: #{allowed_methods.join(", ")}",
|
10
|
+
"Headers: #{allowed_headers.join(",")}",
|
11
|
+
("Exposed Headers: #{expose_headers.join(", ")}" unless expose_headers.empty?),
|
12
|
+
"Max Age Seconds: #{max_age_seconds}"
|
13
|
+
].reject { |s| s.nil? }.join(", ")
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
{
|
18
|
+
"origins" => allowed_origins,
|
19
|
+
"methods" => allowed_methods,
|
20
|
+
"headers" => allowed_headers,
|
21
|
+
"exposed-headers" => expose_headers,
|
22
|
+
"max-age-seconds" => max_age_seconds
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "s3/models/ReplicationConfig"
|
2
|
+
|
3
|
+
module AwsExtensions
|
4
|
+
module S3
|
5
|
+
module ReplicationConfiguration
|
6
|
+
# Public: Convert this Aws::S3::Types::ReplicationConfiguration into a
|
7
|
+
# Cumulus::S3::ReplicationConfig
|
8
|
+
#
|
9
|
+
# Returns the ReplicationConfig
|
10
|
+
def to_cumulus
|
11
|
+
cumulus = Cumulus::S3::ReplicationConfig.new
|
12
|
+
cumulus.populate!(self)
|
13
|
+
|
14
|
+
if self.rules[0].status.downcase != "disabled"
|
15
|
+
cumulus
|
16
|
+
end
|
17
|
+
rescue
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require "conf/Configuration"
|
2
|
+
|
3
|
+
require "aws-sdk"
|
4
|
+
|
5
|
+
module Cumulus
|
6
|
+
module CloudFront
|
7
|
+
class << self
|
8
|
+
@@client = Aws::CloudFront::Client.new(Configuration.instance.client)
|
9
|
+
|
10
|
+
# Public: Static method that will get a distribution from AWS by its cname.
|
11
|
+
#
|
12
|
+
# cname - the cname of the distribution to get
|
13
|
+
#
|
14
|
+
# Returns the Aws::CloudFront::Types::DistributionSummary
|
15
|
+
def get_aws(cname)
|
16
|
+
if cname_distributions[cname].nil?
|
17
|
+
puts "No CloudFront distribution named #{cname}"
|
18
|
+
exit
|
19
|
+
else
|
20
|
+
cname_distributions[cname]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Public: Provides a mapping of cloudfront distribution configs to their id. Lazily loads resources.
|
25
|
+
#
|
26
|
+
# Returns the distribution configs mapped to their ids
|
27
|
+
def id_distributions
|
28
|
+
@full_distributions ||= Hash[distributions.map { |dist| [dist.id, dist] }]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Public: Load the full config for a distribution from AWS
|
32
|
+
#
|
33
|
+
# Returns an Aws::CloudFront::Types::GetDistributionConfigResult
|
34
|
+
def load_distribution_config(distribution_id)
|
35
|
+
@@client.get_distribution_config({
|
36
|
+
id: distribution_id
|
37
|
+
}).data
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Internal: Provide a mapping of CloudFront distributions to their cnames. Lazily loads resources.
|
43
|
+
# Distributions without cnames are not included
|
44
|
+
#
|
45
|
+
# Returns the distributions mapped to their cnames
|
46
|
+
def cname_distributions
|
47
|
+
Hash[distributions.flat_map do |dist|
|
48
|
+
dist.aliases.items.map { |a| [a, dist] }
|
49
|
+
end]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Internal: Provides a list of cloudfront distributions. Lazily loads resources.
|
53
|
+
#
|
54
|
+
# Returns the distributions
|
55
|
+
def distributions
|
56
|
+
@distributions ||= init_distributions
|
57
|
+
end
|
58
|
+
|
59
|
+
# Internal: Load the distributions and map them to their cnames.
|
60
|
+
#
|
61
|
+
# Returns the distributions mapped to their cnames
|
62
|
+
def init_distributions
|
63
|
+
distributions = []
|
64
|
+
all_records_retrieved = false
|
65
|
+
next_marker = nil
|
66
|
+
|
67
|
+
until all_records_retrieved
|
68
|
+
response = @@client.list_distributions({
|
69
|
+
marker: next_marker
|
70
|
+
}.reject { |k, v| v.nil? })
|
71
|
+
distributions << response.distribution_list.items
|
72
|
+
next_marker = response.distribution_list.next_marker
|
73
|
+
|
74
|
+
if !response.distribution_list.is_truncated
|
75
|
+
all_records_retrieved = true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
distributions.flatten
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|