Skip to content

create_resource async

create_resource(
    type_name: TypeName,
    desired_state: Properties,
    *,
    config_overrides: Optional[AsyncCloudControlClientConfig] = None,
    type_version_id: Optional[TypeVersionId] = None,
    role_arn: Optional[RoleArn] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateResourceOutput

Creates the specified resource. For more information, see Creating a resource in the Amazon Web Services Cloud Control API User Guide.

After you have initiated a resource creation request, you can monitor the progress of your request by calling GetResourceRequestStatus using the RequestToken of the ProgressEvent type returned by CreateResource.

Parameters:

  • type_name (TypeName) –

    The name of the resource type.

  • type_version_id (Optional[TypeVersionId], default: None ) –

    For private resource types, the type version to use in this resource operation. If you do not specify a resource version, CloudFormation uses the default version.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the Identity and Access Management (IAM) role for Cloud Control API to use when performing this resource operation. The role specified must have the permissions required for this operation. The necessary permissions for each event handler are defined in the handlers section of the resource type definition schema.

    If you do not specify a role, Cloud Control API uses a temporary session created using your Amazon Web Services user credentials.

    For more information, see Specifying credentials in the Amazon Web Services Cloud Control API User Guide.

  • client_token (Optional[ClientToken], default: None ) –

    A unique identifier to ensure the idempotency of the resource request. As a best practice, specify this token to ensure idempotency, so that Amazon Web Services Cloud Control API can accurately distinguish between request retries and new resource requests. You might retry a resource request to ensure that it was successfully received.

    A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request.

    If you do not specify a client token, one is generated for inclusion in the request.

    For more information, see Ensuring resource operation requests are unique in the Amazon Web Services Cloud Control API User Guide.

  • desired_state (Properties) –

    Structured data format representing the desired state of the resource, consisting of that resource's properties and their desired values.

    Cloud Control API currently supports JSON as a structured data format.

    Specify the desired state as one of the following:

    • A JSON blob

    • A local path containing the desired state in JSON data format

    For more information, see Composing the desired state of the resource in the Amazon Web Services Cloud Control API User Guide.

    For more information about the properties of a specific resource, refer to the related topic for the resource in the Resource and property types reference in the CloudFormation Users Guide.

Raises:

  • AlreadyExistsException –

    The resource with the name requested already exists.

  • ClientTokenConflictException –

    The specified client token has already been used in another resource request.

    It's best practice for client tokens to be unique for each resource operation request. However, client token expire after 36 hours.

  • ConcurrentOperationException –

    Another resource operation is currently being performed on this resource.

  • GeneralServiceException –

    The resource handler has returned that the downstream service generated an error that doesn't map to any other handler error code.

  • HandlerFailureException –

    The resource handler has failed without a returning a more specific error code. This can include timeouts.

  • HandlerInternalFailureException –

    The resource handler has returned that an unexpected error occurred within the resource handler.

  • InvalidCredentialsException –

    The resource handler has returned that the credentials provided by the user are invalid.

  • InvalidRequestException –

    The resource handler has returned that invalid input from the user has generated a generic exception.

  • NetworkFailureException –

    The resource handler has returned that the request couldn't be completed due to networking issues, such as a failure to receive a response from the server.

  • NotStabilizedException –

    The resource handler has returned that the downstream resource failed to complete all of its ready-state checks.

  • NotUpdatableException –

    One or more properties included in this resource operation are defined as create-only, and therefore can't be updated.

  • PrivateTypeException –

    Cloud Control API hasn't received a valid response from the resource handler, due to a configuration error. This includes issues such as the resource handler returning an invalid response, or timing out.

  • ResourceConflictException –

    The resource is temporarily unavailable to be acted upon. For example, if the resource is currently undergoing an operation and can't be acted upon until that operation is finished.

  • ResourceNotFoundException –

    A resource with the specified identifier can't be found.

  • ServiceInternalErrorException –

    The resource handler has returned that the downstream service returned an internal error, typically with a 5XX HTTP status code.

  • ServiceLimitExceededException –

    The resource handler has returned that a non-transient resource limit was reached on the service side.

  • ThrottlingException –

    The request was denied due to request throttling.

  • TypeNotFoundException –

    The specified extension doesn't exist in the CloudFormation registry.

  • UnsupportedActionException –

    The specified resource doesn't support this resource operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_cloudcontrol/_services/async_cloud_control.py
async def create_resource(
    self,
    type_name: "capo_cloudcontrol.types.type_name.TypeName",
    desired_state: "capo_cloudcontrol.types.properties.Properties",
    *,
    config_overrides: Optional[AsyncCloudControlClientConfig] = None,
    type_version_id: Optional[
        "capo_cloudcontrol.types.type_version_id.TypeVersionId"
    ] = None,
    role_arn: Optional["capo_cloudcontrol.types.role_arn.RoleArn"] = None,
    client_token: Optional[
        "capo_cloudcontrol.types.client_token.ClientToken"
    ] = None,
) -> "capo_cloudcontrol.types.create_resource_output.CreateResourceOutput":
    """<p>Creates the specified resource. For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-create.html">Creating a resource</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p> <p>After you have initiated a resource creation request, you can monitor the progress of your request by calling <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_GetResourceRequestStatus.html">GetResourceRequestStatus</a> using the <code>RequestToken</code> of the <code>ProgressEvent</code> type returned by <code>CreateResource</code>.</p>

    Args:
        type_name: <p>The name of the resource type.</p>
        type_version_id: <p>For private resource types, the type version to use in this resource operation. If you do not specify a resource version, CloudFormation uses the default version.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the Identity and Access Management (IAM) role for Cloud Control API to use when performing this resource operation. The role specified must have the permissions required for this operation. The necessary permissions for each event handler are defined in the <code> <a href="https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-handlers">handlers</a> </code> section of the <a href="https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html">resource type definition schema</a>.</p> <p>If you do not specify a role, Cloud Control API uses a temporary session created using your Amazon Web Services user credentials.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-permissions">Specifying credentials</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p>
        client_token: <p>A unique identifier to ensure the idempotency of the resource request. As a best practice, specify this token to ensure idempotency, so that Amazon Web Services Cloud Control API can accurately distinguish between request retries and new resource requests. You might retry a resource request to ensure that it was successfully received.</p> <p>A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request.</p> <p>If you do not specify a client token, one is generated for inclusion in the request.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-idempotency">Ensuring resource operation requests are unique</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p>
        desired_state: <p>Structured data format representing the desired state of the resource, consisting of that resource's properties and their desired values.</p> <note> <p>Cloud Control API currently supports JSON as a structured data format.</p> </note> <p>Specify the desired state as one of the following:</p> <ul> <li> <p>A JSON blob</p> </li> <li> <p>A local path containing the desired state in JSON data format</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-create.html#resource-operations-create-desiredstate">Composing the desired state of the resource</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p> <p>For more information about the properties of a specific resource, refer to the related topic for the resource in the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html">Resource and property types reference</a> in the <i>CloudFormation Users Guide</i>.</p>

    Raises:
        capo_cloudcontrol.errors.already_exists_exception.AlreadyExistsException: <p>The resource with the name requested already exists.</p>
        capo_cloudcontrol.errors.client_token_conflict_exception.ClientTokenConflictException: <p>The specified client token has already been used in another resource request.</p> <p>It's best practice for client tokens to be unique for each resource operation request. However, client token expire after 36 hours.</p>
        capo_cloudcontrol.errors.concurrent_operation_exception.ConcurrentOperationException: <p>Another resource operation is currently being performed on this resource.</p>
        capo_cloudcontrol.errors.general_service_exception.GeneralServiceException: <p>The resource handler has returned that the downstream service generated an error that doesn't map to any other handler error code.</p>
        capo_cloudcontrol.errors.handler_failure_exception.HandlerFailureException: <p>The resource handler has failed without a returning a more specific error code. This can include timeouts.</p>
        capo_cloudcontrol.errors.handler_internal_failure_exception.HandlerInternalFailureException: <p>The resource handler has returned that an unexpected error occurred within the resource handler.</p>
        capo_cloudcontrol.errors.invalid_credentials_exception.InvalidCredentialsException: <p>The resource handler has returned that the credentials provided by the user are invalid.</p>
        capo_cloudcontrol.errors.invalid_request_exception.InvalidRequestException: <p>The resource handler has returned that invalid input from the user has generated a generic exception.</p>
        capo_cloudcontrol.errors.network_failure_exception.NetworkFailureException: <p>The resource handler has returned that the request couldn't be completed due to networking issues, such as a failure to receive a response from the server.</p>
        capo_cloudcontrol.errors.not_stabilized_exception.NotStabilizedException: <p>The resource handler has returned that the downstream resource failed to complete all of its ready-state checks.</p>
        capo_cloudcontrol.errors.not_updatable_exception.NotUpdatableException: <p>One or more properties included in this resource operation are defined as create-only, and therefore can't be updated.</p>
        capo_cloudcontrol.errors.private_type_exception.PrivateTypeException: <p>Cloud Control API hasn't received a valid response from the resource handler, due to a configuration error. This includes issues such as the resource handler returning an invalid response, or timing out.</p>
        capo_cloudcontrol.errors.resource_conflict_exception.ResourceConflictException: <p>The resource is temporarily unavailable to be acted upon. For example, if the resource is currently undergoing an operation and can't be acted upon until that operation is finished.</p>
        capo_cloudcontrol.errors.resource_not_found_exception.ResourceNotFoundException: <p>A resource with the specified identifier can't be found.</p>
        capo_cloudcontrol.errors.service_internal_error_exception.ServiceInternalErrorException: <p>The resource handler has returned that the downstream service returned an internal error, typically with a <code>5XX HTTP</code> status code.</p>
        capo_cloudcontrol.errors.service_limit_exceeded_exception.ServiceLimitExceededException: <p>The resource handler has returned that a non-transient resource limit was reached on the service side.</p>
        capo_cloudcontrol.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_cloudcontrol.errors.type_not_found_exception.TypeNotFoundException: <p>The specified extension doesn't exist in the CloudFormation registry.</p>
        capo_cloudcontrol.errors.unsupported_action_exception.UnsupportedActionException: <p>The specified resource doesn't support this resource operation.</p>
        capo_cloudcontrol.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudcontrol.types.create_resource_input.CreateResourceInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudcontrol.types.create_resource_output.CreateResourceOutput"
    ]:
        import capo_cloudcontrol._operations.cloud_api_service.create_resource

        (
            output,
            http_response,
        ) = await capo_cloudcontrol._operations.cloud_api_service.create_resource.async_create_resource(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloudcontrol.types.create_resource_input.CreateResourceInput",
    ) -> dict[str, Any]:
        import capo_cloudcontrol.types.create_resource_input

        return capo_cloudcontrol.types.create_resource_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_cloudcontrol.types.create_resource_output.CreateResourceOutput",
    ) -> dict[str, Any]:
        import capo_cloudcontrol.types.create_resource_output

        return capo_cloudcontrol.types.create_resource_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateResource",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cloudcontrol.types.create_resource_input.CreateResourceInput = {
        "type_name": type_name,
        "desired_state": desired_state,
    }
    if type_version_id is not None:
        input_["type_version_id"] = type_version_id
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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