7

I'm trying to build a Lambda application using AWS SAM CLI command:

sam build --template C:/MyProject/template.yaml --build-dir C:/MyProject/.aws-sam/build

but I'm getting this error:

Build Failed

Error: 'java8' runtime is not supported

This is my template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  AWS Serverless Application
  Sample SAM Template for AWS Serverless Application
Globals:
  Function:
      Timeout: 20
Resources:
  HelloWorldFunction:
      Type: AWS::Serverless::Function
      Properties:
          CodeUri: target/HelloWorld-1.0.jar
          Handler: helloworld.App::handleRequest
          Runtime: java8
          Environment: 
              Variables:
                  PARAM1: VALUE
          Events:
              HelloWorld:
                  Type: Api
                  Properties:
                      Path: /hello
                      Method: get

It's an example project made in Intellij using AWS Toolkit plugin, I have installed SAM CLI version 0.9.0 and jdk1.8.0_191 (I've tried different versions but it didn't work), at the project's GitHub I can see that java 8 is supported:

[ ] Supported AWS Lambda Runtimes
    [x] java8

Why am I getting this error?

Michael Dz
  • 3,655
  • 8
  • 40
  • 74

2 Answers2

3

Seems like the build option doesn't support the java8 runtime

When I run sam build --help the result is: enter image description here which implies that it only works for python

matsev
  • 32,104
  • 16
  • 121
  • 156
sakata-san
  • 46
  • 2
0

In my case,

Previously, I had given like below,

CodeUri: hello-world.jar

I have changed it to

CodeUri: ./hello-world

where hello-world is my java project's source directory.

NIrav Modi
  • 6,038
  • 8
  • 32
  • 47