import { join } from "../Value";
export class Website {
    bucket;
    bucketPolicy;
    constructor(bucket, bucketPolicy) {
        this.bucket = bucket;
        this.bucketPolicy = bucketPolicy;
    }
    static create(aws, indexDocument = 'index.html', errorDocument = indexDocument) {
        const bucket = aws.s3.bucket({
            accessControl: 'PublicRead',
            websiteConfiguration: { indexDocument, errorDocument }
        });
        const policy = aws.s3.bucketPolicy({
            bucket: bucket,
            policyDocument: { statement: [{ action: 's3:GetObject', effect: 'Allow', resource: [join('arn:aws:s3:::', bucket, '/*')], principal: '*' }] }
        });
        return new Website(bucket, policy);
    }
}
