|
| 1 | +# Amazon S3 Encryption Client for Ruby V3 |
| 2 | + |
| 3 | +This library provides an S3 client that supports client-side encryption. |
| 4 | +`Aws::S3::EncryptionV3::Client` is the v3 of the Amazon S3 Encryption Client for the Ruby programming language. |
| 5 | + |
| 6 | +The v3 encryption client requires a minimum version of **Ruby >= 2.5**. |
| 7 | + |
| 8 | +Jump To: |
| 9 | + |
| 10 | +* [Getting Started](#getting-started) |
| 11 | +* [Migration](#migration) |
| 12 | + |
| 13 | +## Maintenance and support for SDK major versions |
| 14 | + |
| 15 | +For information about maintenance and support for SDK major versions and their underlying dependencies, see the |
| 16 | +following in the AWS SDKs and Tools Shared Configuration and Credentials Reference Guide: |
| 17 | + |
| 18 | +* [AWS SDKs and Tools Maintenance Policy](https://docs.aws.amazon.com/credref/latest/refdocs/maint-policy.html) |
| 19 | +* [AWS SDKs and Tools Version Support Matrix](https://docs.aws.amazon.com/credref/latest/refdocs/version-support-matrix.html) |
| 20 | + |
| 21 | +### Ruby version support policy |
| 22 | + |
| 23 | +The v3 Encryption Client follows the upstream Ruby [maintenance policy](https://www.ruby-lang.org/en/downloads/branches/) |
| 24 | +with an additional six months of support for the most recently deprecated |
| 25 | +language version. |
| 26 | + |
| 27 | +**AWS reserves the right to drop support for unsupported Ruby versions earlier to |
| 28 | +address critical security issues.** |
| 29 | + |
| 30 | +## Getting Started |
| 31 | + |
| 32 | +1. **Sign up for AWS** – Before you begin, you need to |
| 33 | + sign up for an AWS account and retrieve your [AWS credentials][docs-signup]. |
| 34 | +2. **Minimum requirements** – To run the SDK, your system will need to meet the |
| 35 | + [minimum requirements][docs-requirements], including having **Ruby >= 2.5**. |
| 36 | +3. **Install the SDK** – Using [Bundler][bundler] is the recommended way to install the |
| 37 | + AWS SDK for Ruby. The SDK is available via [RubyGems][rubygems] under the |
| 38 | + [`aws-sdk-s3`][install-rubygems] gem. If Bundler is installed on your system, you can add the following to your Gemfile: |
| 39 | + |
| 40 | + ```bash |
| 41 | + gem 'aws-sdk-s3' |
| 42 | + ``` |
| 43 | + |
| 44 | + Or install the gem directly: |
| 45 | + |
| 46 | + ```bash |
| 47 | + gem install aws-sdk-s3 |
| 48 | + ``` |
| 49 | + |
| 50 | + Please see the |
| 51 | + [Installation section of the Developer Guide][docs-installation] for more |
| 52 | + detailed information about installing the SDK. |
| 53 | +4. **Using the SDK** – The best way to become familiar with how to use the SDK |
| 54 | + is to read the [Developer Guide][docs-guide]. The |
| 55 | + [Getting Started Guide][docs-quickstart] will help you become familiar with |
| 56 | + the basic concepts. |
| 57 | + |
| 58 | +## Quick Examples |
| 59 | + |
| 60 | +### Create an Amazon S3 Encryption Client |
| 61 | + |
| 62 | +```ruby |
| 63 | +require 'aws-sdk-s3' |
| 64 | + |
| 65 | +# Instantiate an Amazon S3 client. |
| 66 | +s3_client = Aws::S3::Client.new( |
| 67 | + region: 'us-west-2' |
| 68 | +) |
| 69 | + |
| 70 | +# Instantiate an Amazon S3 Encryption Client V3. |
| 71 | +client = Aws::S3::EncryptionV3::Client.new( |
| 72 | + client: s3_client, |
| 73 | + encryption_key: encryption_key, |
| 74 | + key_wrap_schema: :aes_gcm |
| 75 | +) |
| 76 | +``` |
| 77 | + |
| 78 | +### Upload a file to Amazon S3 using client side encryption |
| 79 | + |
| 80 | +```ruby |
| 81 | +require 'aws-sdk-s3' |
| 82 | +require 'aws-sdk-kms' |
| 83 | + |
| 84 | +# Create a KMS client |
| 85 | +kms_client = Aws::KMS::Client.new( |
| 86 | + region: 'us-east-1' |
| 87 | +) |
| 88 | + |
| 89 | +# Specify your KMS key ID |
| 90 | +kms_key_id = 'your-kms-key-id' |
| 91 | + |
| 92 | +# Create the encryption client |
| 93 | +client = Aws::S3::EncryptionV3::Client.new( |
| 94 | + kms_key_id: kms_key_id, |
| 95 | + kms_client: kms_client, |
| 96 | + key_wrap_schema: :kms_context |
| 97 | +) |
| 98 | + |
| 99 | +# Upload an encrypted object |
| 100 | +bucket = 'the-bucket-name' |
| 101 | +key = 'the-file-name' |
| 102 | + |
| 103 | +result = client.put_object( |
| 104 | + bucket: bucket, |
| 105 | + key: key, |
| 106 | + body: File.open('file-to-encrypt.txt', 'r'), |
| 107 | + kms_encryption_context: { 'context-key' => 'context-value' } |
| 108 | +) |
| 109 | +``` |
| 110 | + |
| 111 | +## Migration |
| 112 | + |
| 113 | +This version of the library supports reading encrypted objects from previous versions with extra configuration. |
| 114 | +It also supports writing objects with non-legacy algorithms. |
| 115 | +The list of legacy modes and operations will be provided below. |
| 116 | + |
| 117 | +* [2.x to 3.x Migration Guide](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/s3-encryption-migration-v2-v3.html) |
| 118 | +* [1.x to 2.x Migration Guide](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/s3-encryption-migration-v1-v2.html) |
| 119 | + |
| 120 | +## Security |
| 121 | + |
| 122 | +See [CONTRIBUTING](../../../CONTRIBUTING.md#security-issue-notifications) for more information. |
| 123 | + |
| 124 | +## License |
| 125 | + |
| 126 | +This project is licensed under the Apache-2.0 License. |
| 127 | + |
| 128 | +[docs-signup]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html |
| 129 | +[docs-requirements]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-install.html |
| 130 | +[docs-installation]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-install.html |
| 131 | +[docs-guide]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/welcome.html |
| 132 | +[docs-quickstart]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/getting-started.html |
| 133 | +[bundler]: https://bundler.io/ |
| 134 | +[rubygems]: https://rubygems.org/ |
| 135 | +[install-rubygems]: https://rubygems.org/gems/aws-sdk-s3 |
0 commit comments