aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 3.08 kB
JavaScript
;var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DropSpamReceiptRule=exports.ReceiptRule=exports.TlsPolicy=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),path=require("path"),iam=require("../../aws-iam"),lambda=require("../../aws-lambda"),core_1=require("../../core"),constructs_1=require("constructs"),ses_generated_1=require("./ses.generated");var TlsPolicy;(function(TlsPolicy2){TlsPolicy2.OPTIONAL="Optional",TlsPolicy2.REQUIRE="Require"})(TlsPolicy=exports.TlsPolicy||(exports.TlsPolicy={}));class ReceiptRule extends core_1.Resource{constructor(scope,id,props){super(scope,id,{physicalName:props.receiptRuleName}),this.actions=new Array;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_ReceiptRuleProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ReceiptRule),error}const resource=new ses_generated_1.CfnReceiptRule(this,"Resource",{after:props.after?.receiptRuleName,rule:{actions:core_1.Lazy.any({produce:()=>this.renderActions()}),enabled:props.enabled??!0,name:this.physicalName,recipients:props.recipients,scanEnabled:props.scanEnabled,tlsPolicy:props.tlsPolicy},ruleSetName:props.ruleSet.receiptRuleSetName});this.receiptRuleName=resource.ref;for(const action of props.actions||[])this.addAction(action)}static fromReceiptRuleName(scope,id,receiptRuleName){class Import extends core_1.Resource{constructor(){super(...arguments),this.receiptRuleName=receiptRuleName}}return new Import(scope,id)}addAction(action){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_IReceiptRuleAction(action)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addAction),error}this.actions.push(action.bind(this))}renderActions(){if(this.actions.length!==0)return this.actions}}exports.ReceiptRule=ReceiptRule,_a=JSII_RTTI_SYMBOL_1,ReceiptRule[_a]={fqn:"aws-cdk-lib.aws_ses.ReceiptRule",version:"2.70.0"};class DropSpamReceiptRule extends constructs_1.Construct{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ses_DropSpamReceiptRuleProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DropSpamReceiptRule),error}const fn=new lambda.SingletonFunction(this,"Function",{runtime:lambda.Runtime.NODEJS_14_X,handler:"index.handler",code:lambda.Code.fromAsset(path.join(__dirname,"drop-spam-handler")),uuid:"224e77f9-a32e-4b4d-ac32-983477abba16"});fn.addPermission("AllowSes",{action:"lambda:InvokeFunction",principal:new iam.ServicePrincipal("ses.amazonaws.com"),sourceAccount:core_1.Aws.ACCOUNT_ID}),this.rule=new ReceiptRule(this,"Rule",{actions:[{bind:()=>({lambdaAction:{functionArn:fn.functionArn,invocationType:"RequestResponse"}})}],scanEnabled:!0,ruleSet:props.ruleSet})}}exports.DropSpamReceiptRule=DropSpamReceiptRule,_b=JSII_RTTI_SYMBOL_1,DropSpamReceiptRule[_b]={fqn:"aws-cdk-lib.aws_ses.DropSpamReceiptRule",version:"2.70.0"};