Repository: getmoto/moto
Pull request #5955 (2023-02-21 13:17:46)

add arn for rds OptionGroup
Creating or describing a RDS `OptionGroup` is missing the parameter `OptionGroupArn`, as [examples described in the docs](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-option-group.html#examples):

> 
```
{
    "OptionGroup": {
        "OptionGroupName": "myoptiongroup",
        "OptionGroupDescription": "Oracle Database Manager Database Control",
        "EngineName": "oracle-ee",
        "MajorEngineVersion": "11.2",
        "Options": [],
        "AllowsVpcAndNonVpcInstanceMemberships": true,
        "OptionGroupArn": "arn:aws:rds:us-west-2:123456789012:og:myoptiongroup"
    }
}
```
The arn is required e.g. for specific terraform deployments, and was [reported as an issue in LocalStack](https://github.com/localstack/localstack/issues/7721).


Patch:
diff --git a/moto/batch/models.py b/moto/batch/models.py
index 5bd751ab8..97ea23945 100644
--- a/moto/batch/models.py
+++ b/moto/batch/models.py
@@ -606,7 +606,12 @@ class Job(threading.Thread, BaseModel, DockerModel, ManagedState):
         """
         try:
             import docker
+        except ImportError as err:
+            logger.error(f"Failed to run AWS Batch container {self.name}. Error {err}")
+            self._mark_stopped(success=False)
+            return
 
+        try:
             containers: List[docker.models.containers.Container] = []
 
             self.advance()
diff --git a/moto/rds/models.py b/moto/rds/models.py
index d394f933e..77124b0c4 100644
--- a/moto/rds/models.py
+++ b/moto/rds/models.py
@@ -1677,6 +1677,10 @@ class RDSBackend(BaseBackend):
         #     "OptionGroupArn": "arn:aws:rds:us-east-1:{account}:og:default:postgres-10"
         # }
         # The CLI does not allow deletion of default groups
+
+        # add region and account-id to construct the arn
+        option_group_kwargs["region"] = self.region_name
+        option_group_kwargs["account_id"] = self.account_id
         option_group = OptionGroup(**option_group_kwargs)
         self.option_groups[option_group_id] = option_group
         return option_group
@@ -2209,7 +2213,15 @@ class RDSBackend(BaseBackend):
 
 
 class OptionGroup(object):
-    def __init__(self, name, engine_name, major_engine_version, description=None):
+    def __init__(
+        self,
+        name,
+        engine_name,
+        major_engine_version,
+        region,
+        account_id,
+        description=None,
+    ):
         self.engine_name = engine_name
         self.major_engine_version = major_engine_version
         self.description = description
@@ -2218,6 +2230,7 @@ class OptionGroup(object):
         self.options = {}
         self.vpcId = "null"
         self.tags = []
+        self.arn = f"arn:aws:rds:{region}:{account_id}:og:{name}"
 
     def to_json(self):
         template = Template(
@@ -2228,7 +2241,8 @@ class OptionGroup(object):
     "AllowsVpcAndNonVpcInstanceMemberships": "{{ option_group.vpc_and_non_vpc_instance_memberships }}",
     "EngineName": "{{ option_group.engine_name }}",
     "Options": [],
-    "OptionGroupName": "{{ option_group.name }}"
+    "OptionGroupName": "{{ option_group.name }},
+    "OptionGroupArn": "{{ option_group.arn }}
 }"""
         )
         return template.render(option_group=self)
@@ -2241,6 +2255,7 @@ class OptionGroup(object):
           <MajorEngineVersion>{{ option_group.major_engine_version }}</MajorEngineVersion>
           <EngineName>{{ option_group.engine_name }}</EngineName>
           <OptionGroupDescription>{{ option_group.description }}</OptionGroupDescription>
+          <OptionGroupArn>{{ option_group.arn }}</OptionGroupArn>
           <Options/>
         </OptionGroup>"""
         )


Test patch:
diff --git a/tests/test_rds/test_rds.py b/tests/test_rds/test_rds.py
index cb452c06b..653e39744 100644
--- a/tests/test_rds/test_rds.py
+++ b/tests/test_rds/test_rds.py
@@ -1228,6 +1228,9 @@ def test_create_option_group():
         "test option group"
     )
     option_group["OptionGroup"]["MajorEngineVersion"].should.equal("5.6")
+    option_group["OptionGroup"]["OptionGroupArn"].should.equal(
+        f"arn:aws:rds:us-west-2:{ACCOUNT_ID}:og:test"
+    )
 
 
 @mock_rds