[JAVA] Building a Lambda development environment in Eclipse

Instead of building a development environment on a notebook PC every time after using AWS, create an EC2 instance for each language such as JAVA, C #, Python, etc. and build a development environment. When you're done using it, you can take the AMI, save it as a snapshot, and delete the instance to maintain the environment at a low maintenance cost.

I made a Python environment in, but this time I will make a JAVA development environment.

environment

Pleiades All in One installation

First, download from the link below http://mergedoc.osdn.jp/index.html#/pleiades_distros4.7.html Download the Windows 64bit Full Edition as it also requires a JDK

After downloading, install it. It's not in the installer format, just right-click the .zip, click Extract All, and extract it to the appropriate location. pleiades.png Navigate to the eclipse folder and double-click eclipse.exe to launch it. You will be asked for the workspace directory, so create it in the default location. workspace.png

AWS Toolkit for Eclipse installation

Open Eclipse and click Help-> Install New Software. In the Work with box, type https://aws.amazon.com/eclipse and press Enter. awstoolskit.png Only ** AWS Toolkit for Eclipse Core ** is required, so install it for the time being. Also, I want to deploy to Lambda this time, so I also installed ** AWS Lambda Plugin **. lambdaplugin.png

reboot.png Eclipse will be restarted after the installation is complete. notice.png A new AWS icon has been added to the menu, allowing you to create an AWS Java project. aws.png

Creating an AWS Lambda Java project

Click ** New AWS Lambda Java Project ** and a pop-up will appear. image1.png

You can create it by entering the project name sample-lambda-java. The input type will list the trigger services that call Lambda, where select Custom.

AWS Lambda Java project configuration

Open the project, and the program materials such as packages, classes, and JRE libraries are listed in the upper left as the configuration. Click [View AWS Explorer View] from the AWS icon menu to display a list of AWS related services as shown in the lower left. If you expand it, you can see what is created inside. image2.png

Also, on the right side is the program that opens S3Sample.java in the [com.amazonaws.smaples] package.

AWS Lambda Java project execution

Now you can start coding. I'd like to make a Wrapper class and run it locally, In the execution configuration of Elipse, I created a new execution configuration with AWS SAM Local sample-lambda-java. I prepared all the SAM Template and Event files, but the error "Property SAM runtime does not contain a valid file!" Was displayed, and when I forced it to execute, the error was displayed. run1.png

run2.png

The Serverless template file is created as follows.

sample-lambda-java.yaml


AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
  samplelambdajava:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: com.amazonaws.lambda.demo.LambdaFunctionHandler
      Runtime: java8
      Description: ''
      MemorySize: 512
      Timeout: 15
      Role: 'arn:aws:iam::xxxxxxxxxxxx:role/lambda_access_execution'

error1.png

You need a SAM Local environment.

After working on building the SAM Local environment with reference to, I was disappointed by starting Docker. If you start the virtual environment (Windows: Docker Toolbox) on EC2 (virtual environment), an error will occur. error2.png I gave up because I couldn't mess with the BIOS.

AWS Lambda Java project upload

If you can't run it locally, you can upload it and run it on the Console. uploadfunction.png Click Upload function to AWS Lambda to upload. uploadwindow1.png Create a test event in the management console and click "Test" image3.png

It was a success.

Recommended Posts

Building a Lambda development environment in Eclipse
Building a Kotlin development environment using SDKMAN
[Ruby] Building a Ruby development environment on Ubuntu
Allow development in Eclipse environment using iPLAss SDK
Points stuck in building VSCode & Java development environment
Java development environment (Mac, Eclipse)
First Java development in Eclipse
Docker × Java Building a development environment that is too simple
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
Spring Boot application development in Eclipse
[Eclipse Java] Development environment setting memo
Create a database in a production environment
Create a Servlet program in Eclipse
Build jooby development environment with Eclipse
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a browser test environment using Capybara in the Docker development environment
Install Rails in the development environment and create a new application
We will build a Spring Framework development environment in the on-premises environment.
Building a Deep Learning environment (Ubuntu 20.04 LTS)
Build a PureScript development environment with Docker
Let's create a Java development environment (updating)
Play Framework 2.6 (Java) environment construction in Eclipse
Build a Java development environment on Mac
Build a Wordpress development environment with Docker
Creating a Servlet in the Liberty environment
Run jooby's Eclipse development environment on Gradle
Take a thread dump in a JRE environment
Java application development environment created in VM environment
Build a simple Docker + Django development environment
Building a development environment for Flutter on Win10 --- Flutter SDK Install (2020 preservation version)
I tried to build a Firebase application development environment with Docker in 2020
Build a development environment for Docker + Rails6 + Postgresql
Let's get started with Java-Create a development environment ②
Let's get started with Java-Create a development environment ①
Create a simple batch processing framework in Eclipse.
Building a Ruby environment for classes on Mac
Build a WordPress development environment quickly with Docker
Java development environment
MVC in Eclipse.
Build a simple Docker Compose + Django development environment
[Note] Struts2 environment construction using Gradle in Eclipse
[Win10] Build a JSF development environment with NetBeans
A reminder of Docker and development environment construction
Build a development environment for Docker, java, vscode
[Beginner] Install java development tool in cloud9 development environment.
Create a Spring Boot development environment with docker
How to automatically generate a constructor in Eclipse
Build a Java development environment with VS Code
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
Java development environment construction (Mac + Pleiades All in One Eclipse 4.7 + Spring Boot + Gradle (Buildship))
A memo when building a Rails 5.2 development environment using Docker Desktop + WSL2 on Windows 10 Home
Learn the meaning of "passing the PATH" by building a Java development environment on Mac
[For beginners] Until building a Web application development environment using Java on Mac OS
Create a Java development environment using jenv on Mac
I tried using a database connection in Android development
How to create a Java environment in just 3 seconds
Build a Ruby on Rails development environment on AWS Cloud9
[CentOS, Eclipse] Load a library file in a C project
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
Let's create a gcloud development environment on a centos8 container
Verification value error that occurred in a clustering environment