fog-aws 3.13.0 → 3.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -1
- data/README.md +43 -0
- data/lib/fog/aws/credential_fetcher.rb +8 -1
- data/lib/fog/aws/models/storage/directories.rb +1 -0
- data/lib/fog/aws/requests/rds/add_tags_to_resource.rb +12 -10
- data/lib/fog/aws/requests/rds/list_tags_for_resource.rb +10 -7
- data/lib/fog/aws/requests/rds/remove_tags_from_resource.rb +9 -8
- data/lib/fog/aws/storage.rb +5 -1
- data/lib/fog/aws/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8af574874772df5b7a7e51819b23f554543472c6cef0b4ff86addac3b0c24b7
|
4
|
+
data.tar.gz: f5171df32eec2c204d27ce7ac7ef361d5b7bc9c0761b6b95efd347b977deb97c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0526c83e1825435460136d7afa5f2467e88de9171ed64fcbe0fc75871ffd2564435b310f54585de0e24e2dbb38d36fa969952c0da98787e6d43fb8128950ad36
|
7
|
+
data.tar.gz: b9282f04b1b59446ab5781154932461d9230e6ef58dde2d573dd8bc488722faa02e54b77a376bda9e1ab8391a673c44bd975f24be9e1ade9ec7b30f1b817c70f
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [v3.
|
3
|
+
## [v3.14.0](https://github.com/fog/fog-aws/tree/v3.14.0) (2022-05-09)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/fog/fog-aws/compare/v3.13.0...HEAD)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Add a special note to the documentation around the danger of using directory.get [\#633](https://github.com/fog/fog-aws/issues/633)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- RDD tags issue in AWS GovCloud Account regions. [\#643](https://github.com/fog/fog-aws/pull/643) ([svavhal](https://github.com/svavhal))
|
14
|
+
- Create codeql.yml [\#641](https://github.com/fog/fog-aws/pull/641) ([naveensrinivasan](https://github.com/naveensrinivasan))
|
15
|
+
- chore\(deps\): Included dependency review [\#640](https://github.com/fog/fog-aws/pull/640) ([naveensrinivasan](https://github.com/naveensrinivasan))
|
16
|
+
- Bump actions/stale from 4 to 5 [\#639](https://github.com/fog/fog-aws/pull/639) ([dependabot[bot]](https://github.com/apps/dependabot))
|
17
|
+
- Set permissions for GitHub actions [\#638](https://github.com/fog/fog-aws/pull/638) ([naveensrinivasan](https://github.com/naveensrinivasan))
|
18
|
+
- Add option to control IAM credential refresh [\#637](https://github.com/fog/fog-aws/pull/637) ([gl-gh-hchouraria](https://github.com/gl-gh-hchouraria))
|
19
|
+
- Add warning messages around directories.get [\#636](https://github.com/fog/fog-aws/pull/636) ([orrin-naylor-instacart](https://github.com/orrin-naylor-instacart))
|
20
|
+
- Bump actions/checkout from 2.4.0 to 3 [\#632](https://github.com/fog/fog-aws/pull/632) ([dependabot[bot]](https://github.com/apps/dependabot))
|
21
|
+
- Add Ruby 3.1 to the CI matrix [\#631](https://github.com/fog/fog-aws/pull/631) ([petergoldstein](https://github.com/petergoldstein))
|
22
|
+
|
23
|
+
## [v3.13.0](https://github.com/fog/fog-aws/tree/v3.13.0) (2022-02-13)
|
4
24
|
|
5
25
|
[Full Changelog](https://github.com/fog/fog-aws/compare/v3.12.0...v3.13.0)
|
6
26
|
|
data/README.md
CHANGED
@@ -98,6 +98,7 @@ file = directory.files.create(key: 'user/1/Gemfile', body: File.open('Gemfile'),
|
|
98
98
|
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
|
99
99
|
directory.files
|
100
100
|
```
|
101
|
+
**Warning!** `s3.directories.get` retrieves and caches meta data for the first 10,000 objects in the bucket, which can be very expensive. When possible use `s3.directories.new`.
|
101
102
|
|
102
103
|
#### Generating a URL for a file:
|
103
104
|
|
@@ -105,6 +106,48 @@ directory.files
|
|
105
106
|
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
|
106
107
|
```
|
107
108
|
|
109
|
+
##### Controlling credential refresh time with IAM authentication
|
110
|
+
|
111
|
+
When using IAM authentication with
|
112
|
+
[temporary security credentials](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html),
|
113
|
+
generated S3 pre-signed URLs
|
114
|
+
[only last as long as the temporary credential](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html).
|
115
|
+
|
116
|
+
Generating the URLs in the following manner will return a URL
|
117
|
+
that will not last as long as its requested expiration time if
|
118
|
+
the remainder of the authentication token lifetime was shorter.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
s3 = Fog::Storage.new(provider: 'AWS', use_iam_auth: true)
|
122
|
+
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
|
123
|
+
|
124
|
+
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
|
125
|
+
```
|
126
|
+
|
127
|
+
By default the temporary credentials in use are refreshed only within the last
|
128
|
+
15 seconds of its expiration time. The URL requested with 60 seconds lifetime
|
129
|
+
using the above example will only remain valid for 15 seconds in the worst case.
|
130
|
+
|
131
|
+
The problem can be avoided by refreshing the token early and often,
|
132
|
+
by setting configuration `aws_credentials_refresh_threshold_seconds` (default: 15)
|
133
|
+
which controls the time when the refresh must occur. It is expressed in seconds
|
134
|
+
before the temporary credential's expiration time.
|
135
|
+
|
136
|
+
The following example can ensure pre-signed URLs last as long as 60 seconds
|
137
|
+
by automatically refreshing the credentials when its remainder lifetime
|
138
|
+
is lower than 60 seconds:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
s3 = Fog::Storage.new(
|
142
|
+
provider: 'AWS',
|
143
|
+
use_iam_auth: true,
|
144
|
+
aws_credentials_refresh_threshold_seconds: 60
|
145
|
+
)
|
146
|
+
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
|
147
|
+
|
148
|
+
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
|
149
|
+
```
|
150
|
+
|
108
151
|
#### Copying a file
|
109
152
|
|
110
153
|
```ruby
|
@@ -123,10 +123,17 @@ module Fog
|
|
123
123
|
|
124
124
|
private
|
125
125
|
|
126
|
+
# When defined, 'aws_credentials_refresh_threshold_seconds' controls
|
127
|
+
# when the credential needs to be refreshed, expressed in seconds before
|
128
|
+
# the current credential's expiration time
|
129
|
+
def credentials_refresh_threshold
|
130
|
+
@aws_credentials_refresh_threshold_seconds || 15
|
131
|
+
end
|
132
|
+
|
126
133
|
def credentials_expired?
|
127
134
|
@use_iam_profile &&
|
128
135
|
(!@aws_credentials_expire_at ||
|
129
|
-
(@aws_credentials_expire_at && Fog::Time.now > @aws_credentials_expire_at -
|
136
|
+
(@aws_credentials_expire_at && Fog::Time.now > @aws_credentials_expire_at - credentials_refresh_threshold)) #new credentials become available from around 5 minutes before expiration time
|
130
137
|
end
|
131
138
|
|
132
139
|
def refresh_credentials
|
@@ -11,6 +11,7 @@ module Fog
|
|
11
11
|
load(data)
|
12
12
|
end
|
13
13
|
|
14
|
+
# Warning! This retrieves and caches meta data for the first 10,000 objects in the bucket, which can be very expensive. When possible use directories.new
|
14
15
|
def get(key, options = {})
|
15
16
|
remap_attributes(options, {
|
16
17
|
:delimiter => 'delimiter',
|
@@ -12,28 +12,30 @@ module Fog
|
|
12
12
|
# * body<~Hash>:
|
13
13
|
def add_tags_to_resource(rds_id, tags)
|
14
14
|
keys = tags.keys.sort
|
15
|
-
values = keys.map {|key| tags[key]}
|
15
|
+
values = keys.map { |key| tags[key] }
|
16
|
+
resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}"
|
17
|
+
%w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name
|
16
18
|
request({
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
|
19
|
+
'Action' => 'AddTagsToResource',
|
20
|
+
'ResourceName' => resource_name,
|
21
|
+
:parser => Fog::Parsers::AWS::RDS::Base.new
|
22
|
+
}.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys))
|
23
|
+
.merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
class Mock
|
26
28
|
def add_tags_to_resource(rds_id, tags)
|
27
29
|
response = Excon::Response.new
|
28
|
-
if server =
|
29
|
-
|
30
|
+
if server = data[:servers][rds_id]
|
31
|
+
data[:tags][rds_id].merge! tags
|
30
32
|
response.status = 200
|
31
33
|
response.body = {
|
32
|
-
|
34
|
+
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
|
33
35
|
}
|
34
36
|
response
|
35
37
|
else
|
36
|
-
raise Fog::AWS::RDS::NotFound
|
38
|
+
raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found"
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -11,11 +11,14 @@ module Fog
|
|
11
11
|
# ==== Returns
|
12
12
|
# * response<~Excon::Response>:
|
13
13
|
# * body<~Hash>:
|
14
|
+
|
14
15
|
def list_tags_for_resource(rds_id)
|
16
|
+
resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}"
|
17
|
+
%w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name
|
15
18
|
request(
|
16
|
-
'Action'
|
17
|
-
'ResourceName'
|
18
|
-
:parser
|
19
|
+
'Action' => 'ListTagsForResource',
|
20
|
+
'ResourceName' => resource_name,
|
21
|
+
:parser => Fog::Parsers::AWS::RDS::TagListParser.new
|
19
22
|
)
|
20
23
|
end
|
21
24
|
end
|
@@ -23,15 +26,15 @@ module Fog
|
|
23
26
|
class Mock
|
24
27
|
def list_tags_for_resource(rds_id)
|
25
28
|
response = Excon::Response.new
|
26
|
-
if server =
|
29
|
+
if server = data[:servers][rds_id]
|
27
30
|
response.status = 200
|
28
31
|
response.body = {
|
29
|
-
|
30
|
-
{
|
32
|
+
'ListTagsForResourceResult' =>
|
33
|
+
{ 'TagList' => data[:tags][rds_id] }
|
31
34
|
}
|
32
35
|
response
|
33
36
|
else
|
34
|
-
raise Fog::AWS::RDS::NotFound
|
37
|
+
raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found"
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
@@ -11,11 +11,12 @@ module Fog
|
|
11
11
|
# * response<~Excon::Response>:
|
12
12
|
# * body<~Hash>:
|
13
13
|
def remove_tags_from_resource(rds_id, keys)
|
14
|
+
resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}"
|
15
|
+
%w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name
|
14
16
|
request(
|
15
|
-
{ 'Action'
|
16
|
-
'ResourceName'
|
17
|
-
:parser
|
18
|
-
}.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys))
|
17
|
+
{ 'Action' => 'RemoveTagsFromResource',
|
18
|
+
'ResourceName' => resource_name,
|
19
|
+
:parser => Fog::Parsers::AWS::RDS::Base.new }.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys))
|
19
20
|
)
|
20
21
|
end
|
21
22
|
end
|
@@ -23,15 +24,15 @@ module Fog
|
|
23
24
|
class Mock
|
24
25
|
def remove_tags_from_resource(rds_id, keys)
|
25
26
|
response = Excon::Response.new
|
26
|
-
if server =
|
27
|
-
keys.each {|key|
|
27
|
+
if server = data[:servers][rds_id]
|
28
|
+
keys.each { |key| data[:tags][rds_id].delete key }
|
28
29
|
response.status = 200
|
29
30
|
response.body = {
|
30
|
-
|
31
|
+
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
|
31
32
|
}
|
32
33
|
response
|
33
34
|
else
|
34
|
-
raise Fog::AWS::RDS::NotFound
|
35
|
+
raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found"
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -46,7 +46,7 @@ module Fog
|
|
46
46
|
]
|
47
47
|
|
48
48
|
requires :aws_access_key_id, :aws_secret_access_key
|
49
|
-
recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :enable_signature_v4_streaming, :virtual_host, :cname, :max_put_chunk_size, :max_copy_chunk_size
|
49
|
+
recognizes :endpoint, :region, :host, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style, :acceleration, :instrumentor, :instrumentor_name, :aws_signature_version, :enable_signature_v4_streaming, :virtual_host, :cname, :max_put_chunk_size, :max_copy_chunk_size, :aws_credentials_refresh_threshold_seconds
|
50
50
|
|
51
51
|
secrets :aws_secret_access_key, :hmac
|
52
52
|
|
@@ -500,6 +500,8 @@ module Fog
|
|
500
500
|
end
|
501
501
|
|
502
502
|
def setup_credentials(options)
|
503
|
+
@aws_credentials_refresh_threshold_seconds = options[:aws_credentials_refresh_threshold_seconds]
|
504
|
+
|
503
505
|
@aws_access_key_id = options[:aws_access_key_id]
|
504
506
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
505
507
|
@aws_session_token = options[:aws_session_token]
|
@@ -577,6 +579,8 @@ module Fog
|
|
577
579
|
|
578
580
|
|
579
581
|
def setup_credentials(options)
|
582
|
+
@aws_credentials_refresh_threshold_seconds = options[:aws_credentials_refresh_threshold_seconds]
|
583
|
+
|
580
584
|
@aws_access_key_id = options[:aws_access_key_id]
|
581
585
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
582
586
|
@aws_session_token = options[:aws_session_token]
|
data/lib/fog/aws/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|