Use this action to manage storage for your file system. A LifecycleConfiguration consists of one or more LifecyclePolicy objects that define the following:
-
TransitionToIA – When to move files in the file system from primary storage (Standard storage class) into the Infrequent Access (IA) storage.
-
TransitionToArchive – When to move files in the file system from their current storage class (either IA or Standard storage) into the Archive storage.
File systems cannot transition into Archive storage before transitioning into IA storage. Therefore, TransitionToArchive must either not be set or must be later than TransitionToIA.
The Archive storage class is available only for file systems that use the Elastic throughput mode and the General Purpose performance mode.
For more information, see Managing file system storage.
Each Amazon EFS file system supports one lifecycle configuration, which applies to all files in the file system. If a LifecycleConfiguration object already exists for the specified file system, a PutLifecycleConfiguration call modifies the existing configuration. A PutLifecycleConfiguration call with an empty LifecyclePolicies array in the request body deletes any existing LifecycleConfiguration. In the request, specify the following:
-
The ID for the file system for which you are enabling, disabling, or modifying lifecycle management.
-
A LifecyclePolicies array of LifecyclePolicy objects that define when to move files to IA storage, to Archive storage, and back to primary storage.
Amazon EFS requires that each LifecyclePolicy object have only have a single transition, so the LifecyclePolicies array needs to be structured with separate LifecyclePolicy objects. See the example requests in the following section for more information.
This operation requires permissions for the elasticfilesystem:PutLifecycleConfiguration operation.
To apply a LifecycleConfiguration object to an encrypted file system, you need the same Key Management Service permissions as when you created the encrypted file system.
Parameters:
-
file_system_id
(FileSystemId)
–
The ID of the file system for which you are creating the LifecycleConfiguration object (String).
-
lifecycle_policies
(LifecyclePolicies)
–
An array of LifecyclePolicy objects that define the file system's LifecycleConfiguration object. A LifecycleConfiguration object informs lifecycle management of the following:
-
TransitionToIA – When to move files in the file system from primary storage (Standard storage class) into the Infrequent Access (IA) storage.
-
TransitionToArchive – When to move files in the file system from their current storage class (either IA or Standard storage) into the Archive storage.
File systems cannot transition into Archive storage before transitioning into IA storage. Therefore, TransitionToArchive must either not be set or must be later than TransitionToIA.
The Archive storage class is available only for file systems that use the Elastic throughput mode and the General Purpose performance mode.
-
TransitionToPrimaryStorageClass – Whether to move files in the file system back to primary storage (Standard storage class) after they are accessed in IA or Archive storage.
When using the put-lifecycle-configuration CLI command or the PutLifecycleConfiguration API action, Amazon EFS requires that each LifecyclePolicy object have only a single transition. This means that in a request body, LifecyclePolicies must be structured as an array of LifecyclePolicy objects, one object for each storage transition. See the example requests in the following section for more information.
Raises:
-
BadRequest
–
Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.
-
FileSystemNotFound
–
Returned if the specified FileSystemId value doesn't exist in the requester's Amazon Web Services account.
-
IncorrectFileSystemLifeCycleState
–
Returned if the file system's lifecycle state is not "available".
-
InternalServerError
–
Returned if an error occurred on the server side.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
Creates a new lifecycleconfiguration object for a file system
This operation enables lifecycle management on a file system by creating a new LifecycleConfiguration object. A LifecycleConfiguration object defines when files in an Amazon EFS file system are automatically transitioned to the lower-cost EFS Infrequent Access (IA) storage class. A LifecycleConfiguration applies to all files in a file system.
>>> client.put_lifecycle_configuration(file_system_id='fs-01234567', lifecycle_policies=[{'TransitionToIA': 'AFTER_30_DAYS'}])
Source code in docs_src/capo_efs/_services/efs.py
| def put_lifecycle_configuration(
self,
file_system_id: "capo_efs.types.file_system_id.FileSystemId",
lifecycle_policies: "capo_efs.types.lifecycle_policies.LifecyclePolicies",
*,
config_overrides: Optional[EFSClientConfig] = None,
) -> "capo_efs.types.lifecycle_configuration_description.LifecycleConfigurationDescription":
"""<p>Use this action to manage storage for your file system. A <code>LifecycleConfiguration</code> consists of one or more <code>LifecyclePolicy</code> objects that define the following:</p> <ul> <li> <p> <b> <code>TransitionToIA</code> </b> – When to move files in the file system from primary storage (Standard storage class) into the Infrequent Access (IA) storage.</p> </li> <li> <p> <b> <code>TransitionToArchive</code> </b> – When to move files in the file system from their current storage class (either IA or Standard storage) into the Archive storage.</p> <p>File systems cannot transition into Archive storage before transitioning into IA storage. Therefore, TransitionToArchive must either not be set or must be later than TransitionToIA.</p> <note> <p> The Archive storage class is available only for file systems that use the Elastic throughput mode and the General Purpose performance mode. </p> </note> </li> </ul> <ul> <li> <p> <b> <code>TransitionToPrimaryStorageClass</code> </b> – Whether to move files in the file system back to primary storage (Standard storage class) after they are accessed in IA or Archive storage.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/efs/latest/ug/lifecycle-management-efs.html"> Managing file system storage</a>.</p> <p>Each Amazon EFS file system supports one lifecycle configuration, which applies to all files in the file system. If a <code>LifecycleConfiguration</code> object already exists for the specified file system, a <code>PutLifecycleConfiguration</code> call modifies the existing configuration. A <code>PutLifecycleConfiguration</code> call with an empty <code>LifecyclePolicies</code> array in the request body deletes any existing <code>LifecycleConfiguration</code>. In the request, specify the following: </p> <ul> <li> <p>The ID for the file system for which you are enabling, disabling, or modifying lifecycle management.</p> </li> <li> <p>A <code>LifecyclePolicies</code> array of <code>LifecyclePolicy</code> objects that define when to move files to IA storage, to Archive storage, and back to primary storage.</p> <note> <p>Amazon EFS requires that each <code>LifecyclePolicy</code> object have only have a single transition, so the <code>LifecyclePolicies</code> array needs to be structured with separate <code>LifecyclePolicy</code> objects. See the example requests in the following section for more information.</p> </note> </li> </ul> <p>This operation requires permissions for the <code>elasticfilesystem:PutLifecycleConfiguration</code> operation.</p> <p>To apply a <code>LifecycleConfiguration</code> object to an encrypted file system, you need the same Key Management Service permissions as when you created the encrypted file system.</p>
Args:
file_system_id: <p>The ID of the file system for which you are creating the <code>LifecycleConfiguration</code> object (String).</p>
lifecycle_policies: <p>An array of <code>LifecyclePolicy</code> objects that define the file system's <code>LifecycleConfiguration</code> object. A <code>LifecycleConfiguration</code> object informs lifecycle management of the following:</p> <ul> <li> <p> <b> <code>TransitionToIA</code> </b> – When to move files in the file system from primary storage (Standard storage class) into the Infrequent Access (IA) storage.</p> </li> <li> <p> <b> <code>TransitionToArchive</code> </b> – When to move files in the file system from their current storage class (either IA or Standard storage) into the Archive storage.</p> <p>File systems cannot transition into Archive storage before transitioning into IA storage. Therefore, TransitionToArchive must either not be set or must be later than TransitionToIA.</p> <note> <p>The Archive storage class is available only for file systems that use the Elastic throughput mode and the General Purpose performance mode. </p> </note> </li> <li> <p> <b> <code>TransitionToPrimaryStorageClass</code> </b> – Whether to move files in the file system back to primary storage (Standard storage class) after they are accessed in IA or Archive storage.</p> </li> </ul> <note> <p>When using the <code>put-lifecycle-configuration</code> CLI command or the <code>PutLifecycleConfiguration</code> API action, Amazon EFS requires that each <code>LifecyclePolicy</code> object have only a single transition. This means that in a request body, <code>LifecyclePolicies</code> must be structured as an array of <code>LifecyclePolicy</code> objects, one object for each storage transition. See the example requests in the following section for more information.</p> </note>
Raises:
capo_efs.errors.bad_request.BadRequest: <p>Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.</p>
capo_efs.errors.file_system_not_found.FileSystemNotFound: <p>Returned if the specified <code>FileSystemId</code> value doesn't exist in the requester's Amazon Web Services account.</p>
capo_efs.errors.incorrect_file_system_life_cycle_state.IncorrectFileSystemLifeCycleState: <p>Returned if the file system's lifecycle state is not "available".</p>
capo_efs.errors.internal_server_error.InternalServerError: <p>Returned if an error occurred on the server side.</p>
capo_efs.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
Creates a new lifecycleconfiguration object for a file system
This operation enables lifecycle management on a file system by creating a new LifecycleConfiguration object. A LifecycleConfiguration object defines when files in an Amazon EFS file system are automatically transitioned to the lower-cost EFS Infrequent Access (IA) storage class. A LifecycleConfiguration applies to all files in a file system.
>>> client.put_lifecycle_configuration(file_system_id='fs-01234567', lifecycle_policies=[{'TransitionToIA': 'AFTER_30_DAYS'}])
"""
def _handler(
req: "OperationRequest[capo_efs.types.put_lifecycle_configuration_request.PutLifecycleConfigurationRequest]",
) -> OperationResponse[
"capo_efs.types.lifecycle_configuration_description.LifecycleConfigurationDescription"
]:
import capo_efs._operations.magnolio_api_service_v20150201.put_lifecycle_configuration
output, http_response = (
capo_efs._operations.magnolio_api_service_v20150201.put_lifecycle_configuration.put_lifecycle_configuration(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutLifecycleConfiguration")
)
input_: capo_efs.types.put_lifecycle_configuration_request.PutLifecycleConfigurationRequest = {
"file_system_id": file_system_id,
"lifecycle_policies": lifecycle_policies,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|