Deploying web app in AWS using Salt stack


This document is about deploying a Java, NodeJS web app in AWS using Saltstack and creating infrastructure using Terraform


  • Knowledge of AWS
  • Knowledge Saltstack
  • Linux
  • Terraform


Saltstack is a configuration management tools which supports both push based and pull based management. Salt-master, salt-minion are the terms which describes server and client in pull based configuration of Saltstack


Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Description of Web app

The web app is consisting of two application services

Java: is the backend for the web app

NodeJS: is the front-end UI for the web app


  • Configure the terraform with AWS provider for the IAM user in AWS account
  • To Generating access and secret keys in IAM console follow the steps
  • After generating keys create a file with following contents


  • Replace the region if you want to change
  • Create a file which used to create salt-master in AWS



  • Now we are creating a salt master with static private IP in default VPC, subnet
  • Create file to create a private hosted in AWS to boot salt-minion with master using custom domain name


  • In this file we are creating a private hosted zone, creating a record set as and linking it our master private IP
  • Use Terraform plan command to evaluate code for any syntax errors
  • Use terraform apply command to create the infrastructure
  • Log in to the AWS console and navigate region that have update observe the changes
  • Using user data field in the we have passed a startup script to install salt-master in AWS
  • Contents of the script



  • We are install another component salt-cloud which used to maintain, configure infrastructure in cloud providers like AWS
  • Salt-cloud user /etc/salt/cloud.providers. d/ uses this location for cloud provider credentials
  • Define a file with. conf extension to configure. Sample file looks like this aws_ap-northeast-1. conf



  • This file defines instance role and credentials
  • Salt-master needs ec2 full access role or administrator role

Salt-cloud uses /etc/salt/cloud.profiles. d/ location for instances configuration




  • Here defining two instances for two instances one for java backend and other for NodeJS frontend
  • Salt-cloud uses /etc/salt/cloud.maps.d. d/ location for mapping cloud. Profiles to cloud providers

Example test. conf


  • Now run salt-cloud -m /etc/salt/cloud.maps.d/test.conf and enter
  • Now salt-cloud in salt-master will create two instances, installs salt-minion and bootstraps with salt master runs the startup script defined /etc/salt/cloud.profiles.d/test_env.conf for those instances
  • Now we have to install Java, MySQL in java backend, NodeJS in frontend
  • We are writing top.sls to installed these packages in respective instances



Defining api-java.sls


Defining nodejs.sls


As instances some initial steps we are passing startup scripts through salt

Script for java backend


Now run salt salt ‘*’ state.apply

TO apply changes enter public ip in your to check UI


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s