- AWS Code Sample demonstrates how to create an Amazon S3 Glacier vault.

# Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of the # License is located at # # # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS # OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. import logging import boto3 from botocore.exceptions import ClientError def create_vault(vault_name): """Create an Amazon Glacier vault. :param vault_name: string :return: glacier.Vault object if vault was created, otherwise None """ glacier = boto3.resource('glacier') try: vault = glacier.create_vault(vaultName=vault_name) except ClientError as e: logging.error(e) return None return vault def main(): """ Exercise create_vault()""" # Assign this value before running the program test_vault_name = 'VAULT_NAME' # Set up logging logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(asctime)s: %(message)s') # Create the Glacier vault vault = create_vault(test_vault_name) if vault is not None:'Created vault {}') if __name__ == '__main__': main()

Sample Details

Service: glacier

Last tested: 2019-2-12

Author: AWS

Type: full-example