Skip to content

create_file_cache

create_file_cache(
    *,
    config_overrides: Optional[FSxClientConfig] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    file_cache_type: Optional[FileCacheType] = None,
    file_cache_type_version: Optional[FileSystemTypeVersion] = None,
    storage_capacity: Optional[StorageCapacity] = None,
    subnet_ids: Optional[SubnetIds] = None,
    security_group_ids: Optional[SecurityGroupIds] = None,
    tags: Optional[Tags] = None,
    copy_tags_to_data_repository_associations: Optional[
        CopyTagsToDataRepositoryAssociations
    ] = None,
    kms_key_id: Optional[KmsKeyId] = None,
    lustre_configuration: Optional[CreateFileCacheLustreConfiguration] = None,
    data_repository_associations: Optional[
        CreateFileCacheDataRepositoryAssociations
    ] = None,
) -> CreateFileCacheResponse

Creates a new Amazon File Cache resource.

You can use this operation with a client request token in the request that Amazon File Cache uses to ensure idempotent creation. If a cache with the specified client request token exists and the parameters match, CreateFileCache returns the description of the existing cache. If a cache with the specified client request token exists and the parameters don't match, this call returns IncompatibleParameterError. If a file cache with the specified client request token doesn't exist, CreateFileCache does the following:

  • Creates a new, empty Amazon File Cache resource with an assigned ID, and an initial lifecycle state of CREATING.

  • Returns the description of the cache in JSON format.

The CreateFileCache call returns while the cache's lifecycle state is still CREATING. You can check the cache creation status by calling the DescribeFileCaches operation, which returns the cache state along with other information.

Parameters:

  • client_request_token (Optional[ClientRequestToken], default: None ) –

    An idempotency token for resource creation, in a string of up to 63 ASCII characters. This token is automatically filled on your behalf when you use the Command Line Interface (CLI) or an Amazon Web Services SDK.

    By using the idempotent operation, you can retry a CreateFileCache operation without the risk of creating an extra cache. This approach can be useful when an initial call fails in a way that makes it unclear whether a cache was created. Examples are if a transport level timeout occurred, or your connection was reset. If you use the same client request token and the initial call created a cache, the client receives success as long as the parameters are the same.

  • file_cache_type (Optional[FileCacheType], default: None ) –

    The type of cache that you're creating, which must be LUSTRE.

  • file_cache_type_version (Optional[FileSystemTypeVersion], default: None ) –

    Sets the Lustre version for the cache that you're creating, which must be 2.12.

  • storage_capacity (Optional[StorageCapacity], default: None ) –

    The storage capacity of the cache in gibibytes (GiB). Valid values are 1200 GiB, 2400 GiB, and increments of 2400 GiB.

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

    A list of IDs specifying the security groups to apply to all network interfaces created for Amazon File Cache access. This list isn't returned in later requests to describe the cache.

  • copy_tags_to_data_repository_associations (Optional[CopyTagsToDataRepositoryAssociations], default: None ) –

    A boolean flag indicating whether tags for the cache should be copied to data repository associations. This value defaults to false.

  • kms_key_id (Optional[KmsKeyId], default: None ) –

    Specifies the ID of the Key Management Service (KMS) key to use for encrypting data on an Amazon File Cache. If a KmsKeyId isn't specified, the Amazon FSx-managed KMS key for your account is used. For more information, see Encrypt in the Key Management Service API Reference.

  • lustre_configuration (Optional[CreateFileCacheLustreConfiguration], default: None ) –

    The configuration for the Amazon File Cache resource being created.

  • data_repository_associations (Optional[CreateFileCacheDataRepositoryAssociations], default: None ) –

    A list of up to 8 configurations for data repository associations (DRAs) to be created during the cache creation. The DRAs link the cache to either an Amazon S3 data repository or a Network File System (NFS) data repository that supports the NFSv3 protocol.

    The DRA configurations must meet the following requirements:

    • All configurations on the list must be of the same data repository type, either all S3 or all NFS. A cache can't link to different data repository types at the same time.

    • An NFS DRA must link to an NFS file system that supports the NFSv3 protocol.

    DRA automatic import and automatic export is not supported.

Raises:

  • BadRequest –

    A generic error indicating a failure with a client request.

  • IncompatibleParameterError –

    The error returned when a second request is received with the same client request token but different parameters settings. A client request token should always uniquely identify a single request.

  • InternalServerError –

    A generic error indicating a server-side failure.

  • InvalidNetworkSettings –

    One or more network settings specified in the request are invalid.

  • InvalidPerUnitStorageThroughput –

    An invalid value for PerUnitStorageThroughput was provided. Please create your file system again, using a valid value.

  • MissingFileCacheConfiguration –

    A cache configuration is required for this operation.

  • ServiceLimitExceeded –

    An error indicating that a particular service limit was exceeded. You can increase some service limits by contacting Amazon Web Services Support.

  • UnknownServiceError –

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

Source code in docs_src/capo_fsx/_services/f_sx.py
def create_file_cache(
    self,
    *,
    config_overrides: Optional[FSxClientConfig] = None,
    client_request_token: Optional[
        "capo_fsx.types.client_request_token.ClientRequestToken"
    ] = None,
    file_cache_type: Optional[
        "capo_fsx.types.file_cache_type.FileCacheType"
    ] = None,
    file_cache_type_version: Optional[
        "capo_fsx.types.file_system_type_version.FileSystemTypeVersion"
    ] = None,
    storage_capacity: Optional[
        "capo_fsx.types.storage_capacity.StorageCapacity"
    ] = None,
    subnet_ids: Optional["capo_fsx.types.subnet_ids.SubnetIds"] = None,
    security_group_ids: Optional[
        "capo_fsx.types.security_group_ids.SecurityGroupIds"
    ] = None,
    tags: Optional["capo_fsx.types.tags.Tags"] = None,
    copy_tags_to_data_repository_associations: Optional[
        "capo_fsx.types.copy_tags_to_data_repository_associations.CopyTagsToDataRepositoryAssociations"
    ] = None,
    kms_key_id: Optional["capo_fsx.types.kms_key_id.KmsKeyId"] = None,
    lustre_configuration: Optional[
        "capo_fsx.types.create_file_cache_lustre_configuration.CreateFileCacheLustreConfiguration"
    ] = None,
    data_repository_associations: Optional[
        "capo_fsx.types.create_file_cache_data_repository_associations.CreateFileCacheDataRepositoryAssociations"
    ] = None,
) -> "capo_fsx.types.create_file_cache_response.CreateFileCacheResponse":
    """<p>Creates a new Amazon File Cache resource.</p> <p>You can use this operation with a client request token in the request that Amazon File Cache uses to ensure idempotent creation. If a cache with the specified client request token exists and the parameters match, <code>CreateFileCache</code> returns the description of the existing cache. If a cache with the specified client request token exists and the parameters don't match, this call returns <code>IncompatibleParameterError</code>. If a file cache with the specified client request token doesn't exist, <code>CreateFileCache</code> does the following: </p> <ul> <li> <p>Creates a new, empty Amazon File Cache resource with an assigned ID, and an initial lifecycle state of <code>CREATING</code>.</p> </li> <li> <p>Returns the description of the cache in JSON format.</p> </li> </ul> <note> <p>The <code>CreateFileCache</code> call returns while the cache's lifecycle state is still <code>CREATING</code>. You can check the cache creation status by calling the <a href="https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileCaches.html">DescribeFileCaches</a> operation, which returns the cache state along with other information.</p> </note>

    Args:
        client_request_token: <p>An idempotency token for resource creation, in a string of up to 63 ASCII characters. This token is automatically filled on your behalf when you use the Command Line Interface (CLI) or an Amazon Web Services SDK.</p> <p>By using the idempotent operation, you can retry a <code>CreateFileCache</code> operation without the risk of creating an extra cache. This approach can be useful when an initial call fails in a way that makes it unclear whether a cache was created. Examples are if a transport level timeout occurred, or your connection was reset. If you use the same client request token and the initial call created a cache, the client receives success as long as the parameters are the same.</p>
        file_cache_type: <p>The type of cache that you're creating, which must be <code>LUSTRE</code>.</p>
        file_cache_type_version: <p>Sets the Lustre version for the cache that you're creating, which must be <code>2.12</code>.</p>
        storage_capacity: <p>The storage capacity of the cache in gibibytes (GiB). Valid values are 1200 GiB, 2400 GiB, and increments of 2400 GiB.</p>
        security_group_ids: <p>A list of IDs specifying the security groups to apply to all network interfaces created for Amazon File Cache access. This list isn't returned in later requests to describe the cache.</p>
        copy_tags_to_data_repository_associations: <p>A boolean flag indicating whether tags for the cache should be copied to data repository associations. This value defaults to false.</p>
        kms_key_id: <p>Specifies the ID of the Key Management Service (KMS) key to use for encrypting data on an Amazon File Cache. If a <code>KmsKeyId</code> isn't specified, the Amazon FSx-managed KMS key for your account is used. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html">Encrypt</a> in the <i>Key Management Service API Reference</i>.</p>
        lustre_configuration: <p>The configuration for the Amazon File Cache resource being created.</p>
        data_repository_associations: <p>A list of up to 8 configurations for data repository associations (DRAs) to be created during the cache creation. The DRAs link the cache to either an Amazon S3 data repository or a Network File System (NFS) data repository that supports the NFSv3 protocol.</p> <p>The DRA configurations must meet the following requirements:</p> <ul> <li> <p>All configurations on the list must be of the same data repository type, either all S3 or all NFS. A cache can't link to different data repository types at the same time.</p> </li> <li> <p>An NFS DRA must link to an NFS file system that supports the NFSv3 protocol.</p> </li> </ul> <p>DRA automatic import and automatic export is not supported.</p>

    Raises:
        capo_fsx.errors.bad_request.BadRequest: <p>A generic error indicating a failure with a client request.</p>
        capo_fsx.errors.incompatible_parameter_error.IncompatibleParameterError: <p>The error returned when a second request is received with the same client request token but different parameters settings. A client request token should always uniquely identify a single request.</p>
        capo_fsx.errors.internal_server_error.InternalServerError: <p>A generic error indicating a server-side failure.</p>
        capo_fsx.errors.invalid_network_settings.InvalidNetworkSettings: <p>One or more network settings specified in the request are invalid.</p>
        capo_fsx.errors.invalid_per_unit_storage_throughput.InvalidPerUnitStorageThroughput: <p>An invalid value for <code>PerUnitStorageThroughput</code> was provided. Please create your file system again, using a valid value.</p>
        capo_fsx.errors.missing_file_cache_configuration.MissingFileCacheConfiguration: <p>A cache configuration is required for this operation.</p>
        capo_fsx.errors.service_limit_exceeded.ServiceLimitExceeded: <p>An error indicating that a particular service limit was exceeded. You can increase some service limits by contacting Amazon Web Services Support.</p>
        capo_fsx.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_fsx.types.create_file_cache_request.CreateFileCacheRequest]",
    ) -> OperationResponse[
        "capo_fsx.types.create_file_cache_response.CreateFileCacheResponse"
    ]:
        import capo_fsx._operations.aws_simba_api_service_v20180301.create_file_cache

        output, http_response = (
            capo_fsx._operations.aws_simba_api_service_v20180301.create_file_cache.create_file_cache(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateFileCache")
    )
    input_: capo_fsx.types.create_file_cache_request.CreateFileCacheRequest = {}
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if file_cache_type is not None:
        input_["file_cache_type"] = file_cache_type
    if file_cache_type_version is not None:
        input_["file_cache_type_version"] = file_cache_type_version
    if storage_capacity is not None:
        input_["storage_capacity"] = storage_capacity
    if subnet_ids is not None:
        input_["subnet_ids"] = subnet_ids
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if tags is not None:
        input_["tags"] = tags
    if copy_tags_to_data_repository_associations is not None:
        input_["copy_tags_to_data_repository_associations"] = (
            copy_tags_to_data_repository_associations
        )
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if lustre_configuration is not None:
        input_["lustre_configuration"] = lustre_configuration
    if data_repository_associations is not None:
        input_["data_repository_associations"] = data_repository_associations

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output