DEV Community

Cover image for Using GitHub actions - Deploy to AWS & SNS Publish
Jones Zachariah Noel for AWS Community ASEAN

Posted on

Using GitHub actions - Deploy to AWS & SNS Publish

GitHub actions enables developers/DevOps engineers to smartly incorporate CI/CD pipelines, perform tasks on actions on different branches and many more things. In the blog, we will look into GitHub actions which uses two workflows -

  1. SAM Pipeline to deploy to AWS environments
  2. SNS Publish on commits / delete branch

This helps in deploying SAM applications to AWS with Pipeline to ensure multiple staging environments to be deployed and handle feature branches. Along with it, you can do more things on AWS end of there is a event trigger via SNS to process each commit action.


My Workflow

SAM Pipeline to deploy to AWS environments

SAM Pipeline enables leveraging SAM and GitHub actions to deploy your Serverless application to AWS environment. This leverages sam build and sam deploy commands performed via SAM CLI in the GitHub actions (Ubuntu) environment.
The workflow defines jobs for -

  • test : Checking if the GitHub event is push.
  • delete-feature : If the GitHub event is delete on a feature branch with the name starting with feature-*, it deletes that particular feature branch with sam delete.
  • build-and-deploy-feature : If the GitHub event is push on a feature branch with the name starting with feature-*, it deploys the app to AWS with the code from feature branch with sam deploy.
  • build-and-package : If the GitHub event is push on a main branch, it packages the the app for two stages - dev and prod and uploads the artifacts zip files to S3 bucket with sam package command.
  • deploy-testing : The code will use the Stage 1 - dev and deploys the Serverless application to AWS with sam deploy.
  • integration-test : If the branch is main, you can run specific integration tests via bash scripts. And if the tests are passed, it proceeds to the next step.
  • deploy-prod : If the integration tests are passed, the complete code from main branch is deployed to AWS with sam deploy.

SAM Pipeline
Action details

SNS Publish on commits / delete branch

The workflow is used to notify with AWS Simple Notification Service (SNS) by pushing to a SNS topic. This workflow uses Danushka96/sns-action@v2 which performs SNS:PUBLISH to send message to the SNS topic.

SNS Publish
Action description


Submission Category:

DIY Deployments which eases deployment of SAM app via SAM Pipelines and also using SNS publish, we can get creative with ways of additional workflows on AWS to be triggered.


Yaml File or Link to Code

The blog post implementation of 2 workflows is implemented with pipeline.yaml and sns.yml

GitHub actions enables developers/DevOps engineers to smartly incorporate CI/CD pipelines, perform tasks on actions on different branches and many more things. In the blog, we will look into GitHub actions which uses two workflows -

  1. SAM Pipeline to deploy to AWS environments
  2. SNS Publish on commits / delete branch

My Workflow

SAM Pipeline to deploy to AWS environments

SAM Pipeline enables leveraging SAM and GitHub actions to deploy your Serverless application to AWS environment. This leverages sam build and sam deploy commands performed via SAM CLI in the GitHub actions (Ubuntu) environment. The workflow defines jobs for -

  • test : Checking if the GitHub event is push.
  • delete-feature : If the GitHub event is delete on a feature branch with the name starting with *feature-**, it deletes that particular feature branch with sam delete.
  • build-and-deploy-feature : If the GitHub event is push on a feature branch with the…

Additional Resources / Info

This project uses several GitHub actions -

Top comments (0)