"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"),iam=require("../../aws-iam"),cdk=require("../../core"),cloudfront_generated_1=require("./cloudfront.generated");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.originAccessIdentityName}`})}}class OriginAccessIdentity extends OriginAccessIdentityBase{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.originAccessIdentityName=this.getResourceNameAttribute(this.resource.ref),this.cloudFrontOriginAccessIdentityS3CanonicalUserId=this.resource.attrS3CanonicalUserId,this.grantPrincipal=new iam.CanonicalUserPrincipal(this.cloudFrontOriginAccessIdentityS3CanonicalUserId)}static fromOriginAccessIdentityName(scope,id,originAccessIdentityName){class Import extends OriginAccessIdentityBase{constructor(s,i){super(s,i,{physicalName:originAccessIdentityName}),this.originAccessIdentityName=originAccessIdentityName,this.grantPrincipal=new iam.ArnPrincipal(this.arn())}}return new Import(scope,id)}}exports.OriginAccessIdentity=OriginAccessIdentity,_a=JSII_RTTI_SYMBOL_1,OriginAccessIdentity[_a]={fqn:"aws-cdk-lib.aws_cloudfront.OriginAccessIdentity",version:"2.29.0"};
//# sourceMappingURL=origin-access-identity.js.map
