Amazon S3 Glacier¶
Amazon Glacier is a secure, durable, and extremely low-cost Amazon S3 cloud storage class for data archiving and long-term backup.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AWS Console or AWS CLI.
Install API libraries via pip.
pip install 'apache-airflow[amazon]'Detailed information is available Installation of Airflow™
Generic Parameters¶
- aws_conn_id
Reference to Amazon Web Services Connection ID. If this parameter is set to
None
then the default boto3 behaviour is used without a connection lookup. Otherwise use the credentials stored in the Connection. Default:aws_default
- region_name
AWS Region Name. If this parameter is set to
None
or omitted then region_name from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
- verify
Whether or not to verify SSL certificates.
False
- Do not validate SSL certificates.path/to/cert/bundle.pem - A filename of the CA cert bundle to use. You can specify this argument if you want to use a different CA cert bundle than the one used by botocore.
If this parameter is set to
None
or is omitted then verify from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
- botocore_config
The provided dictionary is used to construct a botocore.config.Config. This configuration can be used to configure Avoid Throttling exceptions, timeouts, etc.
{ "signature_version": "unsigned", "s3": { "us_east_1_regional_endpoint": True, }, "retries": { "mode": "standard", "max_attempts": 10, }, "connect_timeout": 300, "read_timeout": 300, "tcp_keepalive": True, }
If this parameter is set to
None
or omitted then config_kwargs from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
Note
Specifying an empty dictionary,
{}
, will overwrite the connection configuration for botocore.config.Config
Operators¶
Create an Amazon Glacier job¶
To initiate an Amazon Glacier inventory retrieval job
use GlacierCreateJobOperator
This Operator returns a dictionary of information related to the initiated job such as jobId, which is required for subsequent tasks.
create_glacier_job = GlacierCreateJobOperator(task_id="create_glacier_job", vault_name=vault_name)
JOB_ID = '{{ task_instance.xcom_pull("create_glacier_job")["jobId"] }}'
Upload archive to an Amazon Glacier¶
To add an archive to an Amazon S3 Glacier vault
use GlacierUploadArchiveOperator
upload_archive_to_glacier = GlacierUploadArchiveOperator(
task_id="upload_data_to_glacier", vault_name=vault_name, body=b"Test Data"
)
Sensors¶
Wait on an Amazon Glacier job state¶
To wait on the status of an Amazon Glacier Job to reach a terminal state
use GlacierJobOperationSensor
wait_for_operation_complete = GlacierJobOperationSensor(
vault_name=vault_name,
job_id=JOB_ID,
task_id="wait_for_operation_complete",
)