Skip to content

Latest commit

 

History

History

IntelliJ-AWS-SAM-Java

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

AWS SAM for Java with IntelliJ IDEA

Why not Visual Studio Code?

AWS SAM for Java applications is not compatible with VSCode, the languages that VSCode + SAM supports are: Nodejs, .NET and Python (2.x and 3.x). To see the development of the discovery see post.

Requirements

To use SAM in IntelliJ is necessary:

  • AWS account: Choose Create an AWS Account, or Complete Sign Up.
  • AWS CLI: The AWS Command Line Interface (AWS CLI) is an open source tool that enables you to interact with AWS services using commands in your command-line shell.
  • Docker: The AWS SAM CLI requires this open-source software container platform.
  • AWS SAM CLI: This is an AWS CLI tool that helps you develop, test, and analyze your serverless applications locally.
  • Maven.
  • JDK.
  • IntelliJ IDEA.

Configuration

To see my experience and problems encountered see post.

  1. Configure AWS CLI:

    1. In AWS Web, click in your user > My Security Credentials:

      AWS CLI Credential

    2. In console, write "aws configure" command and add the id and secret of aws web, select your region and preferred output format. If you want to create a specific configuration profile use: "aws configure --profile <profileName>":

      AWS configure

  2. Install AWS Toolkit in IntelliJ: File > Settings:

    Create AWS project

  3. In IntelliJ, chose File > New > Project...

    Create AWS project

    and apply this config:

    AWS project configuration

    It will show an AWS demo project with which we will continue explaining how to use SAM.

  4. Connect IntelliJ IDEA with AWS: Press tab "AWS Explorer"

    IntelliJ + AWS

    and then the configuration profile that we want to use. If in step 1.2. you have made "aws configure" without specifying any profile, this profile will be default.

    IntelliJ + AWS

Run and Debug

It is possible to run and debug the application on IntelliJ, for this you have to apply a configuration like this:

Run and debug config

Run Example

Run example

Debug Example

Debug example

Deploy

To deploy the application:

To deploy

and apply the configuration

Deploy Config

  • Stack: The name of the AWS CloudFormation stack that is create when deploying this serverless application.
  • S3 Bucket: AWS repository where the application will be stored (create one if none exists).

After configuration press deploy and the result will look like this:

Deploy

We can ensure that the application was deployed by consulting the AWS Web environment in the Lambda section:

Deploy done