AWS Lambda Application with Java resource
buildspec.yml if you want to deploy using AWS CodeBuild (would be an unusual flow):
---
version: '0.2'
phases:
install:
commands:
- echo Entered the install phase...
- npm install --global lerna
- lerna bootstrap --concurrency=1 -- --production
build:
commands:
- sam build
- sam deploy --stack-name stackoverflow-stack --capabilities CAPABILITY_IAM --no-fail-on-empty-changeset
--s3-bucket your-bucket-name-here --parameter-overrides AppId=your-app-id-here
buildspec.yml if you only want to produce a CloudFormation template file which you can directly deploy (using CodeDeploy or other means). It is almost the same as what you already have, with the following difference:
- Adds
sam build
- Uses
sam package
instead ofaws cloudformation package
.sam package
uses.aws-sam/template.yaml
(output of sam build) instead oftemplate.yaml
as the first default.
---
version: '0.2'
phases:
install:
commands:
- echo Entered the install phase...
- npm install --global lerna
- lerna bootstrap --concurrency=1 -- --production
build:
commands:
- sam build
- sam package --s3-bucket your-bucket-name-here --output-template-file
template-export.yml
artifacts:
files:
- template-export.yml
Edit2: OP's build project was created by Lambda applications. The build project uses aws/lambda/nodejs:10-1.0
which has two issues:
- The SAM CLI version is outdated
- Java isn't installed because the image is meant to be used for nodejs based Lambda functions. Java is required to build the Java based AWS Lambda function
The following buildspec.yaml can be used to fix both these issues:
---
version: '0.2'
phases:
install:
commands:
- echo Entered the install phase...
- npm install --global lerna
- lerna bootstrap --concurrency=1 -- --production
- yum install -y amazon-linux-extras which
- amazon-linux-extras install java-openjdk11
- pip install aws-sam-cli --upgrade
build:
commands:
- sam build
- sam package --s3-bucket cf-templates-fgoi5xu7d2hs-us-east-1 --output-template-file
template-export.yml
artifacts:
files:
- template-export.yml