Use this operation to update your workforce. You can use this operation to require that workers use specific IP addresses to work on tasks and to update your OpenID Connect (OIDC) Identity Provider (IdP) workforce configuration.
The worker portal is now supported in VPC and public internet.
Use SourceIpConfig to restrict worker access to tasks to a specific range of IP addresses. You specify allowed IP addresses by creating a list of up to ten CIDRs. By default, a workforce isn't restricted to specific IP addresses. If you specify a range of IP addresses, workers who attempt to access tasks using any IP address outside the specified range are denied and get a Not Found error message on the worker portal.
To restrict public internet access for all workers, configure the SourceIpConfig CIDR value. For example, when using SourceIpConfig with an IpAddressType of IPv4, you can restrict access to the IPv4 CIDR block "10.0.0.0/16". When using an IpAddressType of dualstack, you can specify both the IPv4 and IPv6 CIDR blocks, such as "10.0.0.0/16" for IPv4 only, "2001:db8:1234:1a00::/56" for IPv6 only, or "10.0.0.0/16" and "2001:db8:1234:1a00::/56" for dual stack.
Amazon SageMaker does not support Source Ip restriction for worker portals in VPC.
Use OidcConfig to update the configuration of a workforce created using your own OIDC IdP.
You can only update your OIDC IdP configuration when there are no work teams associated with your workforce. You can delete work teams using the DeleteWorkteam operation.
After restricting access to a range of IP addresses or updating your OIDC IdP configuration with this operation, you can view details about your update workforce using the DescribeWorkforce operation.
This operation only applies to private workforces.
Parameters:
-
workforce_name
(Optional[WorkforceName], default:
None
)
–
The name of the private workforce that you want to update. You can find your workforce name by using the ListWorkforces operation.
-
source_ip_config
(Optional[SourceIpConfig], default:
None
)
–
A list of one to ten worker IP address ranges (CIDRs) that can be used to access tasks assigned to this workforce.
Maximum: Ten CIDR values
-
oidc_config
(Optional[OidcConfig], default:
None
)
–
Use this parameter to update your OIDC Identity Provider (IdP) configuration for a workforce made using your own IdP.
-
workforce_vpc_config
(Optional[WorkforceVpcConfigRequest], default:
None
)
–
Use this parameter to update your VPC configuration for a workforce.
-
ip_address_type
(Optional[WorkforceIpAddressType], default:
None
)
–
Use this parameter to specify whether you want IPv4 only or dualstack (IPv4 and IPv6) to support your labeling workforce.
Raises:
-
ConflictException
–
There was a conflict when you attempted to modify a SageMaker entity such as an Experiment or Artifact.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_sagemaker/_services/async_sage_maker.py
| async def update_workforce(
self,
*,
config_overrides: Optional[AsyncSageMakerClientConfig] = None,
workforce_name: Optional[
"capo_sagemaker.types.workforce_name.WorkforceName"
] = None,
source_ip_config: Optional[
"capo_sagemaker.types.source_ip_config.SourceIpConfig"
] = None,
oidc_config: Optional["capo_sagemaker.types.oidc_config.OidcConfig"] = None,
workforce_vpc_config: Optional[
"capo_sagemaker.types.workforce_vpc_config_request.WorkforceVpcConfigRequest"
] = None,
ip_address_type: Optional[
"capo_sagemaker.types.workforce_ip_address_type.WorkforceIpAddressType"
] = None,
) -> "capo_sagemaker.types.update_workforce_response.UpdateWorkforceResponse":
"""<p>Use this operation to update your workforce. You can use this operation to require that workers use specific IP addresses to work on tasks and to update your OpenID Connect (OIDC) Identity Provider (IdP) workforce configuration.</p> <p>The worker portal is now supported in VPC and public internet.</p> <p> Use <code>SourceIpConfig</code> to restrict worker access to tasks to a specific range of IP addresses. You specify allowed IP addresses by creating a list of up to ten <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html">CIDRs</a>. By default, a workforce isn't restricted to specific IP addresses. If you specify a range of IP addresses, workers who attempt to access tasks using any IP address outside the specified range are denied and get a <code>Not Found</code> error message on the worker portal.</p> <p>To restrict public internet access for all workers, configure the <code>SourceIpConfig</code> CIDR value. For example, when using <code>SourceIpConfig</code> with an <code>IpAddressType</code> of <code>IPv4</code>, you can restrict access to the IPv4 CIDR block "10.0.0.0/16". When using an <code>IpAddressType</code> of <code>dualstack</code>, you can specify both the IPv4 and IPv6 CIDR blocks, such as "10.0.0.0/16" for IPv4 only, "2001:db8:1234:1a00::/56" for IPv6 only, or "10.0.0.0/16" and "2001:db8:1234:1a00::/56" for dual stack.</p> <important> <p>Amazon SageMaker does not support Source Ip restriction for worker portals in VPC.</p> </important> <p>Use <code>OidcConfig</code> to update the configuration of a workforce created using your own OIDC IdP. </p> <important> <p>You can only update your OIDC IdP configuration when there are no work teams associated with your workforce. You can delete work teams using the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html">DeleteWorkteam</a> operation.</p> </important> <p>After restricting access to a range of IP addresses or updating your OIDC IdP configuration with this operation, you can view details about your update workforce using the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeWorkforce.html">DescribeWorkforce</a> operation.</p> <important> <p>This operation only applies to private workforces.</p> </important>
Args:
workforce_name: <p>The name of the private workforce that you want to update. You can find your workforce name by using the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ListWorkforces.html">ListWorkforces</a> operation.</p>
source_ip_config: <p>A list of one to ten worker IP address ranges (<a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html">CIDRs</a>) that can be used to access tasks assigned to this workforce.</p> <p>Maximum: Ten CIDR values</p>
oidc_config: <p>Use this parameter to update your OIDC Identity Provider (IdP) configuration for a workforce made using your own IdP.</p>
workforce_vpc_config: <p>Use this parameter to update your VPC configuration for a workforce.</p>
ip_address_type: <p>Use this parameter to specify whether you want <code>IPv4</code> only or <code>dualstack</code> (<code>IPv4</code> and <code>IPv6</code>) to support your labeling workforce.</p>
Raises:
capo_sagemaker.errors.conflict_exception.ConflictException: <p>There was a conflict when you attempted to modify a SageMaker entity such as an <code>Experiment</code> or <code>Artifact</code>.</p>
capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_sagemaker.types.update_workforce_request.UpdateWorkforceRequest]",
) -> AsyncOperationResponse[
"capo_sagemaker.types.update_workforce_response.UpdateWorkforceResponse"
]:
import capo_sagemaker._operations.sage_maker.update_workforce
(
output,
http_response,
) = await capo_sagemaker._operations.sage_maker.update_workforce.async_update_workforce(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_sagemaker.types.update_workforce_request.UpdateWorkforceRequest",
) -> dict[str, Any]:
import capo_sagemaker.types.update_workforce_request
return capo_sagemaker.types.update_workforce_request.redact_sensitive(
input_
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("UpdateWorkforce", redact_input=_redact_input),
)
input_: capo_sagemaker.types.update_workforce_request.UpdateWorkforceRequest = {}
if workforce_name is not None:
input_["workforce_name"] = workforce_name
if source_ip_config is not None:
input_["source_ip_config"] = source_ip_config
if oidc_config is not None:
input_["oidc_config"] = oidc_config
if workforce_vpc_config is not None:
input_["workforce_vpc_config"] = workforce_vpc_config
if ip_address_type is not None:
input_["ip_address_type"] = ip_address_type
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|