"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginAccessIdentity=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cloudfront_generated_1=require("./cloudfront.generated"),iam=require("../../aws-iam"),cdk=require("../../core");class OriginAccessIdentityBase extends cdk.Resource{arn(){return cdk.Stack.of(this).formatArn({service:"iam",region:"",account:"cloudfront",resource:"user",resourceName:`CloudFront Origin Access Identity ${this.originAccessIdentityId}`})}}class OriginAccessIdentity extends OriginAccessIdentityBase{static fromOriginAccessIdentityName(scope,id,originAccessIdentityName){try{jsiiDeprecationWarnings.print("aws-cdk-lib.aws_cloudfront.OriginAccessIdentity#fromOriginAccessIdentityName","use `fromOriginAccessIdentityId`")}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromOriginAccessIdentityName),error}return OriginAccessIdentity.fromOriginAccessIdentityId(scope,id,originAccessIdentityName)}static fromOriginAccessIdentityId(scope,id,originAccessIdentityId){class Import extends OriginAccessIdentityBase{constructor(s,i){super(s,i,{physicalName:originAccessIdentityId}),this.originAccessIdentityId=originAccessIdentityId,this.originAccessIdentityName=originAccessIdentityId,this.grantPrincipal=new iam.ArnPrincipal(this.arn())}}return new Import(scope,id)}get originAccessIdentityName(){try{jsiiDeprecationWarnings.print("aws-cdk-lib.aws_cloudfront.OriginAccessIdentity#originAccessIdentityName","use originAccessIdentityId instead")}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,jsiiDeprecationWarnings.getPropertyDescriptor(this,"originAccessIdentityName").get),error}return this.originAccessIdentityId}constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_cloudfront_OriginAccessIdentityProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,OriginAccessIdentity),error}const comment=(props?.comment??"Allows CloudFront to reach the bucket").slice(0,128);this.resource=new cloudfront_generated_1.CfnCloudFrontOriginAccessIdentity(this,"Resource",{cloudFrontOriginAccessIdentityConfig:{comment}}),this.originAccessIdentityId=this.getResourceNameAttribute(this.resource.ref),this.cloudFrontOriginAccessIdentityS3CanonicalUserId=this.resource.attrS3CanonicalUserId,this.grantPrincipal=new iam.CanonicalUserPrincipal(this.cloudFrontOriginAccessIdentityS3CanonicalUserId)}}exports.OriginAccessIdentity=OriginAccessIdentity,_a=JSII_RTTI_SYMBOL_1,OriginAccessIdentity[_a]={fqn:"aws-cdk-lib.aws_cloudfront.OriginAccessIdentity",version:"2.96.1"};
