GithubHelp home page GithubHelp logo

po-vincent / leveraging-aws-appconfig-for-enabling-saas-pricing-tiers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/leveraging-aws-appconfig-for-enabling-saas-pricing-tiers

0.0 0.0 0.0 875 KB

License: MIT No Attribution

Shell 3.49% JavaScript 29.64% Python 56.43% CSS 6.59% HTML 3.09% Batchfile 0.77%

leveraging-aws-appconfig-for-enabling-saas-pricing-tiers's Introduction

Leveraging AWS AppConfig for Enabling SaaS Pricing Tiers

Documentation

Introduction

If you are delivering your applications as a Software as a Service (SaaS), maintaining a single version of your solution is important to keeping your operational efficiency. However, to make your offering attractive to the widest variety of customers, you also need to package your solution with flexible pricing options. Keeping your desired operational efficiency requires tools like configuration management that allow you to offer variations on your solution.

In this hands-on coding example, we demonstrate techniques for using AWS AppConfig (AppConfig) to configure our SaaS solution, allowing us to package it into pricing tiers with a variety of feature sets enabled for our tenants.

The goal is to provide SaaS developers and architects with working code that illustrates how to use AppConfig in designing SaaS solutions without going to the extent of making a full, production-ready solution. Instead, we're hoping this can jump start your process and address some of the common challenges that you may face.

The instructions below are intended to give you a step-by-step walk through for getting this solution up and running in your own AWS account. For a general description and overview of the solution, please see the developer's documentation.

Note : This is not production grade and simply meant as a hands-on coding example.

High Level Architecture

Figure 1 represents the high-level architecture of this sample SaaS solution. As mentioned before, please see the developer's documentation to understand the architecture in more detail.

High Level ArchitectureFigure 1: High Level Architecture

Prerequisites

Before you begin, ensure you have:

Supported Regions

Deploy this sample in:

  • us-east-1 (Default region)
  • us-east-2
  • us-west-1
  • us-west-2

Getting Started

1. Environment Setup

Clone the repository

git clone [email protected]:aws-samples/leveraging-aws-appconfig-for-enabling-saas-pricing-tiers.git

Move into the cloned repository

cd leveraging-aws-appconfig-for-enabling-saas-pricing-tiers
  • For AWS Cloud9 (Cloud9) users

    We recommend selecting an instance type of at least t3.small

    Resize the Amazon EBS volume to 20 GiB

     chmod +x resize.sh
     ./resize.sh 20

    Reboot the instance. It could take a minute or two for the IDE to come back online

     sudo reboot

Create and activate a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Set the AWS_DEFAULT_REGION environment variable to determine the AWS region to deploy the resources. Ensure the chosen region is supported.

export AWS_DEFAULT_REGION=REGION

Install the necessary dependencies

pip install -r requirements.txt

(Optional) Bootstrap AWS CDK (CDK) on the target account and region

Note: This is required if you have never used CDK before on this account and region combination. (More information on CDK bootstrapping).

cdk bootstrap aws://{ACCOUNT-NUMBER}/{REGION}

2. Deployment with CDK

Deploy the application using CDK, ensuring deployment in the supported regions

cdk deploy --all

After a successful deployment, take note of the displayed values: BackendStack.BackendApiURL, IdentityStack.UserPoolId, and IdentityStack.UserPoolClientId. You will use them in the next step.

Note: You can also retrieve these values by visiting the AWS CloudFormation console. Select the appropriate stack (e.g., BackendStack, IdentityStack) and navigate to the “Outputs” tab to view these details.

3. Configuring the React App

Move into the app directory

cd app/

Update app/src/aws-exports.js with your specific AWS resource details from the previous step

const config = {
    region: 'YOUR_REGION',
    api_gateway: {
        regional_endpoint: 'YOUR_API_URL',
    },
    user_pool_id: 'YOUR_USER_POOL_ID',
    user_pool_client_id: 'YOUR_USER_POOL_CLIENT_ID',
};

export default config;

Install dependencies and run the app locally

npm install
npm run start

Understanding the CDK code

The application is structured into four CDK stacks, each deploying and managing specific resources. The app.py file serves as the entry point for deploying these stacks.

Note: In this sample application, RemovalPolicy.DESTROY is used to ensure that the AWS resources created are automatically removed when the stack is deleted. This is helpful in maintaining a clean testing environment and avoiding unwanted costs. Consider RemovalPolicy.RETAIN or RemovalPolicy.SNAPSHOT for production environments to safeguard against accidental data loss. (More information on RemovalPolicy).

Clean up

Avoid unwanted charges by cleaning up the resources you've created. To do so, navigate to the root of the repository and run:

cdk destroy --all

Note: If you used Cloud9 to deploy the architecture, then make sure to delete that instance. This will not be done by the command, and will need to be done manually.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

leveraging-aws-appconfig-for-enabling-saas-pricing-tiers's People

Contributors

harabdi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.