Skip to content

Add constructor with s3Client factory to s3-encryption #3392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

sbiscigl
Copy link
Contributor

@sbiscigl sbiscigl commented Apr 24, 2025

Issue #, if available:

#3388

Description of changes:

Right now it is impossible for customers to create a S3 encryption client using a S3ClientConfiguration object. Instead of adding more constructors to match each S3Client constructor, add factory method so user can bring their own S3Client. i.e.

#include <aws/core/Aws.h>
#include <aws/s3-encryption/S3EncryptionClient.h>

using namespace Aws;
using namespace Aws::S3Encryption;
using namespace Aws::S3;
using namespace Aws::Utils;

namespace {
const char* LOG_TAG = "test-app";
}

auto main() -> int {
  SDKOptions options{};
  options.loggingOptions.logLevel = Logging::LogLevel::Debug;
  InitAPI(options);
  {
    CryptoBuffer symmetric_key{ByteBuffer{"symmetric_key"}};
    const auto simple_materials =
        Aws::MakeShared<Materials::SimpleEncryptionMaterialsWithGCMAAD>(
            LOG_TAG, symmetric_key);
    CryptoConfigurationV2 configuration_v2{simple_materials};
    S3ClientConfiguration client_configuration{};
    client_configuration.useVirtualAddressing = true;
    S3EncryptionClientV2 client_v2{
        configuration_v2, [&client_configuration]() -> UniquePtr<S3Client> {
          return Aws::MakeUnique<S3Client>(LOG_TAG, client_configuration);
        }};
  }
  ShutdownAPI(options);
  return 0;
}

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sbiscigl sbiscigl force-pushed the cyrpto-client-s3client-factory branch from 0c493ee to cfcb51d Compare April 24, 2025 15:08
@sbiscigl sbiscigl force-pushed the cyrpto-client-s3client-factory branch from cfcb51d to ae894d8 Compare April 24, 2025 15:12
@sbiscigl sbiscigl marked this pull request as ready for review April 24, 2025 16:54
@sbiscigl sbiscigl merged commit e9e0a91 into main Apr 24, 2025
3 of 4 checks passed
@sbiscigl sbiscigl deleted the cyrpto-client-s3client-factory branch April 24, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants