Skip to content

create_route_table

create_route_table(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    vpc_id: Optional[VpcId] = None,
) -> CreateRouteTableResult

Creates a route table for the specified VPC. After you create a route table, you can add routes and associate the table with a subnet.

For more information, see Route tables in the Amazon VPC User Guide.

Parameters:

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to assign to the route table.

  • client_token (Optional[String], default: None ) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • vpc_id (Optional[VpcId], default: None ) –

    The ID of the VPC.

Raises:

Examples:

To create a route table This example creates a route table for the specified VPC.

>>> client.create_route_table(vpc_id='vpc-a01106c2')
Source code in docs_src/capo_ec2/_services/ec2.py
def create_route_table(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
) -> "capo_ec2.types.create_route_table_result.CreateRouteTableResult":
    """<p>Creates a route table for the specified VPC. After you create a route table, you can add routes and associate the table with a subnet.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html">Route tables</a> in the <i>Amazon VPC User Guide</i>.</p>

    Args:
        tag_specifications: <p>The tags to assign to the route table.</p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">Ensuring idempotency</a>.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        vpc_id: <p>The ID of the VPC.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a route table
        This example creates a route table for the specified VPC.

        >>> client.create_route_table(vpc_id='vpc-a01106c2')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_route_table_request.CreateRouteTableRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_route_table_result.CreateRouteTableResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_route_table

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_route_table.create_route_table(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRouteTable")
    )
    input_: capo_ec2.types.create_route_table_request.CreateRouteTableRequest = {}
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output