Generates a set of credentials consisting of a user name and password that can be used to access the service specified in the request. These credentials are generated by IAM, and can be used only for the specified service.
You can have a maximum of two sets of service-specific credentials for each supported service per user.
You can reset the password to a new service-generated value by calling ResetServiceSpecificCredential.
For more information about using service-specific credentials to authenticate to an Amazon Web Services service, refer to the following docs:
Parameters:
-
user_name
(userNameType)
–
The name of the IAM user that is to be associated with the credentials. The new service-specific credentials have the same permissions as the associated user except that they can be used only to access the specified service.
This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-
-
service_name
(serviceName)
–
The name of the Amazon Web Services service that is to be associated with the credentials. The service you specify here is the only service that can be accessed using these credentials.
-
credential_age_days
(Optional[credentialAgeDays], default:
None
)
–
The number of days until the service specific credential expires. This field is only valid for services that support long-term API keys and must be a positive integer. When not specified, the credential will not expire.
To see which services support long-term API keys, refer to API keys for Amazon Web Services services in the IAM User Guide.
Raises:
-
LimitExceededException
–
The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.
-
NoSuchEntityException
–
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
-
ServiceNotSupportedException
–
The specified service does not support service-specific credentials.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_iam/_services/iam.py
| def create_service_specific_credential(
self,
user_name: "capo_iam.types.user_name_type.userNameType",
service_name: "capo_iam.types.service_name.serviceName",
*,
config_overrides: Optional[IAMClientConfig] = None,
credential_age_days: Optional[
"capo_iam.types.credential_age_days.credentialAgeDays"
] = None,
) -> "capo_iam.types.create_service_specific_credential_response.CreateServiceSpecificCredentialResponse":
"""<p>Generates a set of credentials consisting of a user name and password that can be used to access the service specified in the request. These credentials are generated by IAM, and can be used only for the specified service. </p> <p>You can have a maximum of two sets of service-specific credentials for each supported service per user.</p> <p>You can reset the password to a new service-generated value by calling <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_ResetServiceSpecificCredential.html">ResetServiceSpecificCredential</a>.</p> <p>For more information about using service-specific credentials to authenticate to an Amazon Web Services service, refer to the following docs:</p> <ul> <li> <p>For service-specific credentials with CodeCommit, refer to <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_ssh-keys.html">IAM credentials for CodeCommit: Git credentials, SSH keys, and Amazon Web Services access keys</a> in the <i>IAM User Guide</i>.</p> </li> <li> <p>For service-specific credentials with Amazon Keyspaces (for Apache Cassandra), refer to <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_keyspaces.html">Use IAM with Amazon Keyspaces (for Apache Cassandra)</a> in the <i>IAM User Guide</i>.</p> </li> <li> <p>For services that support long-term API keys, refer to <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_api_keys_for_aws_services.html">API keys for Amazon Web Services services</a> in the <i>IAM User Guide</i>.</p> </li> </ul>
Args:
user_name: <p>The name of the IAM user that is to be associated with the credentials. The new service-specific credentials have the same permissions as the associated user except that they can be used only to access the specified service.</p> <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
service_name: <p>The name of the Amazon Web Services service that is to be associated with the credentials. The service you specify here is the only service that can be accessed using these credentials.</p>
credential_age_days: <p>The number of days until the service specific credential expires. This field is only valid for services that support long-term API keys and must be a positive integer. When not specified, the credential will not expire.</p> <p>To see which services support long-term API keys, refer to <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_api_keys_for_aws_services.html">API keys for Amazon Web Services services</a> in the <i>IAM User Guide</i>.</p>
Raises:
capo_iam.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.</p>
capo_iam.errors.no_such_entity_exception.NoSuchEntityException: <p>The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.</p>
capo_iam.errors.service_not_supported_exception.ServiceNotSupportedException: <p>The specified service does not support service-specific credentials.</p>
capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_iam.types.create_service_specific_credential_request.CreateServiceSpecificCredentialRequest]",
) -> OperationResponse[
"capo_iam.types.create_service_specific_credential_response.CreateServiceSpecificCredentialResponse"
]:
import capo_iam._operations.aws_identity_management_v20100508.create_service_specific_credential
output, http_response = (
capo_iam._operations.aws_identity_management_v20100508.create_service_specific_credential.create_service_specific_credential(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_iam.types.create_service_specific_credential_response.CreateServiceSpecificCredentialResponse",
) -> dict[str, Any]:
import capo_iam.types.create_service_specific_credential_response
return capo_iam.types.create_service_specific_credential_response.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging(
"CreateServiceSpecificCredential", redact_output=_redact_output
),
)
input_: capo_iam.types.create_service_specific_credential_request.CreateServiceSpecificCredentialRequest = {
"user_name": user_name,
"service_name": service_name,
}
if credential_age_days is not None:
input_["credential_age_days"] = credential_age_days
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|