S3ClientConfiguration.cpp 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/s3/S3ClientConfiguration.h>
  6. namespace Aws
  7. {
  8. namespace S3
  9. {
  10. static const char US_EAST_1_REGIONAL_ENDPOINT_ENV_VAR[] = "AWS_S3_US_EAST_1_REGIONAL_ENDPOINT";
  11. static const char US_EAST_1_REGIONAL_ENDPOINT_CONFIG_VAR[] = "s3_us_east_1_regional_endpoint";
  12. static const char S3_DISABLE_MULTIREGION_ACCESS_POINTS_ENV_VAR[] = "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS";
  13. static const char S3_DISABLE_MULTIREGION_ACCESS_POINTS_CONFIG_VAR[] = "s3_disable_multiregion_access_points";
  14. static const char S3_USE_ARN_REGION_ENVIRONMENT_VARIABLE[] = "AWS_S3_USE_ARN_REGION";
  15. static const char S3_USE_ARN_REGION_CONFIG_FILE_OPTION[] = "s3_use_arn_region";
  16. void S3ClientConfiguration::LoadS3SpecificConfig(const Aws::String& inputProfileName)
  17. {
  18. if (Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION::NOT_SET == this->useUSEast1RegionalEndPointOption)
  19. {
  20. const Aws::String& useUSEastOption =
  21. BaseClientConfigClass::LoadConfigFromEnvOrProfile(US_EAST_1_REGIONAL_ENDPOINT_ENV_VAR,
  22. inputProfileName,
  23. US_EAST_1_REGIONAL_ENDPOINT_CONFIG_VAR,
  24. {"legacy", "regional"},
  25. "regional");
  26. if (useUSEastOption == "legacy") {
  27. this->useUSEast1RegionalEndPointOption = Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY;
  28. } else {
  29. this->useUSEast1RegionalEndPointOption = Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION::REGIONAL;
  30. }
  31. }
  32. Aws::String s3DisableMultiRegionAccessPoints = ClientConfiguration::LoadConfigFromEnvOrProfile(S3_DISABLE_MULTIREGION_ACCESS_POINTS_ENV_VAR,
  33. inputProfileName,
  34. S3_DISABLE_MULTIREGION_ACCESS_POINTS_CONFIG_VAR,
  35. {"true", "false"},
  36. "false");
  37. if (s3DisableMultiRegionAccessPoints == "true")
  38. {
  39. disableMultiRegionAccessPoints = true;
  40. }
  41. Aws::String useArnRegionCfg = ClientConfiguration::LoadConfigFromEnvOrProfile(S3_USE_ARN_REGION_ENVIRONMENT_VARIABLE,
  42. inputProfileName,
  43. S3_USE_ARN_REGION_CONFIG_FILE_OPTION,
  44. {"true", "false"},
  45. "false");
  46. if (useArnRegionCfg == "true")
  47. {
  48. useArnRegion = true;
  49. }
  50. }
  51. S3ClientConfiguration::S3ClientConfiguration()
  52. : BaseClientConfigClass()
  53. {
  54. LoadS3SpecificConfig(this->profileName);
  55. }
  56. S3ClientConfiguration::S3ClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS)
  57. : BaseClientConfigClass(inputProfileName, shouldDisableIMDS)
  58. {
  59. LoadS3SpecificConfig(Aws::String(inputProfileName));
  60. }
  61. S3ClientConfiguration::S3ClientConfiguration(bool useSmartDefaults, const char* defaultMode, bool shouldDisableIMDS)
  62. : BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS)
  63. {
  64. LoadS3SpecificConfig(this->profileName);
  65. }
  66. S3ClientConfiguration::S3ClientConfiguration(const Client::ClientConfiguration& config,
  67. Client::AWSAuthV4Signer::PayloadSigningPolicy iPayloadSigningPolicy,
  68. bool iUseVirtualAddressing,
  69. US_EAST_1_REGIONAL_ENDPOINT_OPTION iUseUSEast1RegionalEndPointOption)
  70. : BaseClientConfigClass(config),
  71. useVirtualAddressing(iUseVirtualAddressing),
  72. useUSEast1RegionalEndPointOption(iUseUSEast1RegionalEndPointOption),
  73. payloadSigningPolicy(iPayloadSigningPolicy)
  74. {
  75. LoadS3SpecificConfig(this->profileName);
  76. }
  77. } // namespace S3
  78. } // namespace Aws