"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.S3=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};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,S3),error}}bind(rule){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).addWarningV2("@aws-cdk/s3:AddBucketPermissions","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:this.props.kmsKey?.keyArn,objectKeyPrefix:this.props.objectKeyPrefix,topicArn:this.props.topic?.topicArn}}}}exports.S3=S3,_a=JSII_RTTI_SYMBOL_1,S3[_a]={fqn:"aws-cdk-lib.aws_ses_actions.S3",version:"2.148.1"};
