aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 938 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Files=void 0;var s3assets=()=>{var tmp=require("../../../../aws-s3-assets");return s3assets=()=>tmp,tmp};class Files{static fromArtifact(artifact){if(!artifact)throw new Error("Files.fromArtifact(): input artifact is required, got undefined");return{bind:()=>({artifact}),grantRead:()=>{}}}static fromDirectory(directoryPath){let realFiles;return{bind(scope){return realFiles=Files.fromAsset(new(s3assets()).Asset(scope,directoryPath,{path:directoryPath})),realFiles.bind(scope)},grantRead(grantee){if(!realFiles)throw new Error("bind() must be called first");realFiles.grantRead(grantee)}}}static fromAsset(asset){return{bind:()=>({commands:[`echo "Downloading additional files from ${asset.s3ObjectUrl}"`,`aws s3 cp ${asset.s3ObjectUrl} /tmp/dl.zip`,"unzip /tmp/dl.zip -d ."]}),grantRead:grantee=>asset.grantRead(grantee)}}constructor(){}}exports.Files=Files;