Creates/Deploys, Updates and Deletes AWS CloudFormation Stack with AWS SDK for JavaScript/NodeJS V3.
The script can execute the followings:
-
Uses the indicated YAML or JSON CloudFormation input file to create/deploy resources as specified in the input file.
-
Updates the deployed resources.
-
Deletes the deployed resources.
-
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.
-
- 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
- curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -
-
- NodeJS script: index.js
- JSON files: credentials.json and inputConfig.json
- CloudFormation YAML input file: keyspace.yaml
- NodeJS script: index.js
-
- References for inputConfig.json :
- https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/createstackcommandinput.html
- https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/deletestackcommandinput.html
- https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudformation/interfaces/updatestackcommandinput.html
- References for inputConfig.json :
-
- sudo node index.js
- sudo node index.js
This option has the benefits of CICD in general. To deploy the stack via GitHub action, follow these steps:
-
- Ensure that the environment (dev, stag or prod) and region in the file correspond to the values in the GitHub Actions YML file.
- Ensure that the environment (dev, stag or prod) and region in the file correspond to the values in the GitHub Actions YML file.
-
- These include: accessKeyId, secretAccessKey and region.
- This prevents exposure of the credentials.
Copyright © 2015 - present. MongoExpUser
Licensed under the MIT license.