All Projects → brietsparks → guestbook

brietsparks / guestbook

Licence: other
A simple app with automated infrastructure provisioning, app deployment, and E2E testing

Programming Languages

HCL
1544 projects
go
31211 projects - #10 most used programming language
typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to guestbook

terraform-aws-ecs-alb-service-task
Terraform module which implements an ECS service which exposes a web service via ALB.
Stars: ✭ 108 (+332%)
Mutual labels:  fargate, terratest
send-test-info
Attach unit test information to exceptions sent by Raven to Sentry
Stars: ✭ 17 (-32%)
Mutual labels:  cypress
amazin
A MERN-stack app for eCommerce platform, Webshop, Web Store. Storybook: https://www.amazin.one/ Alternative: https://ntrix.github.io/amazin-story
Stars: ✭ 27 (+8%)
Mutual labels:  cypress
runiac
Run IaC Anywhere With Ease
Stars: ✭ 18 (-28%)
Mutual labels:  iac
terraform-aws-fargate
Terraform module to provision a Fargate-ready AWS infrastructure 🚀
Stars: ✭ 77 (+208%)
Mutual labels:  fargate
cypress-gh-action-example
Example running Cypress tests inside GitHub Action
Stars: ✭ 29 (+16%)
Mutual labels:  cypress
react-learning-resources
A curated list of resources to learn React and related web technologies as fast as possible.
Stars: ✭ 65 (+160%)
Mutual labels:  cypress
terraform-aws-lb-s3-bucket
Terraform module to provision an S3 bucket with built in IAM policy to allow AWS Load Balancers to ship access logs
Stars: ✭ 29 (+16%)
Mutual labels:  terratest
snapshot
Adds value / object / DOM element snapshot testing support to Cypress test runner
Stars: ✭ 114 (+356%)
Mutual labels:  cypress
aws-ecs-orb
An orb that simplifies deployment to Amazon's Elastic Container Service (ECS). Supports both EC2 and Fargate launch types.
Stars: ✭ 48 (+92%)
Mutual labels:  fargate
gotf
Managing multiple environments with Terraform made easy
Stars: ✭ 25 (+0%)
Mutual labels:  iac
cypress-hyperapp-unit-test
Unit test Hyperapp components using Cypress
Stars: ✭ 26 (+4%)
Mutual labels:  cypress
cypress-example-todomvc-redux
Example TodoMVC application with full code coverage
Stars: ✭ 43 (+72%)
Mutual labels:  cypress
terraform-provider-cisco-aci
Terraform provider for automating Cisco ACI enabled networks
Stars: ✭ 14 (-44%)
Mutual labels:  iac
terraform-aws-rds-cluster
Terraform module to provision an RDS Aurora cluster for MySQL or Postgres
Stars: ✭ 115 (+360%)
Mutual labels:  terratest
cygger
Boilerplate generator for API Testing from Swagger to Cypress
Stars: ✭ 20 (-20%)
Mutual labels:  cypress
on-demand
CloudFormation resources for scheduling On-Demand Buildkite Agents with AWS ECS and AWS Fargate
Stars: ✭ 19 (-24%)
Mutual labels:  fargate
aws-quota-checker
Keep an eye on your AWS quotas before you hit their limits
Stars: ✭ 63 (+152%)
Mutual labels:  iac
firebase-spring-boot-rest-api-authentication
Firebase Spring Boot Rest API Authentication
Stars: ✭ 172 (+588%)
Mutual labels:  cypress
terraform-fargate-tutorial
A minimal set of Terraform to create a Fargate service
Stars: ✭ 32 (+28%)
Mutual labels:  fargate

Guestbook

A simple app with automated infrastructure provisioning, app deployment, and E2E testing.

  • Terraform IaC, modularized and multi-environment
  • Golang JSON+HTTP API server
  • React webapp client
  • Dockerized, horizontally scaled via ECS Fargate
  • DynamoDB
  • E2E Testing with Terratest and Cypress

Table of contents:

Architecture

The frontend and backend applications each run in Docker containers and are horizontally scaled in an ECS Fargate cluster. They sit in private subnets but can be reached through an application load balancer and are able to pull from DockerHub (server and client) via a NAT instance. The backend application stores data in a DynamoDB table. All IAM permissions are provided via IAM roles so that no long-lived access keys exist.

AWS Architecture Diagram for Guestbook Application

Dependencies

  • an AWS account with an IAM user capable of creating the resources. Currently, I have been using AdministratorAccess. Determining the minimum permission scope is on the list of todos (see Next steps).
  • a locally configured AWS profile for the above IAM user
  • Terraform ~> 0.12.0
  • GNU Make

Deployment and Tear Down

This section Deploying the infrastructure and applications to AWS requires just a few commands. Warning: this will create AWS resources that cost money.

Deployment steps

  1. Clone the repo

    git clone [email protected]:brietsparks/guestbook.git
    
  2. In the project root, create a Terraform var-file. Run:

    touch .tfvars
    

    and in the file, set your AWS profile:

    // .tfvars
    profile = <iam-profile>
    

    See the Prod Terraform Inputs for additional optional parameters.

  3. Next, run:

    make prod
    

    When prompted with the Terraform plan, type yes to create the resources. These resources cost money.

  4. After Terraform creates the resources, it will output the load balancer DNS host address:

    alb_dns_host = http://guestbook-server-123456789.us-west-2.elb.amazonaws.com
    

    Wait a minute or two for the ECS task containers to start. Then in the browser, navigate to DNS host address to use the app.

  5. To tear down the app and its AWS resources, run:

    make prod-down
    

    When prompted with the Terraform plan, type yes to destroy the resources.

App demo: a user can view and submit comments for their particular IP address: Guestbook Application Demo GIF

Infrastructure + E2E Testing

On each test run:

  1. Terratest provisions the infrastructure
  2. Cypress runs E2E tests against the deployed frontend application
  3. Terratest deprovisions the infrastructure.

Dependencies

  • the base dependencies
  • Go >=1.14
  • NodeJS >=12.8.1
  • yarn package manager. If you don't have yarn, then run npm install in the /client directory before running the tests.

Testing steps

  1. Follow steps 1 and 2 of the deployment steps above.

  2. In the project root, run:

    make test
    

    When prompted with the Terraform plan, type yes to create the resources.

Deploy dev environment infrastructure

The dev environment creates a DynamoDB table and an IAM user+role that can access the table. Terraform outputs the credentials which the backend app can use for local development.

Steps:

  1. In the project root, create a Terraform var-file and set the profile. See the Dev Terraform Inputs for additional optional parameters.

  2. Run:

    make dev
    
  3. After Terraform creates the resources, it will output the IAM config and credentials for accessing the database:

    Outputs:
    
    cli_config = 
    [local_dev_user]
    region = us-west-2
    
    [local_dev_user_role]
    role_arn = arn:aws:iam::0123456789012:role/dynamodb_data_access_role_dev
    source_profile = local_dev_user
    
    cli_credentials = 
    [local_dev_user]
    aws_access_key_id = <key>
    aws_secret_access_key = <secret>
    
  4. Paste the config and credential entries into your local shared AWS config and credentials files (in ~/.aws)

  5. You can now run the server locally using the deployed dev database. See the steps for using the server locally.

  6. To tear down the dev infrastructure, run:

    make down-down
    

    When prompted with the Terraform plan, type yes to destroy the resources.

Next steps

Here are a few things that should be done next:

  • CI/CD pipeline
  • HTTPS via ELB SSL termination
  • VPC endpoints for DynamoDB
  • implement VPC without 3rd party module
  • minimize permission scope of TF AWS profile
  • vendor-neutral rewrite

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].