Uploads an X.509 signing certificate and associates it with the specified IAM user. Some Amazon Web Services services require you to use certificates to validate requests that are signed with a corresponding private key. When you upload the certificate, its default status is Active.
For information about when you would use an X.509 signing certificate, see Managing server certificates in IAM in the IAM User Guide.
If the UserName is not specified, the IAM user name is determined implicitly based on the Amazon Web Services access key ID used to sign the request. This operation works for access keys under the Amazon Web Services account. Consequently, you can use this operation to manage Amazon Web Services account root user credentials even if the Amazon Web Services account has no associated users.
Because the body of an X.509 certificate can be large, you should use POST rather than GET when calling UploadSigningCertificate. For information about setting up signatures and authorization through the API, see Signing Amazon Web Services API requests in the Amazon Web Services General Reference. For general information about using the Query API with IAM, see Making query requests in the IAM User Guide.
Parameters:
-
user_name
(Optional[existingUserNameType], default:
None
)
–
The name of the user the signing certificate is for.
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: _+=,.@-
-
certificate_body
(certificateBodyType)
–
The contents of the signing certificate.
The regex pattern used to validate this parameter is a string of characters consisting of the following:
-
Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range
-
The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
-
The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)
Raises:
-
ConcurrentModificationException
–
The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.
-
DuplicateCertificateException
–
The request was rejected because the same certificate is associated with an IAM user in the account.
-
EntityAlreadyExistsException
–
The request was rejected because it attempted to create a resource that already exists.
-
InvalidCertificateException
–
The request was rejected because the certificate is invalid.
-
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.
-
MalformedCertificateException
–
The request was rejected because the certificate was malformed or expired. The error message describes the specific error.
-
NoSuchEntityException
–
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
-
ServiceFailureException
–
The request processing has failed because of an unknown error, exception or failure.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To upload a signing certificate for an IAM user
The following command uploads a signing certificate for the IAM user named Bob.
>>> await client.upload_signing_certificate(user_name='Bob', certificate_body='-----BEGIN CERTIFICATE-----<certificate-body>-----END CERTIFICATE-----')
Source code in docs_src/capo_iam/_services/async_iam.py
| async def upload_signing_certificate(
self,
certificate_body: "capo_iam.types.certificate_body_type.certificateBodyType",
*,
config_overrides: Optional[AsyncIAMClientConfig] = None,
user_name: Optional[
"capo_iam.types.existing_user_name_type.existingUserNameType"
] = None,
) -> "capo_iam.types.upload_signing_certificate_response.UploadSigningCertificateResponse":
r"""<p>Uploads an X.509 signing certificate and associates it with the specified IAM user. Some Amazon Web Services services require you to use certificates to validate requests that are signed with a corresponding private key. When you upload the certificate, its default status is <code>Active</code>.</p> <p>For information about when you would use an X.509 signing certificate, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs.html">Managing server certificates in IAM</a> in the <i>IAM User Guide</i>.</p> <p>If the <code>UserName</code> is not specified, the IAM user name is determined implicitly based on the Amazon Web Services access key ID used to sign the request. This operation works for access keys under the Amazon Web Services account. Consequently, you can use this operation to manage Amazon Web Services account root user credentials even if the Amazon Web Services account has no associated users.</p> <note> <p>Because the body of an X.509 certificate can be large, you should use POST rather than GET when calling <code>UploadSigningCertificate</code>. For information about setting up signatures and authorization through the API, see <a href="https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html">Signing Amazon Web Services API requests</a> in the <i>Amazon Web Services General Reference</i>. For general information about using the Query API with IAM, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html">Making query requests</a> in the <i>IAM User Guide</i>.</p> </note>
Args:
user_name: <p>The name of the user the signing certificate is for.</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>
certificate_body: <p>The contents of the signing certificate.</p> <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p> <ul> <li> <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p> </li> <li> <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p> </li> <li> <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p> </li> </ul>
Raises:
capo_iam.errors.concurrent_modification_exception.ConcurrentModificationException: <p>The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.</p>
capo_iam.errors.duplicate_certificate_exception.DuplicateCertificateException: <p>The request was rejected because the same certificate is associated with an IAM user in the account.</p>
capo_iam.errors.entity_already_exists_exception.EntityAlreadyExistsException: <p>The request was rejected because it attempted to create a resource that already exists.</p>
capo_iam.errors.invalid_certificate_exception.InvalidCertificateException: <p>The request was rejected because the certificate is invalid.</p>
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.malformed_certificate_exception.MalformedCertificateException: <p>The request was rejected because the certificate was malformed or expired. The error message describes the specific error.</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_failure_exception.ServiceFailureException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To upload a signing certificate for an IAM user
The following command uploads a signing certificate for the IAM user named Bob.
>>> await client.upload_signing_certificate(user_name='Bob', certificate_body='-----BEGIN CERTIFICATE-----<certificate-body>-----END CERTIFICATE-----')
"""
async def _handler(
req: "AsyncOperationRequest[capo_iam.types.upload_signing_certificate_request.UploadSigningCertificateRequest]",
) -> AsyncOperationResponse[
"capo_iam.types.upload_signing_certificate_response.UploadSigningCertificateResponse"
]:
import capo_iam._operations.aws_identity_management_v20100508.upload_signing_certificate
(
output,
http_response,
) = await capo_iam._operations.aws_identity_management_v20100508.upload_signing_certificate.async_upload_signing_certificate(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("UploadSigningCertificate")
)
input_: capo_iam.types.upload_signing_certificate_request.UploadSigningCertificateRequest = {
"certificate_body": certificate_body
}
if user_name is not None:
input_["user_name"] = user_name
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|