---
title: "Discussion on \"Build & deploy all AWS resources as easy as: npm run deploy-prod (AWS Sam worflow)\" | Hashnode"
description: "Discussion on \"Build & deploy all AWS resources as easy as: npm run deploy-prod (AWS Sam worflow)\". After manually managing my AWS resources I finally decided to use Sam templates and put everything in Git. Easy deploying to prod and test stages was also a requirement. Here is a short overview of some issues I ran into and how I resolved them. It i..."
url: "https://hashnode.com/posts/build-and-deploy-all-aws-resources-as-easy-as-npm-run-deploy-prod-aws-sam-worflow/5ef2756e2fb6648468ee0f57"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Build & deploy all AWS resources as easy as: npm run deploy-prod (AWS Sam worflow)](https://hashnode.com/post/build-and-deploy-all-aws-resources-as-easy-as-npm-run-deploy-prod-aws-sam-worflow?utm_source=hashnode&utm_medium=feed)

After manually managing my AWS resources I finally decided to use Sam templates and put everything in Git. Easy deploying to prod and test stages was also a requirement. Here is a short overview of some issues I ran into and how I resolved them. It i...

Jun 23, 2020 · 25 min read · hashnode.com  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#serverless](https://hashnode.com/tag/serverless)
-   [#sam](https://hashnode.com/tag/sam)
-   [#node](https://hashnode.com/tag/node)

## Written by

[Mirko Vukušić](https://hashnode.com/@psiho)

@psiho · Split, Croatia

  
[View profile](https://hashnode.com/@psiho)

Full(stack|dev|life)

Passionate for IT since ZX80 days. Over time, worked in many fields from programming, over project management to CEO/co-owner position of IT outsourcing company. But passion for programming never ceased. From old days of Assembler and Perl, over ASP and MS SQL to most recent JavaScript (Angular/ionic, Node, React, PostgreSQL). Currently doing several smaller projects, one of which is JSBench.me - JavaScript performance benchmarking playground ( https://jsbench.me )

## Responses 1

Markdown supported · ⌘↵ to post

[Chris Nagy](https://hashnode.com/@chris_the_nagy)

[Aug 1, 2020](https://hashnode.com/posts/build-and-deploy-all-aws-resources-as-easy-as-npm-run-deploy-prod-aws-sam-worflow/5ef2756e2fb6648468ee0f57/comment/5f25ed43669da9610ee18110)

I always wondered about the benefits of using a bash script for deployments vs using `sam deploy` lets say. Can you elaborate on the pros of using a seperate bash script? Since `sam build && sam deploy` is so easy to use now😅

[Mirko Vukušić](https://hashnode.com/@psiho)

[Aug 2, 2020](https://hashnode.com/posts/build-and-deploy-all-aws-resources-as-easy-as-npm-run-deploy-prod-aws-sam-worflow/5ef2756e2fb6648468ee0f57/comment/5f25ed43669da9610ee18110#reply-5f260a6d669da9610ee18193)

Well, bash script actually uses sam-build and sam-deploy if you look at it. However, it does a few other things too. Mostly, I used json-refs to be able to split template into smaller (managable) files AND also optimize yaml for API Gateway's DefinitionBody. $ref there can only be used ina few places and with json-refs I can use it anywhere, making my definition body really small and easy to write/extend. Second reason is to make it easier to include AWS build/deploy into main build/deploy script that runs the same for both frontend (Webpack) and backend (AWS). And all that for different stages. It seemed much cleaner to separate the two instead of using sam-build in main build script.
