"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArtifactBucket = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
const defaults = {
    blockPublicAccess: aws_cdk_lib_1.aws_s3.BlockPublicAccess.BLOCK_ALL,
    removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
    autoDeleteObjects: true,
};
class ArtifactBucket extends aws_cdk_lib_1.aws_s3.Bucket {
    /**
     *
     * Class is designed to create a standard bucket for holding
     * built artifacts from CodeBuild or CodePipeline.
     * It is a fairly standard item and needed for any project with CI/CD,
     * so it is a good idea to create a construct to ensure that this is done
     * in the same way with each project.
     */
    constructor(scope, id, props) {
        super(scope, id, { ...defaults, ...props });
        this.addToResourcePolicy(new aws_cdk_lib_1.aws_iam.PolicyStatement({
            principals: [new aws_cdk_lib_1.aws_iam.AnyPrincipal()],
            effect: aws_cdk_lib_1.aws_iam.Effect.DENY,
            actions: ['s3:*'],
            conditions: {
                Bool: { 'aws:SecureTransport': false },
            },
            resources: [this.bucketArn + '/*'],
        }));
    }
}
exports.ArtifactBucket = ArtifactBucket;
