aws-doc-sdk-examples icon indicating copy to clipboard operation
aws-doc-sdk-examples copied to clipboard

C++: AwsDoc::Aurora::chooseDBInstanceClass() function lists instance classes twice

Open max-webster opened this issue 1 year ago • 1 comments

Expected behavior

I build the Aurora sample code in the C++ SDK and run run_getting_started_with_db_clusters. I expect a prompt like this:

Let's create a DB instance.
The available DB instance classes for your database engine are:
   1: db.r5.12xlarge
   2: db.r5.16xlarge
   3: db.r5.24xlarge
   4: db.r5.2xlarge

and so on for all the eligible instance classes.

Actual behavior

The actual prompt is like so, with all the instance class names doubled:

Let's create a DB instance.
The available DB instance classes for your database engine are:
   1: db.r5.12xlarge
   2: db.r5.12xlarge
   3: db.r5.16xlarge
   4: db.r5.16xlarge
   5: db.r5.24xlarge
   6: db.r5.24xlarge
   7: db.r5.2xlarge
   8: db.r5.2xlarge

This is because at https://github.com/awsdocs/aws-doc-sdk-examples/blob/b20b819fcfadff318cc8cab09f94e6be08c2b140/cpp/example_code/aurora/getting_started_with_db_clusters.cpp#L935C6-L935C43 , the DescribeOrderableDBInstanceOptions() call now returns 2 entries per instance class (at least for most instance classes). One with "StorageType": "aurora" and one with "StorageType": "aurora-iopt1". The entries with "StorageType": "aurora-iopt1" are for the new I/O-optimized feature. The "StorageType": "aurora" ones are more universal because the I/O-optimized feature isn't available for older combinations of engine version and instance class:

$ aws rds describe-orderable-db-instance-options --engine aurora-postgresql | grep StorageType | sort | uniq -c
   1243             "StorageType": "aurora",
    599             "StorageType": "aurora-iopt1",

Therefore I think the best and simplest fix to this code sample is to filter the orderable DB instance classes to only those with the attribute "StorageType": "aurora". Since I think it would be too complicated to offer another choice "I/O-optimized or not?" in the prompts.

I didn't check the other language-specific examples from https://docs.aws.amazon.com/code-library/latest/ug/aurora_example_aurora_CreateDBInstance_section.html , but I presume the same applies if they use the same logic of calling DescribeOrderableDBInstanceOptions().

Steps to reproduce

1.cd to aws_sdk/sdk_build/aws-doc-sdk-examples/cpp/build/example_code/aurora
2. Run: . build_all_examples.sh
3. Run: run_getting_started_with_db_clusters

This is on a Mac but I think the same would apply on Linux.

Logs / stacktrace (if applicable)

No response

Which SDK were you using?

C++

Which OS were you using?

macOS

SDK version

Latest(?) - just downloaded it yesterday

OS version

Sonoma 14.3.1

max-webster avatar Feb 09 '24 22:02 max-webster

Or just get the list the same way as currently, but de-duplicate the entries before printing the prompt. (Add to a set data structure instead of a vector in the instanceClasses.push_back(instanceClass) call on line 957?)

max-webster avatar Feb 09 '24 22:02 max-webster