Skip to content

create_vpn_connection async

create_vpn_connection(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    customer_gateway_id: Optional[CustomerGatewayId] = None,
    type: Optional[String] = None,
    vpn_gateway_id: Optional[VpnGatewayId] = None,
    transit_gateway_id: Optional[TransitGatewayId] = None,
    vpn_concentrator_id: Optional[VpnConcentratorId] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    pre_shared_key_storage: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    options: Optional[VpnConnectionOptionsSpecification] = None,
) -> CreateVpnConnectionResult

Creates a VPN connection between an existing virtual private gateway or transit gateway and a customer gateway. The supported connection type is ipsec.1.

The response includes information that you need to give to your network administrator to configure your customer gateway.

We strongly recommend that you use HTTPS when calling this operation because the response contains sensitive cryptographic information for configuring your customer gateway device.

If you decide to shut down your VPN connection for any reason and later create a new VPN connection, you must reconfigure your customer gateway with the new information returned from this call.

This is an idempotent operation. If you perform the operation more than once, Amazon EC2 doesn't return an error.

For more information, see Amazon Web Services Site-to-Site VPN in the Amazon Web Services Site-to-Site VPN User Guide.

Parameters:

  • customer_gateway_id (Optional[CustomerGatewayId], default: None ) –

    The ID of the customer gateway.

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

    The type of VPN connection (ipsec.1).

  • vpn_gateway_id (Optional[VpnGatewayId], default: None ) –

    The ID of the virtual private gateway. If you specify a virtual private gateway, you cannot specify a transit gateway.

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

    The ID of the transit gateway. If you specify a transit gateway, you cannot specify a virtual private gateway.

  • vpn_concentrator_id (Optional[VpnConcentratorId], default: None ) –

    The ID of the VPN concentrator to associate with the VPN connection.

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

    The tags to apply to the VPN connection.

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

    Specifies the storage mode for the pre-shared key (PSK). Valid values are Standard" (stored in the Site-to-Site VPN service) or SecretsManager (stored in Amazon Web Services Secrets Manager).

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

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

    The options for the VPN connection.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def create_vpn_connection(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    customer_gateway_id: Optional[
        "capo_ec2.types.customer_gateway_id.CustomerGatewayId"
    ] = None,
    type: Optional["capo_ec2.types.string.String"] = None,
    vpn_gateway_id: Optional["capo_ec2.types.vpn_gateway_id.VpnGatewayId"] = None,
    transit_gateway_id: Optional[
        "capo_ec2.types.transit_gateway_id.TransitGatewayId"
    ] = None,
    vpn_concentrator_id: Optional[
        "capo_ec2.types.vpn_concentrator_id.VpnConcentratorId"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    pre_shared_key_storage: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    options: Optional[
        "capo_ec2.types.vpn_connection_options_specification.VpnConnectionOptionsSpecification"
    ] = None,
) -> "capo_ec2.types.create_vpn_connection_result.CreateVpnConnectionResult":
    """<p>Creates a VPN connection between an existing virtual private gateway or transit gateway and a customer gateway. The supported connection type is <code>ipsec.1</code>.</p> <p>The response includes information that you need to give to your network administrator to configure your customer gateway.</p> <important> <p>We strongly recommend that you use HTTPS when calling this operation because the response contains sensitive cryptographic information for configuring your customer gateway device.</p> </important> <p>If you decide to shut down your VPN connection for any reason and later create a new VPN connection, you must reconfigure your customer gateway with the new information returned from this call.</p> <p>This is an idempotent operation. If you perform the operation more than once, Amazon EC2 doesn't return an error.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html">Amazon Web Services Site-to-Site VPN</a> in the <i>Amazon Web Services Site-to-Site VPN User Guide</i>.</p>

    Args:
        customer_gateway_id: <p>The ID of the customer gateway.</p>
        type: <p>The type of VPN connection (<code>ipsec.1</code>).</p>
        vpn_gateway_id: <p>The ID of the virtual private gateway. If you specify a virtual private gateway, you cannot specify a transit gateway.</p>
        transit_gateway_id: <p>The ID of the transit gateway. If you specify a transit gateway, you cannot specify a virtual private gateway.</p>
        vpn_concentrator_id: <p>The ID of the VPN concentrator to associate with the VPN connection.</p>
        tag_specifications: <p>The tags to apply to the VPN connection.</p>
        pre_shared_key_storage: <p>Specifies the storage mode for the pre-shared key (PSK). Valid values are <code>Standard</code>" (stored in the Site-to-Site VPN service) or <code>SecretsManager</code> (stored in Amazon Web Services Secrets Manager).</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>
        options: <p>The options for the VPN connection.</p>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.create_vpn_connection_request.CreateVpnConnectionRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.create_vpn_connection_result.CreateVpnConnectionResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_vpn_connection

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.create_vpn_connection.async_create_vpn_connection(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_ec2.types.create_vpn_connection_request.CreateVpnConnectionRequest",
    ) -> dict[str, Any]:
        import capo_ec2.types.create_vpn_connection_request

        return capo_ec2.types.create_vpn_connection_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_ec2.types.create_vpn_connection_result.CreateVpnConnectionResult",
    ) -> dict[str, Any]:
        import capo_ec2.types.create_vpn_connection_result

        return capo_ec2.types.create_vpn_connection_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateVpnConnection",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ec2.types.create_vpn_connection_request.CreateVpnConnectionRequest = {}
    if customer_gateway_id is not None:
        input_["customer_gateway_id"] = customer_gateway_id
    if type is not None:
        input_["type"] = type
    if vpn_gateway_id is not None:
        input_["vpn_gateway_id"] = vpn_gateway_id
    if transit_gateway_id is not None:
        input_["transit_gateway_id"] = transit_gateway_id
    if vpn_concentrator_id is not None:
        input_["vpn_concentrator_id"] = vpn_concentrator_id
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if pre_shared_key_storage is not None:
        input_["pre_shared_key_storage"] = pre_shared_key_storage
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if options is not None:
        input_["options"] = options

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output