Repository: getmoto/moto

Issue:
RDS create_option_group supports only mysql engine
`rds_client.create_option_group(
        OptionGroupName="default:postgres-13",
        EngineName="postgres",
        MajorEngineVersion="13",
        OptionGroupDescription="Default option group for postgres 13",
 )`

Raises: `botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the CreateOptionGroup operation: Invalid DB engine: non-existent

/Users/may/Library/Caches/pypoetry/virtualenvs/venv-F1avdFZI-py3.9/lib/python3.9/site-packages/botocore/client.py:915: ClientError`

According to the tests, indeed only mysql engine is being checked, but RDS supports multiple engines (sqlserver, oracle, postgres, aurora-postgres, etc..). Link: https://github.com/spulec/moto/blob/4eb3944b1d9d8f513f1cb96425f60ae41039a831/tests/test_rds/test_rds.py
   - Tell us **what you expected to happen**. When we run your example code,
     what are we expecting to happen? What does "success" look like for your
     code?

I want to be able to test different database engines.

   - Tell us **what actually happens**. It's not helpful for you to say "it
     doesn't work" or "it fails". Tell us *how* it fails: do you get an
     exception? A hang? How was the actual result different from your expected
     result?

It throws a `ClientError` exception

   - Tell us **what version of Moto you're using**, and
     **how you installed it**. Tell us whether you're using standalone server
     mode or the Python mocks. If you are using the Python mocks, include the
     version of boto/boto3/botocore.

moto                                3.1.18
aioboto3                            10.2.0
boto3                               1.24.59
boto3-stubs                         1.26.27




Discussion:
Thanks for raising this @mayk0gan - that's definitely a bug. We do allow other engines, but our list is not complete:

https://github.com/spulec/moto/blob/3c7bdcc5ea4d30681c5d8712926adedc294948fe/moto/rds/models.py#L1595
Interestingly enough, I'm not able to create option groups for Postgres in the UI:
![Screenshot from 2022-12-14 11-13-29](https://user-images.githubusercontent.com/6058517/207594495-d8cdc275-7a03-4706-a3a8-497c5060a5d2.png)


But it does work in the CLI.

As far as I can tell, there is no documentation on what is allowed, so  I'll update the available engine versions based on what the CLI allows.

Resolving patch:
diff --git a/moto/rds/models.py b/moto/rds/models.py
--- a/moto/rds/models.py
+++ b/moto/rds/models.py
@@ -1594,17 +1594,29 @@ def delete_subnet_group(self, subnet_name):
 
     def create_option_group(self, option_group_kwargs):
         option_group_id = option_group_kwargs["name"]
+        # This list was verified against the AWS Console on 14 Dec 2022
+        # Having an automated way (using the CLI) would be nice, but AFAICS that's not possible
+        #
+        # Some options that are allowed in the CLI, but that do now show up in the Console:
+        # - Mysql 5.5
+        # - All postgres-versions
+        # - oracle-se and oracle-se1 - I could not deduct the available versions
+        #   `Cannot find major version 19 for oracle-se`
+        #   (The engines do exist, otherwise the error would be `Invalid DB engine`
         valid_option_group_engines = {
-            "mariadb": ["10.0", "10.1", "10.2", "10.3"],
+            "mariadb": ["10.0", "10.1", "10.2", "10.3", "10.4", "10.5", "10.6"],
             "mysql": ["5.5", "5.6", "5.7", "8.0"],
-            "oracle-se2": ["11.2", "12.1", "12.2"],
-            "oracle-se1": ["11.2", "12.1", "12.2"],
-            "oracle-se": ["11.2", "12.1", "12.2"],
-            "oracle-ee": ["11.2", "12.1", "12.2"],
-            "sqlserver-se": ["10.50", "11.00"],
-            "sqlserver-ee": ["10.50", "11.00"],
-            "sqlserver-ex": ["10.50", "11.00"],
-            "sqlserver-web": ["10.50", "11.00"],
+            "oracle-ee": ["19"],
+            "oracle-ee-cdb": ["19", "21"],
+            "oracle-se": [],
+            "oracle-se1": [],
+            "oracle-se2": ["19"],
+            "oracle-se2-cdb": ["19", "21"],
+            "postgres": ["10", "11", "12", "13"],
+            "sqlserver-ee": ["11.00", "12.00", "13.00", "14.00", "15.00"],
+            "sqlserver-ex": ["11.00", "12.00", "13.00", "14.00", "15.00"],
+            "sqlserver-se": ["11.00", "12.00", "13.00", "14.00", "15.00"],
+            "sqlserver-web": ["11.00", "12.00", "13.00", "14.00", "15.00"],
         }
         if option_group_id in self.option_groups:
             raise RDSClientError(
@@ -1631,6 +1643,18 @@ def create_option_group(self, option_group_kwargs):
                 "InvalidParameterCombination",
                 f"Cannot find major version {option_group_kwargs['major_engine_version']} for {option_group_kwargs['engine_name']}",
             )
+        # AWS also creates default option groups, if they do not yet exist, when creating an option group in the CLI
+        # Maybe we should do the same
+        # {
+        #     "OptionGroupName": "default:postgres-10",
+        #     "OptionGroupDescription": "Default option group for postgres 10",
+        #     "EngineName": "postgres",
+        #     "MajorEngineVersion": "10",
+        #     "Options": [],
+        #     "AllowsVpcAndNonVpcInstanceMemberships": true,
+        #     "OptionGroupArn": "arn:aws:rds:us-east-1:{account}:og:default:postgres-10"
+        # }
+        # The CLI does not allow deletion of default groups
         option_group = OptionGroup(**option_group_kwargs)
         self.option_groups[option_group_id] = option_group
         return option_group


Test patch: