"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.S3=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),iam=require("../../aws-iam"),cdk=require("../../core");class S3{constructor(props){this.props=props;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_actions_S3Props(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}}bind(rule){var _b,_c;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_IReceiptRule(rule)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const keyPattern=this.props.objectKeyPrefix||"",s3Statement=new iam.PolicyStatement({actions:["s3:PutObject"],principals:[new iam.ServicePrincipal("ses.amazonaws.com")],resources:[this.props.bucket.arnForObjects(`${keyPattern}*`)],conditions:{StringEquals:{"aws:Referer":cdk.Aws.ACCOUNT_ID}}});this.props.bucket.addToResourcePolicy(s3Statement);const policy=this.props.bucket.node.tryFindChild("Policy");if(policy?rule.node.addDependency(policy):cdk.Annotations.of(rule).addWarning("This rule is using a S3 action with an imported bucket. Ensure permission is given to SES to write to that bucket."),this.props.kmsKey&&!/alias\/aws\/ses$/.test(this.props.kmsKey.keyArn)){const kmsStatement=new iam.PolicyStatement({actions:["kms:Encrypt","kms:GenerateDataKey"],principals:[new iam.ServicePrincipal("ses.amazonaws.com")],resources:["*"],conditions:{Null:{"kms:EncryptionContext:aws:ses:rule-name":"false","kms:EncryptionContext:aws:ses:message-id":"false"},StringEquals:{"kms:EncryptionContext:aws:ses:source-account":cdk.Aws.ACCOUNT_ID}}});this.props.kmsKey.addToResourcePolicy(kmsStatement)}return{s3Action:{bucketName:this.props.bucket.bucketName,kmsKeyArn:(_b=this.props.kmsKey)===null||_b===void 0?void 0:_b.keyArn,objectKeyPrefix:this.props.objectKeyPrefix,topicArn:(_c=this.props.topic)===null||_c===void 0?void 0:_c.topicArn}}}}exports.S3=S3,_a=JSII_RTTI_SYMBOL_1,S3[_a]={fqn:"aws-cdk-lib.aws_ses_actions.S3",version:"2.24.1"};
//# sourceMappingURL=s3.js.map
