"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CloudWatchLogGroup=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),iam=require("../../aws-iam"),cdk=require("../../core"),core_1=require("../../core"),log_group_resource_policy_1=require("./log-group-resource-policy"),util_1=require("./util");class CloudWatchLogGroup{constructor(logGroup,props={}){this.logGroup=logGroup,this.props=props;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_logs_ILogGroup(logGroup),jsiiDeprecationWarnings.aws_cdk_lib_aws_events_targets_LogGroupProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.constructor),error}}bind(_rule,_id){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_events_IRule(_rule)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const resourcePolicyId=`EventsLogGroupPolicy${cdk.Names.nodeUniqueId(_rule.node)}`,logGroupStack=cdk.Stack.of(this.logGroup);return this.logGroup.node.tryFindChild(resourcePolicyId)||new log_group_resource_policy_1.LogGroupResourcePolicy(logGroupStack,resourcePolicyId,{policyStatements:[new iam.PolicyStatement({effect:iam.Effect.ALLOW,actions:["logs:PutLogEvents","logs:CreateLogStream"],resources:[this.logGroup.logGroupArn],principals:[new iam.ServicePrincipal("events.amazonaws.com")]})]}),{...util_1.bindBaseTargetConfig(this.props),arn:logGroupStack.formatArn({service:"logs",resource:"log-group",arnFormat:core_1.ArnFormat.COLON_RESOURCE_NAME,resourceName:this.logGroup.logGroupName}),input:this.props.event,targetResource:this.logGroup}}}exports.CloudWatchLogGroup=CloudWatchLogGroup,_a=JSII_RTTI_SYMBOL_1,CloudWatchLogGroup[_a]={fqn:"aws-cdk-lib.aws_events_targets.CloudWatchLogGroup",version:"2.24.1"};
//# sourceMappingURL=log-group.js.map
