diff --git a/.doc_gen/metadata/dynamodb_metadata.yaml b/.doc_gen/metadata/dynamodb_metadata.yaml index 15eb296d16c..b5a18e5ffac 100644 --- a/.doc_gen/metadata/dynamodb_metadata.yaml +++ b/.doc_gen/metadata/dynamodb_metadata.yaml @@ -81,6 +81,10 @@ dynamodb_CreateTable: - description: snippet_tags: - dynamodb.cpp.create_table.code + - description: Code that waits for the table to become active. + snippet_tags: + - cpp.example_code.dynamodb.scenario.waitTableActive + Go: versions: - sdk_version: 2 @@ -623,11 +627,13 @@ dynamodb_PutItem: versions: - sdk_version: 1 github: cpp/example_code/dynamodb - sdkguide: excerpts: - description: snippet_tags: - dynamodb.cpp.put_item.code + - description: Code that waits for the table to become active. + snippet_tags: + - cpp.example_code.dynamodb.scenario.waitTableActive Go: versions: - sdk_version: 2 @@ -890,6 +896,9 @@ dynamodb_UpdateItem: - description: snippet_tags: - dynamodb.cpp.update_item.code + - description: Code that waits for the table to become active. + snippet_tags: + - cpp.example_code.dynamodb.scenario.waitTableActive Go: versions: - sdk_version: 2 @@ -1109,11 +1118,13 @@ dynamodb_DeleteItem: versions: - sdk_version: 1 github: cpp/example_code/dynamodb - sdkguide: excerpts: - description: snippet_tags: - cpp.example_code.dynamodb.delete_item + - description: Code that waits for the table to become active. + snippet_tags: + - cpp.example_code.dynamodb.scenario.waitTableActive Swift: versions: - sdk_version: 1 @@ -1774,6 +1785,21 @@ dynamodb_BatchExecuteStatement: - cpp.example_code.dynamodb.BatchExecuteStatement.Delete services: dynamodb: {BatchExecuteStatement} +dynamodb_UpdateTable: + languages: + C++: + versions: + - sdk_version: 1 + github: cpp/example_code/dynamodb + excerpts: + - description: + snippet_tags: + - dynamodb.cpp.update_table.code + - description: Code that waits for the table to become active. + snippet_tags: + - cpp.example_code.dynamodb.scenario.waitTableActive + services: + dynamodb: {UpdateTable} dynamodb_Usage_DaxDemo: title: Accelerate &DDB; reads with &DAX; using an &AWS; SDK title_abbrev: Accelerate reads with &DAX; diff --git a/aws-cli/bash-linux/s3/s3_getting_started.sh b/aws-cli/bash-linux/s3/s3_getting_started.sh index b83a565ac58..c660a11e285 100755 --- a/aws-cli/bash-linux/s3/s3_getting_started.sh +++ b/aws-cli/bash-linux/s3/s3_getting_started.sh @@ -50,9 +50,12 @@ function s3_getting_started() { echo_repeat "*" 88 echo "Welcome to the Amazon S3 getting started demo." echo_repeat "*" 88 - + echo "A unique bucket will be created by appending a Universally Unique Identifier to a bucket name prefix." + echo -n "Enter a prefix for the S3 bucket that will be used in this demo: " + get_input + bucket_name_prefix=$get_input_result local bucket_name - bucket_name=$(generate_random_name "amzn-s3-demo-bucket") + bucket_name=$(generate_random_name "$bucket_name_prefix") local region_code region_code=$(aws configure get region) diff --git a/cpp/example_code/dynamodb/README.md b/cpp/example_code/dynamodb/README.md index fd3af6b6758..4e6ab890d81 100644 --- a/cpp/example_code/dynamodb/README.md +++ b/cpp/example_code/dynamodb/README.md @@ -67,6 +67,7 @@ Code excerpts that show you how to call individual service functions. - [Query](query_items.cpp#L22) - [Scan](scan_table.cpp#L23) - [UpdateItem](update_item.cpp#L24) +- [UpdateTable](update_table.cpp#L33) ### Scenarios diff --git a/cpp/example_code/dynamodb/batch_write_item.cpp b/cpp/example_code/dynamodb/batch_write_item.cpp index fc04482dcfb..ab0b5127ee5 100644 --- a/cpp/example_code/dynamodb/batch_write_item.cpp +++ b/cpp/example_code/dynamodb/batch_write_item.cpp @@ -115,9 +115,10 @@ bool AwsDoc::DynamoDB::batchWriteItem(const Aws::String &jsonFilePath, std::cerr << "Error with DynamoDB::BatchWriteItem. " << outcome.GetError().GetMessage() << std::endl; + return false; } - return true; + return outcome.IsSuccess(); } //! Convert requests in JSON format to a vector of WriteRequest objects. diff --git a/cpp/example_code/dynamodb/create_table.cpp b/cpp/example_code/dynamodb/create_table.cpp index 476bee96bf9..1c36db82ac8 100644 --- a/cpp/example_code/dynamodb/create_table.cpp +++ b/cpp/example_code/dynamodb/create_table.cpp @@ -68,9 +68,10 @@ bool AwsDoc::DynamoDB::createTable(const Aws::String &tableName, else { std::cerr << "Failed to create table: " << outcome.GetError().GetMessage() << std::endl; + return false; } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[dynamodb.cpp.create_table.code] diff --git a/cpp/example_code/dynamodb/create_table_composite_key.cpp b/cpp/example_code/dynamodb/create_table_composite_key.cpp index 0eac52ae837..ec5d6def657 100644 --- a/cpp/example_code/dynamodb/create_table_composite_key.cpp +++ b/cpp/example_code/dynamodb/create_table_composite_key.cpp @@ -79,9 +79,10 @@ bool AwsDoc::DynamoDB::createTableWithCompositeKey(const Aws::String &tableName, else { std::cerr << "Failed to create table:" << outcome.GetError().GetMessage() << std::endl; + return false; } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[dynamodb.cpp.create_table_composite_key.code] diff --git a/cpp/example_code/dynamodb/delete_item.cpp b/cpp/example_code/dynamodb/delete_item.cpp index b5183647ea1..3240db28b11 100644 --- a/cpp/example_code/dynamodb/delete_item.cpp +++ b/cpp/example_code/dynamodb/delete_item.cpp @@ -50,9 +50,10 @@ bool AwsDoc::DynamoDB::deleteItem(const Aws::String &tableName, else { std::cerr << "Failed to delete item: " << outcome.GetError().GetMessage() << std::endl; + return false; } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[cpp.example_code.dynamodb.delete_item] diff --git a/cpp/example_code/dynamodb/dynamodb_samples.h b/cpp/example_code/dynamodb/dynamodb_samples.h index 320cb65ce8b..54bde881108 100644 --- a/cpp/example_code/dynamodb/dynamodb_samples.h +++ b/cpp/example_code/dynamodb/dynamodb_samples.h @@ -6,6 +6,7 @@ #include #include +#include namespace AwsDoc { namespace DynamoDB { @@ -262,11 +263,11 @@ namespace AwsDoc { /*! \sa waitTableActive() \param waitTableActive: The DynamoDB table's name. - \param clientConfiguration: AWS client configuration. + \param dynamoClient: A DynamoDB client. \return bool: Function succeeded. */ bool waitTableActive(const Aws::String &tableName, - const Aws::Client::ClientConfiguration &clientConfiguration); + const Aws::DynamoDB::DynamoDBClient &dynamoClient); //! Command line prompt/response utility function. /*! \\sa askQuestion() diff --git a/cpp/example_code/dynamodb/dynamodb_utils.cpp b/cpp/example_code/dynamodb/dynamodb_utils.cpp index f2ac29927c7..b1135aacf7f 100644 --- a/cpp/example_code/dynamodb/dynamodb_utils.cpp +++ b/cpp/example_code/dynamodb/dynamodb_utils.cpp @@ -146,12 +146,12 @@ bool AwsDoc::DynamoDB::deleteMoviesDynamoDBTable( /*! \sa waitTableActive() \param waitTableActive: The DynamoDB table's name. - \param clientConfiguration: AWS client configuration. + \param dynamoClient: A DynamoDB client. \return bool: Function succeeded. */ bool AwsDoc::DynamoDB::waitTableActive(const Aws::String &tableName, - const Aws::Client::ClientConfiguration &clientConfiguration) { - Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration); + const Aws::DynamoDB::DynamoDBClient &dynamoClient) { + // Repeatedly call DescribeTable until table is ACTIVE. const int MAX_QUERIES = 20; Aws::DynamoDB::Model::DescribeTableRequest request; diff --git a/cpp/example_code/dynamodb/put_item.cpp b/cpp/example_code/dynamodb/put_item.cpp index e9ffe1245f3..295d1979cb2 100644 --- a/cpp/example_code/dynamodb/put_item.cpp +++ b/cpp/example_code/dynamodb/put_item.cpp @@ -69,9 +69,10 @@ bool AwsDoc::DynamoDB::putItem(const Aws::String &tableName, } else { std::cerr << outcome.GetError().GetMessage() << std::endl; + return false; } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[dynamodb.cpp.put_item.code] diff --git a/cpp/example_code/dynamodb/update_item.cpp b/cpp/example_code/dynamodb/update_item.cpp index 378e145224b..73e05ad706b 100644 --- a/cpp/example_code/dynamodb/update_item.cpp +++ b/cpp/example_code/dynamodb/update_item.cpp @@ -80,12 +80,12 @@ bool AwsDoc::DynamoDB::updateItem(const Aws::String &tableName, request); if (outcome.IsSuccess()) { std::cout << "Item was updated" << std::endl; - } - else { + } else { std::cerr << outcome.GetError().GetMessage() << std::endl; + return false; } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[dynamodb.cpp.update_item.code] diff --git a/cpp/example_code/dynamodb/update_table.cpp b/cpp/example_code/dynamodb/update_table.cpp index e66715e8343..cba2249aa8d 100644 --- a/cpp/example_code/dynamodb/update_table.cpp +++ b/cpp/example_code/dynamodb/update_table.cpp @@ -60,12 +60,18 @@ bool AwsDoc::DynamoDB::updateTable(const Aws::String &tableName, request); if (outcome.IsSuccess()) { std::cout << "Successfully updated the table." << std::endl; - } - else { - std::cerr << outcome.GetError().GetMessage() << std::endl; + } else { + const Aws::DynamoDB::DynamoDBError &error = outcome.GetError(); + if (error.GetErrorType() == Aws::DynamoDB::DynamoDBErrors::VALIDATION && + error.GetMessage().find("The provisioned throughput for the table will not change") != std::string::npos) { + std::cout << "The provisioned throughput for the table will not change." << std::endl; + } else { + std::cerr << outcome.GetError().GetMessage() << std::endl; + return false; + } } - return outcome.IsSuccess(); + return waitTableActive(tableName, dynamoClient); } // snippet-end:[dynamodb.cpp.update_table.code] diff --git a/cpp/example_code/s3/create_bucket.cpp b/cpp/example_code/s3/create_bucket.cpp index cf51221b36a..5d2104a3d6a 100644 --- a/cpp/example_code/s3/create_bucket.cpp +++ b/cpp/example_code/s3/create_bucket.cpp @@ -60,16 +60,28 @@ bool AwsDoc::S3::createBucket(const Aws::String &bucketName, * * main function * - * Usage: 'run_create_bucket>' + * Usage: 'run_create_bucket * */ #ifndef EXCLUDE_MAIN_FUNCTION -int main() { +int main(int argc, char* argv[]) { Aws::SDKOptions options; InitAPI(options); + if (argc != 2) { + std::cout << R"( +Usage: + run_create_bucket +Where: + bucket_name - A bucket name prefix which will be made unique by appending a UUID. +)" << std::endl; + return 1; + } + + Aws::String bucketNamePrefix = argv[1]; + { Aws::S3::S3ClientConfiguration clientConfig; // Optional: Set to the AWS Region in which the bucket was created (overrides config file). @@ -77,10 +89,10 @@ int main() { // Create a unique bucket name to increase the chance of success // when trying to create the bucket. - // Format: "amzn-s3-demo-bucket-" + lowercase UUID. + // Format: " + "-" + lowercase UUID. Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + - Aws::Utils::StringUtils::ToLower(uuid.c_str()); + Aws::String bucketName = bucketNamePrefix + "-" + + Aws::Utils::StringUtils::ToLower(uuid.c_str()); AwsDoc::S3::createBucket(bucketName, clientConfig); } diff --git a/cpp/example_code/s3/list_objects_with_aws_global_region.cpp b/cpp/example_code/s3/list_objects_with_aws_global_region.cpp index e57a5324205..408f5e0c753 100644 --- a/cpp/example_code/s3/list_objects_with_aws_global_region.cpp +++ b/cpp/example_code/s3/list_objects_with_aws_global_region.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -42,10 +41,10 @@ */ static const int MAX_TIMEOUT_RETRIES = 20; -static Aws::String createOneBucket(const Aws::S3::S3Client &s3Client) { +static Aws::String createOneBucket(const Aws::String &bucketNamePrefix, const Aws::S3::S3Client &s3Client) { // Create an S3 bucket within the us-west-2 AWS Region. Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + + Aws::String bucketName = bucketNamePrefix + Aws::Utils::StringUtils::ToLower(uuid.c_str()); Aws::S3::Model::CreateBucketRequest createBucketRequest; @@ -160,13 +159,14 @@ bool deleteABucket(const Aws::S3::S3Client &s3Client, const Aws::String &bucketN */ bool AwsDoc::S3::listObjectsWithAwsGlobalRegion( + const Aws::String &bucketNamePrefix, const Aws::S3::S3ClientConfiguration &clientConfig) { Aws::S3::S3ClientConfiguration config(clientConfig); config.region = Aws::Region::AWS_GLOBAL; Aws::S3::S3Client s3Client(config); - Aws::String bucketName = createOneBucket(s3Client); + Aws::String bucketName = createOneBucket(bucketNamePrefix, s3Client); if (bucketName.empty()) { return false; } @@ -186,17 +186,31 @@ bool AwsDoc::S3::listObjectsWithAwsGlobalRegion( * * main function * + * Usage: ' run_list_objects_with_aws_global_region_bucket ' + * */ #ifndef EXCLUDE_MAIN_FUNCTION -int main() { +int main(int argc, char *argv[]) { + if (argc != 2) { + std::cout << R"( +Usage: + run_list_objects_with_aws_global_region_bucket +Where: + bucket_name - A bucket name prefix which will be made unique by appending a UUID. +)" << std::endl; + return 1; + } + Aws::SDKOptions options; InitAPI(options); + + Aws::String bucketNamePrefix = argv[1]; { Aws::S3::S3ClientConfiguration config; - AwsDoc::S3::listObjectsWithAwsGlobalRegion(config); + AwsDoc::S3::listObjectsWithAwsGlobalRegion(bucketNamePrefix, config); } ShutdownAPI(options); diff --git a/cpp/example_code/s3/s3_examples.h b/cpp/example_code/s3/s3_examples.h index 98cf60a37f9..2da5777698f 100644 --- a/cpp/example_code/s3/s3_examples.h +++ b/cpp/example_code/s3/s3_examples.h @@ -62,6 +62,7 @@ namespace AwsDoc { const Aws::S3::S3ClientConfiguration &clientConfig); bool listObjectsWithAwsGlobalRegion( + const Aws::String &bucketNamePrefix, const Aws::S3::S3ClientConfiguration &clientConfig); Aws::String generatePreSignedPutObjectUrl(const Aws::String &bucketName, @@ -107,7 +108,8 @@ namespace AwsDoc { const Aws::String &errorPage, const Aws::S3::S3ClientConfiguration &clientConfig); - bool S3_GettingStartedScenario(const Aws::String &uploadFilePath, + bool S3_GettingStartedScenario(const Aws::String &bucketNamePrefix, + const Aws::String &uploadFilePath, const Aws::String &saveFilePath, const Aws::Client::ClientConfiguration &clientConfig); diff --git a/cpp/example_code/s3/s3_getting_started_scenario.cpp b/cpp/example_code/s3/s3_getting_started_scenario.cpp index 05b6ca9b03e..24d0d1090e9 100644 --- a/cpp/example_code/s3/s3_getting_started_scenario.cpp +++ b/cpp/example_code/s3/s3_getting_started_scenario.cpp @@ -69,21 +69,23 @@ namespace AwsDoc { //! Scenario to create, copy, and delete S3 buckets and objects. /*! + \param bucketNamePrefix: A prefix for a bucket name. \param uploadFilePath: Path to file to upload to an Amazon S3 bucket. \param saveFilePath: Path for saving a downloaded S3 object. \param clientConfig: Aws client configuration. \return bool: Function succeeded. */ -bool AwsDoc::S3::S3_GettingStartedScenario(const Aws::String &uploadFilePath, +bool AwsDoc::S3::S3_GettingStartedScenario(const Aws::String &bucketNamePrefix, + const Aws::String &uploadFilePath, const Aws::String &saveFilePath, const Aws::Client::ClientConfiguration &clientConfig) { Aws::S3::S3Client client(clientConfig); // Create a unique bucket name which is only temporary and will be deleted. - // Format: "amzn-s3-demo-bucket-" + lowercase UUID. + // Format: + "-" + lowercase UUID. Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + + Aws::String bucketName = bucketNamePrefix + Aws::Utils::StringUtils::ToLower(uuid.c_str()); // 1. Create a bucket. @@ -292,10 +294,11 @@ AwsDoc::S3::deleteBucket(const Aws::String &bucketName, Aws::S3::S3Client &clien int main(int argc, const char *argv[]) { - if (argc != 3) { + if (argc != 4) { std::cout << "Usage:\n" << - " \n\n" << + " \n\n" << "Where:\n" << + " bucketNamePrefix - A prefix for a bucket name..\n" " uploadFilePath - The path where the file is located (for example, C:/AWS/book2.pdf).\n" << " saveFilePath - The path where the file is saved after it's " << @@ -303,15 +306,16 @@ int main(int argc, const char *argv[]) { return 1; } - Aws::String objectPath = argv[1]; - Aws::String savePath = argv[2]; + Aws::String bucketNamePrefix = argv[1]; + Aws::String objectPath = argv[2]; + Aws::String savePath = argv[3]; Aws::SDKOptions options; InitAPI(options); { Aws::Client::ClientConfiguration clientConfig; - AwsDoc::S3::S3_GettingStartedScenario(objectPath, savePath, clientConfig); + AwsDoc::S3::S3_GettingStartedScenario(bucketNamePrefix, objectPath, savePath, clientConfig); } ShutdownAPI(options); diff --git a/cpp/example_code/s3/tests/S3_GTests.cpp b/cpp/example_code/s3/tests/S3_GTests.cpp index 8eb71b03d5b..dd8d9bd02aa 100644 --- a/cpp/example_code/s3/tests/S3_GTests.cpp +++ b/cpp/example_code/s3/tests/S3_GTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include Aws::SDKOptions AwsDocTest::S3_GTests::s_options; @@ -88,9 +89,7 @@ void AwsDocTest::S3_GTests::TearDownTestSuite() { std::vector AwsDocTest::S3_GTests::GetCachedS3Buckets(size_t count) { for (size_t index = s_cachedS3Buckets.size(); index < count; ++index) { - Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + - Aws::Utils::StringUtils::ToLower(uuid.c_str()); + Aws::String bucketName = GetUniqueBucketName(); if (CreateBucket(bucketName)) { s_cachedS3Buckets.push_back(bucketName); @@ -420,6 +419,20 @@ void AwsDocTest::S3_GTests::AddCommandLineResponses( m_cinBuffer.str(stringStream.str()); } +Aws::String AwsDocTest::S3_GTests::GetUniqueBucketName() { + Aws::String uuid = Aws::Utils::UUID::RandomUUID(); + return GetBucketNamePrefix() + Aws::Utils::StringUtils::ToLower(uuid.c_str()); +} + +Aws::String AwsDocTest::S3_GTests::GetBucketNamePrefix() { + Aws::String bucketNamePrefix; + const char* envPrefix = std::getenv("S3TestsBucketPrefix"); + if (envPrefix != nullptr) { + bucketNamePrefix = Aws::String(envPrefix) + "-"; + } + return bucketNamePrefix; +} + AwsDocTest::MockHTTP::MockHTTP() { requestTmp = CreateHttpRequest(Aws::Http::URI("https://test.com/"), Aws::Http::HttpMethod::HTTP_GET, diff --git a/cpp/example_code/s3/tests/S3_GTests.h b/cpp/example_code/s3/tests/S3_GTests.h index 19e9d3ac190..708b2f2d337 100644 --- a/cpp/example_code/s3/tests/S3_GTests.h +++ b/cpp/example_code/s3/tests/S3_GTests.h @@ -53,6 +53,10 @@ namespace AwsDocTest { static Aws::String GetCanonicalUserID(); + static Aws::String GetBucketNamePrefix(); + + static Aws::String GetUniqueBucketName(); + static Aws::String preconditionError(); void AddCommandLineResponses(const std::vector &responses); diff --git a/cpp/example_code/s3/tests/gtest_create_bucket.cpp b/cpp/example_code/s3/tests/gtest_create_bucket.cpp index c468f88cf20..bee8bf43ec5 100644 --- a/cpp/example_code/s3/tests/gtest_create_bucket.cpp +++ b/cpp/example_code/s3/tests/gtest_create_bucket.cpp @@ -19,8 +19,7 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) TEST_F(S3_GTests, create_bucket_2_) { Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + - Aws::Utils::StringUtils::ToLower(uuid.c_str()); + Aws::String bucketName = GetUniqueBucketName(); bool result = AwsDoc::S3::createBucket(bucketName, *s_clientConfig); if (result) { diff --git a/cpp/example_code/s3/tests/gtest_delete_bucket.cpp b/cpp/example_code/s3/tests/gtest_delete_bucket.cpp index 5ca455fbb21..81ba51d1c68 100644 --- a/cpp/example_code/s3/tests/gtest_delete_bucket.cpp +++ b/cpp/example_code/s3/tests/gtest_delete_bucket.cpp @@ -19,8 +19,7 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) TEST_F(S3_GTests, delete_bucket_2_) { Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + - Aws::Utils::StringUtils::ToLower(uuid.c_str()); + Aws::String bucketName = GetUniqueBucketName(); bool result = CreateBucket(bucketName); diff --git a/cpp/example_code/s3/tests/gtest_list_objects_with_aws_global_region.cpp b/cpp/example_code/s3/tests/gtest_list_objects_with_aws_global_region.cpp index e2b292754ae..47147fb087b 100644 --- a/cpp/example_code/s3/tests/gtest_list_objects_with_aws_global_region.cpp +++ b/cpp/example_code/s3/tests/gtest_list_objects_with_aws_global_region.cpp @@ -19,7 +19,9 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) TEST_F(S3_GTests, list_objects_with_aws_global_region_2_) { - bool result = AwsDoc::S3::listObjectsWithAwsGlobalRegion(*s_clientConfig); + Aws::String bucketNamePrefix = GetBucketNamePrefix(); + + bool result = AwsDoc::S3::listObjectsWithAwsGlobalRegion(bucketNamePrefix, *s_clientConfig); EXPECT_TRUE(result); } } // namespace AwsDocTest diff --git a/cpp/example_code/s3/tests/gtest_s3_demo_for_cloud9.cpp b/cpp/example_code/s3/tests/gtest_s3_demo_for_cloud9.cpp index a7946cd4894..2d39870f004 100644 --- a/cpp/example_code/s3/tests/gtest_s3_demo_for_cloud9.cpp +++ b/cpp/example_code/s3/tests/gtest_s3_demo_for_cloud9.cpp @@ -11,8 +11,7 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) TEST_F(S3_GTests, s3_demo_for_cloud9) { Aws::String uuid = Aws::Utils::UUID::RandomUUID(); - Aws::String bucketName = "amzn-s3-demo-bucket-" + - Aws::Utils::StringUtils::ToLower(uuid.c_str()); + Aws::String bucketName = GetUniqueBucketName(); Aws::S3::S3Client s3Client(*s_clientConfig); diff --git a/cpp/example_code/s3/tests/gtest_s3_getting_started_scenario.cpp b/cpp/example_code/s3/tests/gtest_s3_getting_started_scenario.cpp index 535d71b8ef1..a6fa52a263e 100644 --- a/cpp/example_code/s3/tests/gtest_s3_getting_started_scenario.cpp +++ b/cpp/example_code/s3/tests/gtest_s3_getting_started_scenario.cpp @@ -10,12 +10,13 @@ namespace AwsDocTest { // NOLINTNEXTLINE(readability-named-parameter) TEST_F(S3_GTests, s3_getting_started_scenario) { + Aws::String bucketNamePrefix = GetBucketNamePrefix(); Aws::String testFile = GetTestFilePath(); ASSERT_TRUE(!testFile.empty()) << "Failed precondition for test." << std::endl; const char *TEST_SAVE_FILE = "test2.txt"; - EXPECT_TRUE(AwsDoc::S3::S3_GettingStartedScenario(testFile, TEST_SAVE_FILE, *s_clientConfig)); + EXPECT_TRUE(AwsDoc::S3::S3_GettingStartedScenario(bucketNamePrefix, testFile, TEST_SAVE_FILE, *s_clientConfig)); { std::ifstream save_file(TEST_SAVE_FILE); diff --git a/cpp/run_automated_tests.py b/cpp/run_automated_tests.py index d70a6dc98c0..d6168e620c8 100644 --- a/cpp/run_automated_tests.py +++ b/cpp/run_automated_tests.py @@ -302,6 +302,9 @@ def main(argv): start_time = datetime.datetime.now() base_dir = os.getcwd() + + # Set the S3 bucket prefix to be used in tests + os.environ['S3TestsBucketPrefix'] = 'tests-script' [err_code, run_files] = build_tests(service=service)