Skip to content

Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.

License

Notifications You must be signed in to change notification settings

MongoExpUser/AWS-CloudFormation-Stack-with-AWS-SDK-JS-V3

Repository files navigation

CI - AWS-SDK-JS-V3 Deploy CFN

CloudFormation-Stack-with-AWS-SDK-JS-V3


Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.

The script can execute the followings:
  1. Uses the indicated YAML or JSON CloudFormation input file to create/deploy resources as specified in the input file.

  2. Updates the deployed resources.

  3. Deletes the deployed resources.


PURPOSE

  • Normally an AWS CloudFormation stack can be deployed via AWS CloudFormation console or AWS CLI.

  • An AWS CloudFormation stack can also be deployed via AWS SDK in any language of choice.

  • This repository contains code for deploying an AWS CloudFormation stack via AWS SDK for JavaScript/NodeJS V3, from any computer.

  • AWS SDK for JavaScript/NodeJS V3 is clean, light weight, fast and it fully supports async-await syntax.

  • The sample stack (keyspace.yaml file) in this repository is for creating/deploying, updating and deleting an AWS Keyspace and Tables (for Apache Cassandra), used in real-time drilling, reservoir and production applications.

DEPLOYING STACK with the NodeJS script

OPTION 1: Clone to Local Computer

To deploy the stack on AWS, follow these steps:

  1. Install NodeJS and @aws-sdk/client-cloudformation (v3) module, assuming Ubuntu OS

  2. Download or clone the following files, from this repo, into the current working directory (CWD):

    • NodeJS script: index.js
    • JSON files: credentials.json and inputConfig.json
    • CloudFormation YAML input file: keyspace.yaml
  3. Fill in relevant values in inputConfig.json file.

  4. Then run the code, assuming sudo access:

    • sudo node index.js

OPTION 2: Through GitHub Actions

This option has the benefits of CICD in general. To deploy the stack via GitHub action, follow these steps:

  1. Check and fill relevant values in the GitHub Actions YML deployment file.

  2. Also fill relevant values in the inputConfig.json file.

    • Ensure that the environment (dev, stag or prod) and region in the file correspond to the values in the GitHub Actions YML file.
  3. Add the actual values for credentials to the GitHub Secrets.

    • These include: accessKeyId, secretAccessKey and region.
    • This prevents exposure of the credentials.
  4. Then enable GitHub Actions Workflow and run the YML file.

License

Copyright © 2015 - present. MongoExpUser

Licensed under the MIT license.

About

Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published