Created
March 2, 2022 17:59
-
-
Save findtharun/41080434eb0858439db911ad426a8075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import boto3 | |
from botocore.exceptions import ClientError | |
logger = logging.getLogger(__name__) | |
glacier=boto3.resource('glacier') | |
# Create a Vault | |
def create_vault(vault_name): | |
try: | |
vault= glacier.create_vault(vaultName=vault_name) | |
return vault | |
except ClientError: | |
logger.exception("Couldn't create vault %s.", vault_name) | |
raise | |
# # vault_name = "tharun-test-vault" | |
vault= create_vault("tharun-test-vault") | |
print(vault) | |
with open('upload_file_to_glacier.py', 'rb') as upload_file: | |
archive = vault.upload_archive(vaultName=vault.name,archiveDescription='Upload file Test', body=upload_file) | |
print(archive) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment