Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)
edited by

I want to create a zip artefact for my nodejs lambda through aws codebuild process - so that lambda function can use this zip file as a source in S3 and we have a deployment "proof" for management with git commit id in codebuild 

my file structure in github-repo is


   - myfile.js

   - otherfile.js


   - otherfiles.js


now for nodejs lambda project, I want zip file without the folder in zip (we need that for nodejs project in lambda) so zip should directly contain following files

- myfile.js

- node_module ==> folder from codebuild via npm install command 


1) output zip in S3 contains in folder i.e .zip->rootfolder->myfile.js rather than we require .zip->myfiles.js this is not usable by lambda as for nodejs it should have files in root zip and not inside them (no relative path inside folder) 

2) paths - as you can see myfile.js is inside a folder I want to relative path to be omitted - I tried to discard path but problem with that is all the node_module files are also in folder rather than in folder as discard path applies to both of them - Can I set discard path only for myfile.js and not for node_module folder ?? my current YAML file: 



    - folder/myfile.js

    - node_modules/**/*

  discard-paths: yes 

It would be great if someone can provide a solution to this? 

It would be great if the solution does not contain changing github-repo folder structure and I want to repeat this for other files too in that repo for creating other lambda functions.

1 Answer

0 votes
by (44.3k points)

Copy the needed files to a new folder as the part of your build (buildspec.yml) and specify it in artifacts section. This is a sample:



      - mkdir build-output

      - cp -R folder/myfile.js node_modules/ build-output



    - build-output/**/*

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories