Skip to content

Stacks

The stacks are the main building blocks of the s6pack cloud framework. The main.ts file in the root directory illustrates how the stacks are imported and used. The setup that comes with the installation of the framework is illustrated below:

s6pack stacks

99.9% of the Application Logic for the devStacks and webStacks are AWS Stepfuncions as defined in the *.asl.json files. These step functions are orchestrators for the application and are triggered by the Graphql API and Cognito Lambda triggers and Lambda webhooks.

Below are the stacks broken down by project structure and in order of deployment.

hostingStack

  • Directoryhosting
    • hostingStack.ts
    • Directoryinfrastructure
      • Directoryaws
        • acm.ts
        • iam.ts
        • route53.ts
        • s3.ts
        • ses.ts
        • ssm.ts

The hostingStack’s purpose is to provide a static website hosting environment for the application. This stack is deployed the least frequently as it is not dependent on the other stacks. It makes use of the following AWS services:

  • ACM - Amazon Certificate Manager - to provide a certificate for the domain
  • IAM - Amazon Identity and Access Management - to provide a user for the application to access the resources in the stack
  • Route53 - Amazon Route53 - to provide a domain and a hosted zone and DNS recordsfor the application
  • S3 - Amazon Simple Storage Service - to provide a bucket for the application to store the static website
  • SES - Amazon Simple Email Service - to provide an email service for the application
  • SSM - Amazon Simple Systems Manager - to provide a parameter store for various parameters used throuought the infrastructure and application, as well as the client application

dataStack

  • Directorydata
    • dataStack.ts
    • Directoryapp
      • Directoryservice-authenticate
        • DirectorystepFunctionDefinitions
          • cognitoPostConfirmationTrigger.asl.json
          • cognitoPreTokenGenerationTrigger.asl.json
        • service.ts
    • Directoryentities
      • DirectorygoogleRecaptcha
        • index.js
    • Directoryinfrastructure
      • Directoryaws
        • cloudWatch.ts
        • cognito.ts
        • dynamoDb.ts
        • iam.ts
      • Directorystripe
        • product.ts
        • webhookEndpoint.ts
    • Directorycontroller-lambda
      • postConformationTrigger
      • preTokenGenerationTrigger
      • lambdaAuthenticationController.ts

The dataStack is used to house the data-centric infrastructure. It houses the AWS Cloudwatch logs for all other downstream stacks. It is also responsible for adding database records to stripe and AWS DynamoDB. These records are for payment subscription plans and can be modified in the ./.config.dataStack.yaml file.

Note: The googleRecaptcha is installed manually per the cloud installation instructions and no infrastructure is deployed for this.

s6pack by default has the dataStack deployed twice using the dataStackDev and dataStackLive definitions, which can be found in the main.ts file. It is possible to add more dataStacks to the main.ts file if you need to separate the environments even further.

The dataStackDev is used for development and testing. The dataStackLive is the live mode, which is used for the production environment. Stripe has a test mode and a live mode, which can be found in the stripe dashboard. The dataStackDev and dataStackLive are both configured for their respective Stripe test and live modes.

what you get for both the live and test modes are the following:

  • a live and development Cognito user pool with Cognito identity providers and customapplication clients.
  • a live and development DynamoDB tables for tenant and plan iformation
  • a live and development Cloudwatch log environemnts
  • a live and development Stripe account with plans and products configured

You can examine the ./.config.dataStack.yaml file to see other options available.

This stack makes use of the following AWS and Stripe services:

  • CloudWatch - Amazon CloudWatch - to provide a monitoring service for the application
  • Cognito - Amazon Cognito - to provide an authentication service for the application
  • DynamoDB - Amazon DynamoDB - to provide a database service for the application
  • IAM - Amazon Identity and Access Management - to provide a user for the application to access the resources in the stack
  • Stripe - Stripe product and webhook endpoints- to provide a payment service and notifications for the application

webStack

  • Directoryweb
    • DirectorywebStack.ts
      • Directoryapp
        • Directoryservice-account
          • service.ts
          • DirectorystepFunctionDefinitions
      • Directoryservice-plan
        • service.ts
        • DirectorystepFunctionDefinitions
      • Directoryservice-user
        • service.ts
        • DirectorystepFunctionDefinitions
      • DirectoryserviceComponents
      • Directorytests
    • Directoryentities
      • DirectorystripeApi
        • index.ts
      • DirectorystripeWebhooksValidation
        • index.ts
      • Directorytests
    • Directoryinfrastructure
      • Directoryaws
        • acmCertificateValidationResiurce.ts
        • appsync.ts
        • iam.ts
    • Directoryinterface
      • DirectorycontrollerPresenter-appsync
        • appsybcGraphqlController.ts
        • *.request/resolver.vtl files
        • schema.graphql
      • Directorygateway-lambdaUrl
        • DirectorycloudfrontViewerRequestFunction
          • index.ts
        • DirectoryqueryAppsyncGatewayFunction
          • index.ts

There are three webstack deployments that come with s6pack as defined in the main.ts file. You can also find all three coinfigurations in the ./.config.webStack.yaml file. If you want a seperate dev stack for each developer on you team it is as simple as duplicating the webstackDev code in main.ts and duplicating the the stack configuration in the ./.config.webStack.yaml file for each developer on your team. With this setup, developers can deploy their own stack and have their own development environment.

The webStack is where the bulk of the application logic is housed. This is where the GraphQL API is defined, as well as the step functions and all the services that are used to orchestrate the application.

The webStack makes use of the following AWS and Stripe services:

  • ACM - Amazon Certificate Manager - to provide a certificate for the domain
  • AppSync - Amazon AppSync - to provide a GraphQL API for the application
  • CloudFront - Amazon CloudFront - to provide a content delivery network for the application
  • Lambda - Amazon Lambda - to provide a compute service for bespoke code execution
  • Step Functions - Amazon Step Functions - to provide a consistant workflow service for the application with maximum visibility

The westacks are also dependant on the dataStacks and hostingStack so if changes occur to those then they will need to be re-deployed first before deploying the devstack.

documentationStack

  • Directorydocumentation
    • documentationStack.ts

The documentationStack is used to provide a static website hosting environment for the purpose of serving this static documentation site. it makes use of the following AWS services:

  • ACM - Amazon Certificate Manager - to provide a certificate for the domain
  • CloudFront - Amazon CloudFront - to provide a content delivery network for the application
  • S3 - Amazon Simple Storage Service - to provide a bucket for the application to store the static website

blueGreenToggleStack

  • DirectoryblueGreenToggle
    • blueGreenToggleStack.ts

The blueGreenToggleStack is used to toggle the blue and green stacks. Simply change the currentLiveAppStackName in the ./.config.blueGreenToggleStack.yaml file and deploy the bluegreenToggleStack to point the apex domain name and api subdomain name to the new live stack.

This stack makes use of the following AWS services:

  • ACM - Amazon Certificate Manager - to provide a certificate for the domain
  • CloudFront - Amazon CloudFront - to provide a content delivery network for the application
  • Route53 - Amazon Route53 - to provide a domain and a hosted zone and DNS recordsfor the application
  • AppSync - Amazon AppSync - to update custom domain names for the blue/green subdomains

This illustrates toggling to the blue stack:

s6pack stacks