"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BucketPolicy=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),aws_iam_1=require("../../aws-iam"),core_1=require("../../core"),s3_generated_1=require("./s3.generated");class BucketPolicy extends core_1.Resource{constructor(scope,id,props){super(scope,id),this.document=new aws_iam_1.PolicyDocument;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_s3_BucketPolicyProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}if(!props.bucket.bucketName)throw new Error("Bucket doesn't have a bucketName defined");this.resource=new s3_generated_1.CfnBucketPolicy(this,"Resource",{bucket:props.bucket.bucketName,policyDocument:this.document}),props.removalPolicy&&this.resource.applyRemovalPolicy(props.removalPolicy)}applyRemovalPolicy(removalPolicy){try{jsiiDeprecationWarnings.aws_cdk_lib_RemovalPolicy(removalPolicy)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.applyRemovalPolicy),error}this.resource.applyRemovalPolicy(removalPolicy)}}exports.BucketPolicy=BucketPolicy,_a=JSII_RTTI_SYMBOL_1,BucketPolicy[_a]={fqn:"aws-cdk-lib.aws_s3.BucketPolicy",version:"2.24.1"};
//# sourceMappingURL=bucket-policy.js.map
