Skip to content

apply_security_groups_to_client_vpn_target_network

apply_security_groups_to_client_vpn_target_network(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_vpn_endpoint_id: Optional[ClientVpnEndpointId] = None,
    vpc_id: Optional[VpcId] = None,
    security_group_ids: Optional[ClientVpnSecurityGroupIdSet] = None,
    dry_run: Optional[Boolean] = None,
) -> ApplySecurityGroupsToClientVpnTargetNetworkResult

Applies a security group to the association between the target network and the Client VPN endpoint. This action replaces the existing security groups with the specified security groups.

Parameters:

  • client_vpn_endpoint_id (Optional[ClientVpnEndpointId], default: None ) –

    The ID of the Client VPN endpoint.

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

    The ID of the VPC in which the associated target network is located.

  • security_group_ids (Optional[ClientVpnSecurityGroupIdSet], default: None ) –

    The IDs of the security groups to apply to the associated target network. Up to 5 security groups can be applied to an associated target network.

  • 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 apply_security_groups_to_client_vpn_target_network(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_vpn_endpoint_id: Optional[
        "capo_ec2.types.client_vpn_endpoint_id.ClientVpnEndpointId"
    ] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    security_group_ids: Optional[
        "capo_ec2.types.client_vpn_security_group_id_set.ClientVpnSecurityGroupIdSet"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.apply_security_groups_to_client_vpn_target_network_result.ApplySecurityGroupsToClientVpnTargetNetworkResult":
    """<p>Applies a security group to the association between the target network and the Client VPN endpoint. This action replaces the existing security groups with the specified security groups.</p>

    Args:
        client_vpn_endpoint_id: <p>The ID of the Client VPN endpoint.</p>
        vpc_id: <p>The ID of the VPC in which the associated target network is located.</p>
        security_group_ids: <p>The IDs of the security groups to apply to the associated target network. Up to 5 security groups can be applied to an associated target network.</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.apply_security_groups_to_client_vpn_target_network_request.ApplySecurityGroupsToClientVpnTargetNetworkRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.apply_security_groups_to_client_vpn_target_network_result.ApplySecurityGroupsToClientVpnTargetNetworkResult"
    ]:
        import capo_ec2._operations.amazon_ec2.apply_security_groups_to_client_vpn_target_network

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

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ApplySecurityGroupsToClientVpnTargetNetwork"),
    )
    input_: capo_ec2.types.apply_security_groups_to_client_vpn_target_network_request.ApplySecurityGroupsToClientVpnTargetNetworkRequest = {}
    if client_vpn_endpoint_id is not None:
        input_["client_vpn_endpoint_id"] = client_vpn_endpoint_id
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    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