2

I've been using AWS SAM without much issue for the last 6 months, with about 40 functions split across 4 projects.

Just today I was cleaning up some hard disk space and notice my codebase folder for one project was 4.5 gbs, and I realized it was the .aws-sam folder. Looking further, I could see a build folder inside, with each function storing the equivalent of every single dependency. I am wondering if I am doing something wrong, or if not, why is this necessary, considering I don't utilize this folder whatsoever when I'm building locally.

Michael Du
  • 669
  • 7
  • 15
  • 1
    Are you saying the local SAM utility cache is too much? Or the actual project? Each application would have some cache, I'm assuming it's just different versions of deployments. Just delete and recreate if you're not using it per se. We can't answer why a folder is taking up more space than "necessary" on your machine unless we can reproduce it accurately. – Ermiya Eskandary Mar 20 '22 at 15:08
  • So from my understanding, everytime I run a `sam build` the artifacts of the entire project including all the dependencies of every function is packaged up into .aws-sam/build, which is ultimately what gets deployed when i run `sam deploy`. My question s this folder is taking up 4.5gb for one project alone, so is there any use for keeping it around? Is it safe to just delete the entire folder after every deployment? – Michael Du Mar 20 '22 at 15:17
  • 1
    You should be fine yes, as long as your template stays where it is, feel free. – Ermiya Eskandary Mar 20 '22 at 15:18
  • Hi, @MichaelDu I've just realized I am facing the same issue. I am looking for a correct way to avoid or clean those files in `.aws-sam/deps/` directory. Please, did you find a solution to this issue? – Alexandre Barbosa Sep 03 '22 at 20:27
  • 1
    @AlexandreBarbosa I noticed that dependencies included in layers don't get generated as artifacts, so I eventually just dumped large and common dependencies into individual layers rather than include them in each individual project. – Michael Du Sep 04 '22 at 01:50

0 Answers0