Skip to content

create_transit_gateway_vpc_attachment

create_transit_gateway_vpc_attachment(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_id: Optional[TransitGatewayId] = None,
    vpc_id: Optional[VpcId] = None,
    subnet_ids: Optional[TransitGatewaySubnetIdList] = None,
    options: Optional[CreateTransitGatewayVpcAttachmentRequestOptions] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateTransitGatewayVpcAttachmentResult

Attaches the specified VPC to the specified transit gateway.

If you attach a VPC with a CIDR range that overlaps the CIDR range of a VPC that is already attached, the new VPC CIDR range is not propagated to the default propagation route table.

To send VPC traffic to an attached transit gateway, add a route to the VPC route table using CreateRoute.

Parameters:

  • transit_gateway_id (Optional[TransitGatewayId], default: None ) –

    The ID of the transit gateway.

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

    The ID of the VPC.

  • subnet_ids (Optional[TransitGatewaySubnetIdList], default: None ) –

    The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify at least one subnet, but we recommend that you specify two subnets for better availability. The transit gateway uses one IP address from each specified subnet.

  • options (Optional[CreateTransitGatewayVpcAttachmentRequestOptions], default: None ) –

    The VPC attachment options.

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

    The tags to apply to the VPC attachment.

  • 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.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def create_transit_gateway_vpc_attachment(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_id: Optional[
        "capo_ec2.types.transit_gateway_id.TransitGatewayId"
    ] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    subnet_ids: Optional[
        "capo_ec2.types.transit_gateway_subnet_id_list.TransitGatewaySubnetIdList"
    ] = None,
    options: Optional[
        "capo_ec2.types.create_transit_gateway_vpc_attachment_request_options.CreateTransitGatewayVpcAttachmentRequestOptions"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_transit_gateway_vpc_attachment_result.CreateTransitGatewayVpcAttachmentResult":
    """<p>Attaches the specified VPC to the specified transit gateway.</p> <p>If you attach a VPC with a CIDR range that overlaps the CIDR range of a VPC that is already attached, the new VPC CIDR range is not propagated to the default propagation route table.</p> <p>To send VPC traffic to an attached transit gateway, add a route to the VPC route table using <a>CreateRoute</a>.</p>

    Args:
        transit_gateway_id: <p>The ID of the transit gateway.</p>
        vpc_id: <p>The ID of the VPC.</p>
        subnet_ids: <p>The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify at least one subnet, but we recommend that you specify two subnets for better availability. The transit gateway uses one IP address from each specified subnet.</p>
        options: <p>The VPC attachment options.</p>
        tag_specifications: <p>The tags to apply to the VPC attachment.</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>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_transit_gateway_vpc_attachment_request.CreateTransitGatewayVpcAttachmentRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_transit_gateway_vpc_attachment_result.CreateTransitGatewayVpcAttachmentResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_transit_gateway_vpc_attachment

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTransitGatewayVpcAttachment")
    )
    input_: capo_ec2.types.create_transit_gateway_vpc_attachment_request.CreateTransitGatewayVpcAttachmentRequest = {}
    if transit_gateway_id is not None:
        input_["transit_gateway_id"] = transit_gateway_id
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if options is not None:
        input_["options"] = options
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run

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