"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArchiveBucket = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
const defaults = {
    blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
    deepArchive: false,
};
class ArchiveBucket extends aws_cdk_lib_1.aws_s3.Bucket {
    /**
     * Class is designed to create a Glacier or Deep Archive archival system - immediately transitioning
     * objects from S3 to Glacier upon deposit. This is not designed to leave objects
     * in S3, and should not be leveraged for a tiered storage system as no objects should
     * remain in S3. It is merely designed to provide a mechanism to easily deposit items
     * into an Archive, which could be via console, CLI, or an API
     */
    constructor(scope, id, props) {
        super(scope, id, { ...defaults, ...props });
        const storageClass = props && props.deepArchive === true ? aws_cdk_lib_1.aws_s3.StorageClass.DEEP_ARCHIVE : aws_cdk_lib_1.aws_s3.StorageClass.GLACIER;
        this.addLifecycleRule({
            transitions: [
                {
                    storageClass,
                    transitionAfter: aws_cdk_lib_1.Duration.hours(0),
                },
            ],
        });
    }
}
exports.ArchiveBucket = ArchiveBucket;
