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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e84c0fec840014d49e5cf67d7a3bcb1886c6a9d2
4
- data.tar.gz: 4da738f7000edf523f7e054eeccf505b756563f4
3
+ metadata.gz: 3eeb93420ce5a5e732c9083fc72375a35f76ffec
4
+ data.tar.gz: ed8e2800baf73e0e093d38508345ac5a12dfc7a3
5
5
  SHA512:
6
- metadata.gz: dffae49afed2bc7868ea0616a1aa053293d42c31a47cd53795f284ff140bd167b210f3e07c5bb24c25a9c6275ff653a1d528fd5610b66ac0f8c33ee8488d4ba5
7
- data.tar.gz: 8d7b8e26b90f74dce32e6614af5c282aa79c3e0b94f994e3bc612e269c1799a870fd86282bdc2e0fa65b4ee9184781b02fb8a8f02b57ba9a65fc8c1d1ed30a32
6
+ metadata.gz: 3103ccae5a572266e85b516059cf3b6a48921c486d70a905aa29d2e8e431ae706024e8656cdf9e84ebcdbfbf1404f1054f61df8f7f52bbc7a5f6cef10830b70b
7
+ data.tar.gz: 33c1a56f112b3e4a554ca0fdc9145d7ccac5b601be9ec2280e80213f048fbd668390e6f3adf6c30299f9ca2f1a752e3b40a18ab631e57e03980dd443a2d901d8
data/lib/sumomo.rb CHANGED
@@ -6,6 +6,7 @@ require 'yaml'
6
6
 
7
7
  require "sumomo/version"
8
8
  require 'sumomo/api'
9
+ require 'sumomo/cdn'
9
10
  require 'sumomo/dns'
10
11
  require 'sumomo/ec2'
11
12
  require 'sumomo/ecs'
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
@@ -1,3 +1,3 @@
1
1
  module Sumomo
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
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.2
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