https://github.com/fog/fog-aws
Module for the 'fog' gem to support Amazon Web Services http://aws.amazon.com/
https://github.com/fog/fog-aws
Keywords from Contributors
activerecord rubygems rack activejob mvc crash-reporting rspec sinatra ruby-gem rubocop
Last synced: about 22 hours ago
JSON representation
Repository metadata
Module for the 'fog' gem to support Amazon Web Services http://aws.amazon.com/
- Host: GitHub
- URL: https://github.com/fog/fog-aws
- Owner: fog
- License: mit
- Created: 2014-12-30T20:04:47.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-11-24T14:00:08.000Z (18 days ago)
- Last Synced: 2025-11-27T10:53:27.848Z (15 days ago)
- Language: Ruby
- Homepage:
- Size: 15.2 MB
- Stars: 305
- Watchers: 9
- Forks: 354
- Open Issues: 15
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: SECURITY.md
README.md
Fog::Aws
Installation
Add this line to your application's Gemfile:
gem 'fog-aws'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fog-aws
Usage
Before you can use fog-aws, you must require it in your application:
require 'fog/aws'
Since it's a bad practice to have your credentials in source code, you should load them from default fog configuration file: ~/.fog. This file could look like this:
default:
aws_access_key_id: <YOUR_ACCESS_KEY_ID>
aws_secret_access_key: <YOUR_SECRET_ACCESS_KEY>
EC2
Connecting to the EC2 Service:
ec2 = Fog::Compute.new :provider => 'AWS', :region => 'us-west-2'
You can review all the requests available with this service using #requests method:
ec2.requests # => [:allocate_address, :assign_private_ip_addresses, :associate_address, ...]
Launch an EC2 on-demand instance:
response = ec2.run_instances(
"ami-23ebb513",
1,
1,
"InstanceType" => "t1.micro",
"SecurityGroup" => "ssh",
"KeyName" => "miguel"
)
instance_id = response.body["instancesSet"].first["instanceId"] # => "i-02db5af4"
instance = ec2.servers.get(instance_id)
instance.wait_for { ready? }
puts instance.public_ip_address # => "356.300.501.20"
Terminate an EC2 instance:
instance = ec2.servers.get("i-02db5af4")
instance.destroy
Fog::AWS is more than EC2 since it supports many services provided by AWS. The best way to learn and to know about how many services are supported is to take a look at the source code. To review the tests directory and to play with the library in bin/console can be very helpful resources as well.
S3
Connecting to the S3 Service:
s3 = Fog::Storage.new(provider: 'AWS', region: 'eu-central-1')
Creating a file:
directory = s3.directories.new(key: 'gaudi-portal-dev')
file = directory.files.create(key: 'user/1/Gemfile', body: File.open('Gemfile'), tags: 'Org-Id=1&Service-Name=My-Service')
Listing files:
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
directory.files
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.
Generating a URL for a file:
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
Generate download URL
You should pass an option argument that contains the query key with response-content-disposition inside indicating that is an attachment and the filename to be used when downloaded.
options = {
query: {
'response-content-disposition' => "attachment; filename=#{key}"
}
}
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60, options)
Controlling credential refresh time with IAM authentication
When using IAM authentication with
temporary security credentials,
generated S3 pre-signed URLs
only last as long as the temporary credential.
Generating the URLs in the following manner will return a URL
that will not last as long as its requested expiration time if
the remainder of the authentication token lifetime was shorter.
s3 = Fog::Storage.new(provider: 'AWS', use_iam_profile: true)
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
By default the temporary credentials in use are refreshed only within the last
15 seconds of its expiration time. The URL requested with 60 seconds lifetime
using the above example will only remain valid for 15 seconds in the worst case.
The problem can be avoided by refreshing the token early and often,
by setting configuration aws_credentials_refresh_threshold_seconds (default: 15)
which controls the time when the refresh must occur. It is expressed in seconds
before the temporary credential's expiration time.
The following example can ensure pre-signed URLs last as long as 60 seconds
by automatically refreshing the credentials when its remainder lifetime
is lower than 60 seconds:
s3 = Fog::Storage.new(
provider: 'AWS',
use_iam_profile: true,
aws_credentials_refresh_threshold_seconds: 60
)
directory = s3.directories.get('gaudi-portal-dev', prefix: 'user/1/')
directory.files.new(key: 'user/1/Gemfile').url(Time.now + 60)
Copying a file
directory = s3.directories.new(key: 'gaudi-portal-dev')
file = directory.files.get('user/1/Gemfile')
file.copy("target-bucket", "user/2/Gemfile.copy")
To speed transfers of large files, the concurrency option can be used
to spawn multiple threads. Note that the file must be at least 5 MB for
multipart uploads to work. For example:
directory = s3.directories.new(key: 'gaudi-portal-dev')
file = directory.files.get('user/1/Gemfile')
file.multipart_chunk_size = 10 * 1024 * 1024
file.concurrency = 10
file.copy("target-bucket", "user/2/Gemfile.copy")
Documentation
See the online documentation for a complete API reference.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
Contributing
- Fork it ( https://github.com/fog/fog-aws/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Owner metadata
- Name: fog
- Login: fog
- Email:
- Kind: organization
- Description:
- Website: http://fog.io
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/991149?v=4
- Repositories: 61
- Last ynced at: 2023-04-10T00:16:30.104Z
- Profile URL: https://github.com/fog
GitHub Events
Total
- Issues event: 16
- Watch event: 5
- Delete event: 6
- Issue comment event: 34
- Push event: 33
- Pull request review event: 19
- Pull request review comment event: 12
- Pull request event: 26
- Fork event: 5
- Create event: 12
Last Year
- Issues event: 14
- Watch event: 3
- Delete event: 5
- Issue comment event: 28
- Push event: 29
- Pull request review comment event: 11
- Pull request review event: 17
- Pull request event: 22
- Fork event: 4
- Create event: 10
Committers metadata
Last synced: 8 days ago
Total Commits: 926
Total Committers: 207
Avg Commits per committer: 4.473
Development Distribution Score (DDS): 0.816
Commits in past year: 19
Committers in past year: 4
Avg Commits per committer in past year: 4.75
Development Distribution Score (DDS) in past year: 0.526
| Name | Commits | |
|---|---|---|
| Joshua Lane | me@j****m | 170 |
| geemus | g****s@g****m | 103 |
| Eugene Howe | e****e@x****t | 56 |
| Michael Hale | m****e@h****s | 38 |
| sue445 | s****5@s****t | 37 |
| KevinLoiseau | k****d@g****m | 37 |
| dependabot[bot] | 4****] | 25 |
| Stan Hu | s****u@g****m | 24 |
| Frederick Cheung | f****g@g****m | 22 |
| Miguel Landaeta | m****l@m****c | 12 |
| Shai Rosenfeld | s****d@a****m | 10 |
| Chanakya Devraj | c****j@c****n | 9 |
| Michelle Noorali | m****u@g****m | 9 |
| David Vaz | d****z@g****m | 8 |
| Matthew O'Riordan | m****n@g****m | 7 |
| Paulo Ribeiro | p****0@g****m | 7 |
| Vic van Gool | v****c@c****m | 7 |
| Denis Diachkov | d****v@g****m | 6 |
| Jack Thomas | j****k@s****m | 6 |
| Todd Willey | x****x@g****m | 6 |
| Chanakya Devraj | c****j@g****m | 6 |
| Nilanjan Roy | n****y@n****m | 6 |
| solud | j****n@j****m | 5 |
| Michael Sawyer | m****r@v****m | 5 |
| Johann Fuechsl | j****n@f****o | 5 |
| Carlos Lima | c****s@c****g | 5 |
| Aaron Stone | a****n@s****x | 5 |
| Alexander Stuart-Kregor | e****y@m****m | 4 |
| Ash Tyndall | g****t@a****t | 4 |
| Brett Cave | b****t@c****t | 4 |
| and 177 more... | ||
Committer domains:
- gitlab.com: 3
- engineyard.com: 3
- backupify.com: 2
- heroku.com: 2
- emetriq.com: 2
- linkbynet.com: 2
- gemalto.com: 1
- thoughtmachine.net: 1
- rah.im: 1
- sugarcrm.com: 1
- yandex.ru: 1
- einnews.com: 1
- honeybeehealth.com: 1
- alces-software.com: 1
- galluzzo.me: 1
- 27crags.com: 1
- letz-it.lu: 1
- remind101.com: 1
- runtime-revolution.com: 1
- williamhill.co.uk: 1
- atmos.org: 1
- github.com: 1
- andrewsullivancant.ca: 1
- legitscript.com: 1
- lucianosousa.net: 1
- netguru.co: 1
- sam-media.com: 1
- developmentlogics.com: 1
- hales.ws: 1
- sue445.net: 1
- miguel.cc: 1
- autodesk.com: 1
- cuelogic.co.in: 1
- cloud66.com: 1
- scalefactory.com: 1
- nosto.com: 1
- joncole.com: 1
- veeva.com: 1
- fuechsl.co: 1
- cpan.org: 1
- serendipity.cx: 1
- me.com: 1
- atyndall.net: 1
- cave.za.net: 1
- bitsighttech.com: 1
- expressvpn.com: 1
- blake.com.au: 1
- immediate.co.uk: 1
- redhat.com: 1
- herot.com: 1
- jaredbeck.com: 1
- 42na.in: 1
- popsugar.com: 1
- xtreme-computers.net: 1
- joshualane.com: 1
- kohlvanwijngaarden.nl: 1
- beanstalk.ie: 1
- pivotal.io: 1
- red-bean.com: 1
- 10io.net: 1
- allstate.com: 1
- mague.com: 1
- edu.esiee.fr: 1
- labratrevenge.com: 1
- ayumiyu.com: 1
- alexcoomans.com: 1
- dio.jp: 1
- reese.io: 1
- uci.edu: 1
- ably.com: 1
- recordedfuture.com: 1
- slonopotamus.org: 1
- maicoin.com: 1
- zbla.net: 1
- knapo.net: 1
- aurea.com: 1
- ursm.jp: 1
- jonathan-hanson.org: 1
- meyouhealth.com: 1
- graavy.com: 1
- jansterba.com: 1
- gree.net: 1
- adobe.com: 1
- idrive.com: 1
- pobox.com: 1
- bahchis.com: 1
- oriontransfer.co.nz: 1
- ryanschlesinger.com: 1
- doxin.net: 1
- rodrigo-pereira.net: 1
- deheus.net: 1
- p373.net: 1
- instacart.com: 1
- nawaidshamim.com: 1
- johnandrewmarshall.com: 1
- saldan.it: 1
- mrloop.com: 1
- agilitypr.com: 1
- cern.ch: 1
- chef.io: 1
- sunfox.org: 1
- piksel.com: 1
- datapipe.com: 1
- academia.edu: 1
- seedrs.com: 1
- fronter.com.br: 1
- outpost24.com: 1
- schweetheart.jp: 1
Issue and Pull Request metadata
Last synced: 17 days ago
Total issues: 75
Total pull requests: 127
Average time to close issues: about 2 years
Average time to close pull requests: 5 days
Total issue authors: 56
Total pull request authors: 52
Average comments per issue: 3.87
Average comments per pull request: 1.31
Merged pull request: 108
Bot issues: 0
Bot pull requests: 28
Past year issues: 8
Past year pull requests: 21
Past year average time to close issues: 4 days
Past year average time to close pull requests: 3 days
Past year issue authors: 6
Past year pull request authors: 5
Past year average comments per issue: 1.13
Past year average comments per pull request: 0.48
Past year merged pull request: 17
Past year bot issues: 0
Past year bot pull requests: 10
Top Issue Authors
- plribeiro3000 (15)
- stanhu (3)
- matt-domsch-sp (2)
- Ankk98 (2)
- avoidik (2)
- ohookins (1)
- meraj-kashi (1)
- homerlex (1)
- kyletolle (1)
- jnnttlpcktw (1)
- babatakao (1)
- awongh (1)
- nekomaho (1)
- pravi (1)
- acatighera (1)
Top Pull Request Authors
- dependabot[bot] (28)
- geemus (13)
- stanhu (11)
- chaadow (4)
- Ankk98 (4)
- naveensrinivasan (3)
- orrin-naylor-instacart (3)
- gopalcoupa (3)
- y-yagi (3)
- rahim (2)
- y-sugawara-acs (2)
- m-nakamura145 (2)
- mark-young-atg (2)
- kitherill (2)
- kianmeng (2)
Top Issue Labels
- no-issue-activity (31)
- pinned (5)
Top Pull Request Labels
- dependencies (28)
- github_actions (23)
- ruby (5)
- no-pr-activity (4)
Package metadata
- Total packages: 2
-
Total downloads:
- rubygems: 326,890,059 total
- Total docker downloads: 939,043,096
- Total dependent packages: 116 (may contain duplicates)
- Total dependent repositories: 19,440 (may contain duplicates)
- Total versions: 164
- Total maintainers: 2
gem.coop: fog-aws
This library can be used as a module for `fog` or as standalone provider to use the Amazon Web Services in applications..
- Homepage: https://github.com/fog/fog-aws
- Documentation: http://www.rubydoc.info/gems/fog-aws/
- Licenses: MIT
- Latest release: 3.33.1 (published about 1 month ago)
- Last Synced: 2025-12-07T11:52:59.920Z (5 days ago)
- Versions: 82
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 163,449,919 Total
- Docker Downloads: 469,521,548
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.093%
- Downloads: 0.151%
- Docker downloads count: 0.221%
- Maintainers (2)
rubygems.org: fog-aws
This library can be used as a module for `fog` or as standalone provider to use the Amazon Web Services in applications..
- Homepage: https://github.com/fog/fog-aws
- Documentation: http://www.rubydoc.info/gems/fog-aws/
- Licenses: MIT
- Latest release: 3.33.1 (published about 1 month ago)
- Last Synced: 2025-12-06T14:31:59.004Z (6 days ago)
- Versions: 82
- Dependent Packages: 116
- Dependent Repositories: 19,440
- Downloads: 163,440,140 Total
- Docker Downloads: 469,521,548
-
Rankings:
- Downloads: 0.137%
- Dependent repos count: 0.259%
- Docker downloads count: 0.273%
- Dependent packages count: 0.292%
- Average: 0.946%
- Forks count: 1.451%
- Stargazers count: 3.265%
- Maintainers (2)
Dependencies
- actions/checkout v3 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/autobuild v2 composite
- github/codeql-action/init v2 composite
- actions/checkout v3 composite
- actions/dependency-review-action v3 composite
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
- actions/stale v6 composite
- codeclimate-test-reporter ~> 1.0.0 development
- simplecov >= 0 development
- mime-types ~> 3.1
- pry-nav >= 0
- bundler >= 0 development
- github_changelog_generator ~> 1.16 development
- rake >= 12.3.3 development
- rubyzip ~> 2.3.0 development
- shindo ~> 0.3 development
- fog-core ~> 2.1
- fog-json ~> 1.1
- fog-xml ~> 0.1
Score: 32.06013113783356