def main():
    args = _parse_args()
    logging.info("Parsed cli args: %s", vars(args))

    checksum_files = []
    if args.integrity_check:
        checksum_files = list(
            map(lambda f: f"{f}.{args.integrity_check}", args.src_files))

    logging.info("Retrieving STS credentials")
    sts_credentials = retrieve_sts_credentials(
        args.credentials, PARTITION_TO_MAIN_REGION[args.partition],
        args.regions)

    logging.info("Generating rollback data")
    rollback_data = generate_rollback_data(args.regions, args.dest_bucket,
                                           args.src_files + checksum_files,
                                           sts_credentials)

    with tempfile.TemporaryDirectory() as temp_dir:
        logging.info("Created temporary directory %s", temp_dir)
        logging.info("Downloading the data")
        _download_files(args, temp_dir)
        logging.info(
            "Checking S3 versioning is enabled in destination bucket before proceeding"
        )
        _check_buckets_versioning(args, sts_credentials)
        logging.info("Copying files")
        _upload_files(args, args.src_files + checksum_files, sts_credentials,
                      temp_dir)
        if args.deploy:
            logging.info("Validating uploaded files")
            _validate_uploaded_files(args, args.src_files + checksum_files,
                                     rollback_data)
Пример #2
0
def main():
    args = _parse_args()
    logging.info("Parsed cli args: %s", vars(args))

    sts_credentials = retrieve_sts_credentials(args.credentials, PARTITION_TO_MAIN_REGION[args.partition], args.regions)

    if args.rollback_file_path:
        execute_rollback(args.rollback_file_path, sts_credentials, args.deploy)
    else:
        logging.info("Generating all documents to upload")
        files_to_upload = _generate_docs(args, sts_credentials)

        logging.info("Validating all documents to upload")
        _validate_documents_against_existing_version(args, files_to_upload, sts_credentials)

        logging.info("Generating rollback data")
        generate_rollback_data(args.regions, args.bucket, files_to_upload, sts_credentials)

        logging.info("Uploading documents...")
        _upload_documents(args, files_to_upload, sts_credentials)

        logging.info(
            "Summary of uploaded docs:\n%s",
            json.dumps({k: list(v.keys()) for k, v in files_to_upload.items()}, indent=2),
        )
        if not args.deploy:
            logging.warning(
                "Documents not uploaded since --deploy flag not specified. Rerun with --deploy flag to upload"
            )
Пример #3
0
def main():
    args = _parse_args()
    logging.info("Parsed cli args: %s", vars(args))

    regions = set()
    with open(args.rollback_file_path) as rollback_file:
        rollback_data = json.load(rollback_file)
        for bucket in rollback_data.keys():
            regions.add(rollback_data[bucket]["region"])

    sts_credentials = retrieve_sts_credentials(args.credentials, PARTITION_TO_MAIN_REGION[args.partition], regions)
    execute_rollback(args.rollback_file_path, sts_credentials, args.deploy)