configure-s3-website 2.0.0 → 2.1.0

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: d8aeecfcf2c39ebb0f814a54d3782130e12e9e25
4
- data.tar.gz: c73066e5e5b09d982985efb9b45352dab92a7776
3
+ metadata.gz: c33ce4f35ab6af0df19dc186cd931a5cc70d96e4
4
+ data.tar.gz: 86ef41e2572b387d6ea1666b030135e5179341d0
5
5
  SHA512:
6
- metadata.gz: 4ddc2df2a4940adb7bb10dd89b6e769011ce9d2101833b0063bdb8f1dad6ae022425cd4ed78b8502b21561ce4944ade726c35c79f2ca119f2d32846dddb90aaf
7
- data.tar.gz: f4c9cf08d17924c9147ecb18aca2282e678080f8bb82d7e709ba0a5579e160aa2463a2587d274e6452adc3d77f37394a493e2829b3ba5dca5ee42d0c01962b11
6
+ metadata.gz: fd81ad8e3e2d4304ffd8cd9231671e9f428fb380064ba60b1624b4401600abf5ec1b4480befb8d8f48acd8de737a5a6dbb3e8e2de7dfda552c606533568c2288
7
+ data.tar.gz: b3654371cf9a0e2ec151c94af155577ec438421714e179786f5e956b1c57010d63bf8228a688d4cf39cabe25aab5df3723c4e28ae9aa4b938b5211841b9ad33e
data/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  [![Build Status](https://secure.travis-ci.org/laurilehmijoki/configure-s3-website.png)](http://travis-ci.org/laurilehmijoki/configure-s3-website)
4
4
  [![Gem Version](https://fury-badge.herokuapp.com/rb/configure-s3-website.png)](http://badge.fury.io/rb/configure-s3-website)
5
5
 
6
- Configure an AWS S3 bucket to function as a website. Easily from the
7
- command-line interface.
6
+ Configure an AWS S3 bucket to function as a website easily from a command-line interface.
8
7
 
9
8
  The bucket may or may not exist. If the bucket does not exist,
10
9
  `configure-s3-website` will create it.
@@ -17,7 +16,14 @@ For deploying websites to S3, consider using [s3_website](https://github.com/lau
17
16
 
18
17
  ## Usage
19
18
 
20
- Create a file that contains the S3 credentials and the name of the bucket:
19
+ Create a file that contains the name of your AWS profile with access to S3 and the name of the bucket:
20
+
21
+ ```yaml
22
+ profile: name-of-your-aws-profile-with-access
23
+ s3_bucket: name-of-your-bucket
24
+ ```
25
+
26
+ **or** create a file that contains the S3 credentials and the name of the bucket:
21
27
 
22
28
  ```yaml
23
29
  s3_id: your-aws-access-key
@@ -70,11 +76,11 @@ file. For example:
70
76
  ```yaml
71
77
  cloudfront_distribution_config:
72
78
  default_cache_behavior:
73
- min_TTL: 600
79
+ min_ttl: 600
74
80
  aliases:
75
81
  quantity: 1
76
82
  items:
77
- CNAME: your.domain.net
83
+ - your.domain.net
78
84
  ```
79
85
 
80
86
  See the section below for more information about the valid values of the
@@ -94,12 +100,12 @@ Let's say your config file contains the following fragment:
94
100
  cloudfront_distribution_id: AXSAXSSE134
95
101
  cloudfront_distribution_config:
96
102
  default_cache_behavior:
97
- min_TTL: 600
103
+ min_ttl: 600
98
104
  default_root_object: index.json
99
105
  ```
100
106
 
101
107
  When you invoke `configure-s3-website`, it will overwrite the default value of
102
- *default_cache_behavior's* *min_TTL* as well as the default value of
108
+ *default_cache_behavior's* *min_ttl* as well as the default value of
103
109
  *default_root_object* setting in the [default distribution configs](#default-distribution-configs).
104
110
 
105
111
  This gem generates `<DistributionConfig>` of the CloudFront REST API. For
@@ -151,7 +157,7 @@ Type](http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/Distributi
151
157
  }
152
158
  },
153
159
  'viewer_protocol_policy' => 'allow-all',
154
- 'min_TTL' => '86400'
160
+ 'min_ttl' => '86400'
155
161
  },
156
162
  'cache_behaviors' => {
157
163
  'quantity' => '0'
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 2.1.0
6
+
7
+ * Add ability to use an AWS profile instead of explicit `s3_id` and `s3_secret`
8
+
5
9
  ## 2.0.0
6
10
 
7
11
  ### Breaking changes
@@ -20,6 +20,10 @@ module ConfigureS3Website
20
20
  @config['s3_secret']
21
21
  end
22
22
 
23
+ def profile
24
+ @config['profile']
25
+ end
26
+
23
27
  def s3_bucket_name
24
28
  @config['s3_bucket']
25
29
  end
@@ -74,10 +78,14 @@ module ConfigureS3Website
74
78
  end
75
79
 
76
80
  def self.validate_config(config, yaml_file_path)
77
- required_keys = %w{s3_id s3_secret s3_bucket}
78
- missing_keys = required_keys.reject do |key| config.keys.include?key end
79
- unless missing_keys.empty?
80
- raise "File #{yaml_file_path} does not contain the required key(s) #{missing_keys.join(', ')}"
81
+ # make sure the bucket name is configured at a minimum
82
+ if not config.keys.include?'s3_bucket'
83
+ raise "File #{yaml_file_path} does not contain the required key 's3_bucket'"
84
+ end
85
+
86
+ # check that either s3_id or profile is configured
87
+ if not (config.keys.include?'s3_id' or config.keys.include?'profile')
88
+ raise "File #{yaml_file_path} does not contain either 's3_id' or 'profile'"
81
89
  end
82
90
  end
83
91
  end
@@ -21,11 +21,18 @@ module ConfigureS3Website
21
21
  private
22
22
 
23
23
  def self.s3(config_source)
24
- s3 = Aws::S3::Client.new(
25
- region: config_source.s3_endpoint,
26
- access_key_id: config_source.s3_access_key_id,
27
- secret_access_key: config_source.s3_secret_access_key
28
- )
24
+ if config_source.s3_access_key_id
25
+ Aws::S3::Client.new(
26
+ region: config_source.s3_endpoint,
27
+ access_key_id: config_source.s3_access_key_id,
28
+ secret_access_key: config_source.s3_secret_access_key
29
+ )
30
+ else
31
+ Aws::S3::Client.new(
32
+ region: config_source.s3_endpoint,
33
+ profile: config_source.profile,
34
+ )
35
+ end
29
36
  end
30
37
 
31
38
  def self.enable_website_configuration(config_source)
@@ -1,3 +1,3 @@
1
1
  module ConfigureS3Website
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configure-s3-website
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge