title: How to use a specific version of aws-sdk in lambda function building by serverless and webpack?
body: <p>I need to use a higher version of aws-sdk than what lambda function provides by default. I am using serverless framework and webpack to build my serverless application. In serverless I can include or exclude dependencies in serverless.yml configuration:</p>
  
  <pre><code>package:
   individually: true
   include:
     - node_modules/aws-sdk
  </code></pre>
  
  <p>So I can provide my own aws-sdk in the package. But in my webpack config I have this configuration:</p>
  
  <pre><code>externals: [
     /aws-sdk/
  ],
  </code></pre>
  
  <p>which relies on aws-sdk on lambda container. When I remove this to not use the aws-sdk provided by lambda, I'm getting <code>JavaScript heap out of memory</code> error. What is the best way to accomplish this task?</p>
  
  <pre><code>    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation 
      failed - JavaScript heap out of memory
      1: 0x10003b125 node::Abort() [/usr/local/bin/node]
      2: 0x10003b32f node::OnFatalError(char const*, char const*) 
      [/usr/local/bin/node]
      3: 0x1001a8e85 
      v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char 
      const*, bool) [/usr/local/bin/node]
      4: 0x1005742a2 v8::internal::Heap::FatalProcessOutOfMemory(char 
      const*) [/usr/local/bin/node]
      5: 0x100576d75 
      v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) 
      [/usr/local/bin/node]
      6: 0x100572c1f 
   v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollect 
   .or, v8::GCCallbackFlags) [/usr/local/bin/node]
   7: 0x100570df4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
   8: 0x10057d68c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
   9: 0x10057d70f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
  10: 0x10054f594 v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
  11: 0x100681149 v8::internal::String::SlowFlatten(v8::internal::Handle&lt;v8::internal::ConsString&gt;, v8::internal::PretenureFlag) [/usr/local/bin/node]
  12: 0x1001c6c1d v8::String::Utf8Length() const [/usr/local/bin/node]
  13: 0x10004eaac node::Buffer::(anonymous namespace)::ByteLengthUtf8(v8::FunctionCallbackInfo&lt;v8::Value&gt; const&amp;) [/usr/local/bin/node]
  14: 0x10023170f v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
  15: 0x100230c51 v8::internal::MaybeHandle&lt;v8::internal::Object&gt; v8::internal::(anonymous namespace)::HandleApiCallHelper&lt;false&gt;(v8::internal::Isolate*, v8::internal::Handle&lt;v8::internal::HeapObject&gt;, v8::internal::Handle&lt;v8::internal::HeapObject&gt;, v8::internal::Handle&lt;v8::internal::FunctionTemplateInfo&gt;, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::BuiltinArguments) [/usr/local/bin/node]
  16: 0x1002302f0 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
  17: 0xddb29a5be3d 
  18: 0xddb29a118d5 
  Abort trap: 6
  </code></pre>