This section assumes you have already defined your API, read this to learn how.

Deploying your API

Since all the configuration for your API is inside your build.sbt file, follow the same steps for deploying a Scalambda project that uses Api Gateway as you would with one that doesn’t.

Step 1: Generate the Terraform module

Use the scalambdaTerraform SBT task to generate a Terraform module for your API.

Step 2: Add the new Terraform module

Either in your existing Terraform, or in a new .tf file, add the following module:

# my-project/terraform/

module "helloworld_api" {
  # Points to the terraform generated by scalambda inside the your project's target folder
  source = "<path to your project>/target/terraform" 
Step 3: Apply the Terraform

Run the following commands in your favorite shell (make sure you have Terraform installed):

# cd to wherever your terraform is
cd my-project/terraform

# initialize the terraform (only need to this once)
terraform init

# apply the terraform
terraform apply