serverkit-aws 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +38 -9
- data/lib/serverkit/aws.rb +1 -0
- data/lib/serverkit/aws/client_options_generatable.rb +16 -0
- data/lib/serverkit/aws/version.rb +1 -1
- data/lib/serverkit/resources/cloud_front_web_distribution.rb +63 -0
- data/lib/serverkit/resources/s3_bucket.rb +3 -9
- data/serverkit-aws.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e7fa8e75351d9ff3c9d5ffcffbe1546e651552b
|
4
|
+
data.tar.gz: 39393fc23076116a7de457249535f40cd746af87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab356fef434f99366f9c4e4bb65145f98f75622df78469a78be773fdbc912224fa7e47788a80cc6d1aafc38bf2d8d6197144b11a36e527d1fca088c5a3c8e87
|
7
|
+
data.tar.gz: 25beffaeac0fb78c283b9d09066745ec781d519d616adb649f51743759f530b37810f185053905adb1189b8b1f8c7e30b1e6dd484d7b554a437b459d8f895f55
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,22 +8,42 @@ gem "serverkit-aws"
|
|
8
8
|
```
|
9
9
|
|
10
10
|
## Resource
|
11
|
-
###
|
12
|
-
Create a
|
11
|
+
### cloud_front_web_distribution
|
12
|
+
Create a CloudFront web distribution.
|
13
13
|
|
14
14
|
#### Attributes
|
15
|
-
- name - S3 bucket name (required) (e.g. `"my-bucket"`)
|
16
15
|
- aws_access_key_id - AWS access key ID
|
17
16
|
- aws_region - AWS region
|
18
17
|
- aws_secret_access_key - AWS secret access key
|
18
|
+
- distribution_config - distribution_config parameter
|
19
19
|
|
20
|
-
Note:
|
20
|
+
Note: some default parameters are reverse-merged into given distribution_config.
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
-
|
26
|
-
-
|
22
|
+
#### Example
|
23
|
+
```yml
|
24
|
+
resources:
|
25
|
+
- type: cloud_front_web_distribution
|
26
|
+
aws_region: ap-northeast-1
|
27
|
+
distribution_config:
|
28
|
+
caller_reference: test
|
29
|
+
default_cache_behavior:
|
30
|
+
target_origin_id: S3-test
|
31
|
+
origins:
|
32
|
+
items:
|
33
|
+
- id: S3-test
|
34
|
+
domain_name: test.s3.amazonaws.com
|
35
|
+
s3_origin_config:
|
36
|
+
origin_access_identity: ""
|
37
|
+
quantity: 1
|
38
|
+
```
|
39
|
+
### s3_bucket
|
40
|
+
Create a S3 bucket.
|
41
|
+
|
42
|
+
#### Attributes
|
43
|
+
- aws_access_key_id - AWS access key ID
|
44
|
+
- aws_region - AWS region
|
45
|
+
- aws_secret_access_key - AWS secret access key
|
46
|
+
- name - S3 bucket name (required) (e.g. `"my-bucket"`)
|
27
47
|
|
28
48
|
#### Example
|
29
49
|
```yml
|
@@ -32,3 +52,12 @@ resources:
|
|
32
52
|
name: my-bucket
|
33
53
|
aws_region: ap-northeast-1
|
34
54
|
```
|
55
|
+
|
56
|
+
## Credentials and Region
|
57
|
+
serverkit-aws searches the following locations for credentials and a region:
|
58
|
+
|
59
|
+
- `ENV["AWS_ACCESS_KEY_ID"]`
|
60
|
+
- `ENV["AWS_REGION"]`
|
61
|
+
- `ENV["AWS_SECRET_ACCESS_KEY"]`
|
62
|
+
- The shared credentials ini file at `~/.aws/credentials`
|
63
|
+
- From an instance profile when running on EC2
|
data/lib/serverkit/aws.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Serverkit
|
2
|
+
module Aws
|
3
|
+
module ClientOptionsGeneratable
|
4
|
+
private
|
5
|
+
|
6
|
+
# @return [Hash{Symbol => Object}]
|
7
|
+
def client_options
|
8
|
+
options = { region: aws_region }
|
9
|
+
if aws_access_key_id || aws_secret_access_key
|
10
|
+
options[:credentials] = ::Aws::Credentials.new(aws_access_key_id, aws_secret_access_key)
|
11
|
+
end
|
12
|
+
options
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "active_support/core_ext/hash/keys"
|
2
|
+
require "aws-sdk"
|
3
|
+
require "serverkit/aws/client_options_generatable"
|
4
|
+
require "serverkit/resources/base"
|
5
|
+
|
6
|
+
module Serverkit
|
7
|
+
module Resources
|
8
|
+
class CloudFrontWebDistribution < Base
|
9
|
+
include ::Serverkit::Aws::ClientOptionsGeneratable
|
10
|
+
|
11
|
+
DEFAULT_DISTRIBUTION_CONFIG = {
|
12
|
+
comment: "Created by serverkit-aws",
|
13
|
+
default_cache_behavior: {
|
14
|
+
forwarded_values: {
|
15
|
+
cookies: {
|
16
|
+
forward: "none",
|
17
|
+
},
|
18
|
+
query_string: false,
|
19
|
+
},
|
20
|
+
min_ttl: 0,
|
21
|
+
trusted_signers: {
|
22
|
+
enabled: false,
|
23
|
+
quantity: 0,
|
24
|
+
},
|
25
|
+
viewer_protocol_policy: "allow-all",
|
26
|
+
},
|
27
|
+
enabled: true,
|
28
|
+
}
|
29
|
+
|
30
|
+
attribute :aws_access_key_id, type: ::String
|
31
|
+
attribute :aws_region, type: ::String
|
32
|
+
attribute :aws_secret_access_key, type: ::String
|
33
|
+
attribute :distribution_config, type: ::Hash
|
34
|
+
|
35
|
+
# @note Override
|
36
|
+
def apply
|
37
|
+
client.create_distribution(
|
38
|
+
distribution_config: DEFAULT_DISTRIBUTION_CONFIG.deep_merge(
|
39
|
+
distribution_config.deep_symbolize_keys,
|
40
|
+
)
|
41
|
+
)
|
42
|
+
rescue ::Aws::CloudFront::Errors::DistributionAlreadyExists
|
43
|
+
end
|
44
|
+
|
45
|
+
# @note Override
|
46
|
+
def check
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
# @note Override
|
51
|
+
def recheck
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# @return [Aws::Cloudfront::Client]
|
58
|
+
def client
|
59
|
+
@client ||= ::Aws::CloudFront::Client.new(client_options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require "aws-sdk"
|
2
|
+
require "serverkit/aws/client_options_generatable"
|
2
3
|
require "serverkit/resources/base"
|
3
4
|
|
4
5
|
module Serverkit
|
5
6
|
module Resources
|
6
7
|
class S3Bucket < Base
|
8
|
+
include ::Serverkit::Aws::ClientOptionsGeneratable
|
9
|
+
|
7
10
|
attribute :aws_access_key_id, type: String
|
8
11
|
attribute :aws_region, type: String
|
9
12
|
attribute :aws_secret_access_key, type: String
|
@@ -28,15 +31,6 @@ module Serverkit
|
|
28
31
|
def client
|
29
32
|
@client ||= ::Aws::S3::Client.new(client_options)
|
30
33
|
end
|
31
|
-
|
32
|
-
# @return [Hash]
|
33
|
-
def client_options
|
34
|
-
options = { region: aws_region }
|
35
|
-
if aws_access_key_id || aws_secret_access_key
|
36
|
-
options[:credentials] = ::Aws::Credentials.new(aws_access_key_id, aws_secret_access_key)
|
37
|
-
end
|
38
|
-
options
|
39
|
-
end
|
40
34
|
end
|
41
35
|
end
|
42
36
|
end
|
data/serverkit-aws.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
+
spec.add_runtime_dependency "activesupport", ">= 4.0.2"
|
17
18
|
spec.add_runtime_dependency "aws-sdk", "~> 2"
|
18
19
|
spec.add_runtime_dependency "serverkit", ">= 0.6.7"
|
19
20
|
spec.add_development_dependency "bundler", "~> 1.9"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverkit-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: aws-sdk
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,9 @@ files:
|
|
80
94
|
- README.md
|
81
95
|
- Rakefile
|
82
96
|
- lib/serverkit/aws.rb
|
97
|
+
- lib/serverkit/aws/client_options_generatable.rb
|
83
98
|
- lib/serverkit/aws/version.rb
|
99
|
+
- lib/serverkit/resources/cloud_front_web_distribution.rb
|
84
100
|
- lib/serverkit/resources/s3_bucket.rb
|
85
101
|
- serverkit-aws.gemspec
|
86
102
|
homepage: https://github.com/serverkit/serverkit-s3
|