Creates a new DB security group. DB security groups control access to a DB instance.
A DB security group controls access to EC2-Classic DB instances that are not in a VPC.
EC2-Classic was retired on August 15, 2022. If you haven't migrated from EC2-Classic to a VPC, we recommend that you migrate as soon as possible. For more information, see Migrate from EC2-Classic to a VPC in the Amazon EC2 User Guide, the blog EC2-Classic Networking is Retiring – Here’s How to Prepare, and Moving a DB instance not in a VPC into a VPC in the Amazon RDS User Guide.
Parameters:
-
db_security_group_name
(Optional[String], default:
None
)
–
The name for the DB security group. This value is stored as a lowercase string.
Constraints:
-
Must be 1 to 255 letters, numbers, or hyphens.
-
First character must be a letter
-
Can't end with a hyphen or contain two consecutive hyphens
-
Must not be "Default"
Example: mysecuritygroup
-
db_security_group_description
(Optional[String], default:
None
)
–
The description for the DB security group.
-
tags
(Optional[TagList], default:
None
)
–
Tags to assign to the DB security group.
Raises:
Examples:
To create a DB security group.
This example creates a DB security group.
>>> client.create_db_security_group(db_security_group_name='mydbsecuritygroup', db_security_group_description='My DB security group')
Source code in docs_src/capo_rds/_services/rds.py
| def create_db_security_group(
self,
*,
config_overrides: Optional[RDSClientConfig] = None,
db_security_group_name: Optional["capo_rds.types.string.String"] = None,
db_security_group_description: Optional["capo_rds.types.string.String"] = None,
tags: Optional["capo_rds.types.tag_list.TagList"] = None,
) -> "capo_rds.types.create_db_security_group_result.CreateDBSecurityGroupResult":
"""<p>Creates a new DB security group. DB security groups control access to a DB instance.</p> <p>A DB security group controls access to EC2-Classic DB instances that are not in a VPC.</p> <note> <p>EC2-Classic was retired on August 15, 2022. If you haven't migrated from EC2-Classic to a VPC, we recommend that you migrate as soon as possible. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-migrate.html">Migrate from EC2-Classic to a VPC</a> in the <i>Amazon EC2 User Guide</i>, the blog <a href="http://aws.amazon.com/blogs/aws/ec2-classic-is-retiring-heres-how-to-prepare/">EC2-Classic Networking is Retiring – Here’s How to Prepare</a>, and <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Non-VPC2VPC.html">Moving a DB instance not in a VPC into a VPC</a> in the <i>Amazon RDS User Guide</i>.</p> </note>
Args:
db_security_group_name: <p>The name for the DB security group. This value is stored as a lowercase string.</p> <p>Constraints:</p> <ul> <li> <p>Must be 1 to 255 letters, numbers, or hyphens.</p> </li> <li> <p>First character must be a letter</p> </li> <li> <p>Can't end with a hyphen or contain two consecutive hyphens</p> </li> <li> <p>Must not be "Default"</p> </li> </ul> <p>Example: <code>mysecuritygroup</code> </p>
db_security_group_description: <p>The description for the DB security group.</p>
tags: <p>Tags to assign to the DB security group.</p>
Raises:
capo_rds.errors.db_security_group_already_exists_fault.DBSecurityGroupAlreadyExistsFault: <p>A DB security group with the name specified in <code>DBSecurityGroupName</code> already exists.</p>
capo_rds.errors.db_security_group_not_supported_fault.DBSecurityGroupNotSupportedFault: <p>A DB security group isn't allowed for this action.</p>
capo_rds.errors.db_security_group_quota_exceeded_fault.DBSecurityGroupQuotaExceededFault: <p>The request would result in the user exceeding the allowed number of DB security groups.</p>
capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To create a DB security group.
This example creates a DB security group.
>>> client.create_db_security_group(db_security_group_name='mydbsecuritygroup', db_security_group_description='My DB security group')
"""
def _handler(
req: "OperationRequest[capo_rds.types.create_db_security_group_message.CreateDBSecurityGroupMessage]",
) -> OperationResponse[
"capo_rds.types.create_db_security_group_result.CreateDBSecurityGroupResult"
]:
import capo_rds._operations.amazon_rd_sv19.create_db_security_group
output, http_response = (
capo_rds._operations.amazon_rd_sv19.create_db_security_group.create_db_security_group(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateDBSecurityGroup")
)
input_: capo_rds.types.create_db_security_group_message.CreateDBSecurityGroupMessage = {}
if db_security_group_name is not None:
input_["db_security_group_name"] = db_security_group_name
if db_security_group_description is not None:
input_["db_security_group_description"] = db_security_group_description
if tags is not None:
input_["tags"] = tags
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|