https://github.com/mongoexpuser/aws-cloudformation-stack-with-aws-sdk-js-v3
Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.
https://github.com/mongoexpuser/aws-cloudformation-stack-with-aws-sdk-js-v3
apache-cassandra aws aws-sdk-v3 cloudformation github-actions javascript keyspace nodejs yml-file
Last synced: 10 months ago
JSON representation
Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.
- Host: GitHub
- URL: https://github.com/mongoexpuser/aws-cloudformation-stack-with-aws-sdk-js-v3
- Owner: MongoExpUser
- License: mit
- Created: 2023-01-01T09:11:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-01T11:22:15.000Z (over 1 year ago)
- Last Synced: 2025-03-14T07:45:49.181Z (about 1 year ago)
- Topics: apache-cassandra, aws, aws-sdk-v3, cloudformation, github-actions, javascript, keyspace, nodejs, yml-file
- Language: JavaScript
- Homepage:
- Size: 207 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/MongoExpUser/AWS-CloudFormation-Stack-with-AWS-SDK-JS-V3/actions/workflows/deploy-cfn.yml)
# 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
* curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -
* sudo apt-get install -y nodejs
* sudo npm install @aws-sdk/client-cloudformation
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.
* References for inputConfig.json :
1) https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/createstackcommandinput.html
2) https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/deletestackcommandinput.html
3) https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/updatestackcommandinput.html
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.
* Link: https://github.com/MongoExpUser/AWS-CloudFormation-Stack-with-AWS-SDK-JS-V3/blob/main/.github/workflows/deploy-cfn.yml
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.
* Link: https://github.com/MongoExpUser/AWS-CloudFormation-Stack-with-AWS-SDK-JS-V3/actions
# License
Copyright © 2015 - present. MongoExpUser
Licensed under the MIT license.