sumomo 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sumomo.rb +1 -0
- data/lib/sumomo/cdn.rb +82 -0
- data/lib/sumomo/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eeb93420ce5a5e732c9083fc72375a35f76ffec
|
4
|
+
data.tar.gz: ed8e2800baf73e0e093d38508345ac5a12dfc7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3103ccae5a572266e85b516059cf3b6a48921c486d70a905aa29d2e8e431ae706024e8656cdf9e84ebcdbfbf1404f1054f61df8f7f52bbc7a5f6cef10830b70b
|
7
|
+
data.tar.gz: 33c1a56f112b3e4a554ca0fdc9145d7ccac5b601be9ec2280e80213f048fbd668390e6f3adf6c30299f9ca2f1a752e3b40a18ab631e57e03980dd443a2d901d8
|
data/lib/sumomo.rb
CHANGED
data/lib/sumomo/cdn.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
module Sumomo
|
3
|
+
module Stack
|
4
|
+
def make_cdn_from_dir(domain:, dir:, low_ttl: [])
|
5
|
+
|
6
|
+
bucket_name = @bucket_name
|
7
|
+
|
8
|
+
puts "Uploading files..."
|
9
|
+
`aws s3 sync #{dir} "s3://#{bucket_name}/uploads/#{domain}" --size-only --delete`
|
10
|
+
puts "Done."
|
11
|
+
|
12
|
+
oai = make "Custom::OriginAccessIdentity"
|
13
|
+
|
14
|
+
make "AWS::S3::BucketPolicy" do
|
15
|
+
Bucket "#{bucket_name}"
|
16
|
+
PolicyDocument({
|
17
|
+
Version: "2008-10-17",
|
18
|
+
Id: "PolicyForCloudFrontPrivateContent",
|
19
|
+
Statement: [
|
20
|
+
{
|
21
|
+
Effect: "Allow",
|
22
|
+
Principal: {
|
23
|
+
CanonicalUser: oai.S3CanonicalUserId
|
24
|
+
},
|
25
|
+
Action: "s3:GetObject",
|
26
|
+
Resource: "arn:aws:s3:::#{bucket_name}/uploads/#{domain}/*"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
})
|
30
|
+
end
|
31
|
+
|
32
|
+
make "AWS::CloudFront::Distribution" do
|
33
|
+
DistributionConfig do
|
34
|
+
Origins [{
|
35
|
+
Id: "originBucket",
|
36
|
+
DomainName: "#{bucket_name}.s3.amazonaws.com",
|
37
|
+
OriginPath: "/uploads/#{domain}",
|
38
|
+
S3OriginConfig: {
|
39
|
+
OriginAccessIdentity: oai
|
40
|
+
}
|
41
|
+
}]
|
42
|
+
|
43
|
+
CacheBehaviors low_ttl.map{ |pattern|
|
44
|
+
{
|
45
|
+
PathPattern: pattern,
|
46
|
+
ForwardedValues: {
|
47
|
+
QueryString: "false",
|
48
|
+
Cookies: { Forward: "none" }
|
49
|
+
},
|
50
|
+
TargetOriginId: "originBucket",
|
51
|
+
ViewerProtocolPolicy: "allow-all",
|
52
|
+
DefaultTTL: 60,
|
53
|
+
MaxTTL: 60,
|
54
|
+
MinTTL: 60
|
55
|
+
}
|
56
|
+
}.to_a
|
57
|
+
|
58
|
+
Enabled "true"
|
59
|
+
DefaultRootObject "index.html"
|
60
|
+
Aliases [ domain ]
|
61
|
+
ViewerCertificate { CloudFrontDefaultCertificate "true" }
|
62
|
+
|
63
|
+
DefaultCacheBehavior do
|
64
|
+
AllowedMethods ["GET", "HEAD", "OPTIONS"]
|
65
|
+
TargetOriginId "originBucket"
|
66
|
+
ViewerProtocolPolicy "allow-all"
|
67
|
+
ForwardedValues {
|
68
|
+
QueryString "false"
|
69
|
+
Cookies { Forward "none" }
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
Logging do
|
74
|
+
IncludeCookies "false"
|
75
|
+
Bucket "#{bucket_name}.s3.amazonaws.com"
|
76
|
+
Prefix "logs/#{domain}/"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/sumomo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sumomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Siaw
|
@@ -2526,6 +2526,7 @@ files:
|
|
2526
2526
|
- exe/sumomo
|
2527
2527
|
- lib/sumomo.rb
|
2528
2528
|
- lib/sumomo/api.rb
|
2529
|
+
- lib/sumomo/cdn.rb
|
2529
2530
|
- lib/sumomo/dns.rb
|
2530
2531
|
- lib/sumomo/ec2.rb
|
2531
2532
|
- lib/sumomo/ecs.rb
|