Region.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/core/utils/memory/stl/AWSString.h>
  6. #include <aws/core/Region.h>
  7. namespace Aws
  8. {
  9. namespace Region
  10. {
  11. Aws::String ComputeSignerRegion(const Aws::String& region)
  12. {
  13. if (region == Aws::Region::AWS_GLOBAL)
  14. {
  15. return Aws::Region::US_EAST_1;
  16. }
  17. else if (region == "fips-aws-global")
  18. {
  19. return Aws::Region::US_EAST_1;
  20. }
  21. else if (region == "s3-external-1")
  22. {
  23. return Aws::Region::US_EAST_1;
  24. }
  25. else if (region.size() >= 5 && region.compare(0, 5, "fips-") == 0)
  26. {
  27. return region.substr(5);
  28. }
  29. else if (region.size() >= 5 && region.compare(region.size() - 5, 5, "-fips") == 0)
  30. {
  31. return region.substr(0, region.size() - 5);
  32. }
  33. else
  34. {
  35. return region;
  36. }
  37. }
  38. bool IsFipsRegion(const Aws::String& region)
  39. {
  40. if (region.size() >= 5 && region.compare(0, 5, "fips-") == 0)
  41. {
  42. return true;
  43. }
  44. else if (region.size() >= 5 && region.compare(region.size() - 5, 5, "-fips") == 0)
  45. {
  46. return true;
  47. }
  48. return false;
  49. }
  50. }
  51. }