Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save glaszczak/8ec0f0bbdf4aecbf5f9b925b6e7abf01 to your computer and use it in GitHub Desktop.

Select an option

Save glaszczak/8ec0f0bbdf4aecbf5f9b925b6e7abf01 to your computer and use it in GitHub Desktop.

Revisions

  1. glaszczak revised this gist Jun 5, 2020. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Reaction Commerce 3 deploy on AWS using terraform - variables explanation

    [GitHub repository](https://github.com/Selleo/reaction-commerce-deployment).
    [GitHub repository](https://github.com/Selleo/reaction-commerce-deployment)

    ---

  2. glaszczak revised this gist Jun 5, 2020. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -153,7 +153,7 @@ Additional variable - always when AWS region is mentioned:

    ---

    # Repo paths
    ## Repo paths

    `admin_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-admin"

  3. glaszczak revised this gist Jun 5, 2020. 1 changed file with 6 additions and 10 deletions.
    Original file line number Diff line number Diff line change
    @@ -56,9 +56,7 @@

    # 📗 Variables explanation

    ## MongoDB Atlas Variables

    # Mongo
    ## MongoDB

    `atlas_mongo_public_key` => MongoDB Atlas API public_key which should be created by user > Go to MongoDB Atlas account > Projects > Access Manager > Api Keys tab > Create API Key or select existing

    @@ -103,23 +101,23 @@ Additional variable - always when AWS region is mentioned:

    ---

    # Backend
    ## Backend

    `stripe_secret_key` => your Stripe API secret key

    - [stripe Log in](https://stripe.com/) > Dashboard > Developers > API keys > Create secret key or use existing Secret key

    ---

    # Hydra
    ## Hydra

    `ocid_subject_identifiers_pairwise_salt` => Generate ocid subject identifier

    `secret_system` => Generate session secret

    ---

    # Frontend
    ## Frontend

    `oauth2_client_secret` => Generate oauth client secret

    @@ -131,15 +129,13 @@ Additional variable - always when AWS region is mentioned:

    ---

    # Route53
    ## Route53

    `domain_name` => http://yoursite.com

    ---

    ## PostgreSQL Variables

    # Postgres
    ## Postgres

    `postgres_identifier` = "hydra" (Set itentifier - can be the same as database name)

  4. glaszczak revised this gist Jun 5, 2020. 1 changed file with 4 additions and 4 deletions.
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    ---

    # 📦 Reaction Commerce
    # 💡 Reaction Commerce

    [Reaction Commerce repository](https://github.com/reactioncommerce)

    @@ -31,7 +31,7 @@

    ---

    # Steps that has to be done (all using automation scripts by terraform)
    # 💻 Steps that has to be done (all using automation scripts by terraform)

    ## MongoDB

    @@ -54,7 +54,7 @@

    ---

    # Variables explanation
    # 📗 Variables explanation

    ## MongoDB Atlas Variables

    @@ -177,7 +177,7 @@ Additional variable - always when AWS region is mentioned:

    ---

    ## Helpful Links
    # 🔗 Helpful Links

    ---

  5. glaszczak revised this gist Jun 5, 2020. 1 changed file with 2 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,15 @@

    ---

    # Reaction Commerce
    # 📦 Reaction Commerce

    [Reaction Commerce repository](https://github.com/reactioncommerce)

    [Deploying Reaction Commerce 3 on AWS ECS Tutorial](https://university.outgrow.io/courses/enrolled/802219)

    ---

    # Prerequisites
    # 💡 Prerequisites

    1. To run Reaction Commerce locally download repository -> [Reaction Commerce Repository](https://github.com/reactioncommerce/reaction-development-platform)

  6. glaszczak revised this gist Jun 5, 2020. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -171,7 +171,7 @@ Additional variable - always when AWS region is mentioned:

    ---

    ## Other Arguments Explanation
    ## Other variables explanation

    `local-exec commands` > Get commands to build docker images based on each repository > Go to AWS Console > Services > ECR > Select repository > View push commands

  7. glaszczak revised this gist Jun 5, 2020. 1 changed file with 2 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -155,6 +155,8 @@ Additional variable - always when AWS region is mentioned:

    `postgres_port` => Default port for PostgreSQL: 5432

    ---

    # Repo paths

    `admin_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-admin"
  8. glaszczak revised this gist Jun 5, 2020. 1 changed file with 1 addition and 5 deletions.
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@
    7. Deploy Identity API
    8. Deploy Admin panel

    ## External provider (Vercel?)
    ## External provider (e.g. Vercel)

    1. Deploy Storefront

    @@ -155,10 +155,6 @@ Additional variable - always when AWS region is mentioned:

    `postgres_port` => Default port for PostgreSQL: 5432

    ---

    ## OTHER

    # Repo paths

    `admin_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-admin"
  9. glaszczak revised this gist Jun 5, 2020. 1 changed file with 0 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -54,8 +54,6 @@

    ---

    ---

    # Variables explanation

    ## MongoDB Atlas Variables
  10. glaszczak created this gist Jun 5, 2020.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,272 @@
    # Reaction Commerce 3 deploy on AWS using terraform - variables explanation

    [GitHub repository](https://github.com/Selleo/reaction-commerce-deployment).

    ---

    # Reaction Commerce

    [Reaction Commerce repository](https://github.com/reactioncommerce)

    [Deploying Reaction Commerce 3 on AWS ECS Tutorial](https://university.outgrow.io/courses/enrolled/802219)

    ---

    # Prerequisites

    1. To run Reaction Commerce locally download repository -> [Reaction Commerce Repository](https://github.com/reactioncommerce/reaction-development-platform)

    2. You will need the following tools installed on your computer:

    - [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
    - [Docker](https://www.docker.com/)
    - [Terraform](https://www.terraform.io/)

    3. You need to register on platrofrms:

    - [Amazon Web Services](https://aws.amazon.com/)
    - [MongoDB Atlas](https://www.mongodb.com/cloud/atlas)

    4. Also AWS or external domain is needed!

    ---

    # Steps that has to be done (all using automation scripts by terraform)

    ## MongoDB

    1. Create MongoDB cluster on MongoDB Atlas and connect it with AWS

    ## AWS

    1. Create Hydra PostgreSQL database
    2. Build Docker images and push them to ECR
    3. Setup Load Balancers
    4. Setup ECS cluster
    5. Deploy Reaction Commerce API (backend)
    6. Deploy Hydra's API
    7. Deploy Identity API
    8. Deploy Admin panel

    ## External provider (Vercel?)

    1. Deploy Storefront

    ---

    ---

    # Variables explanation

    ## MongoDB Atlas Variables

    # Mongo

    `atlas_mongo_public_key` => MongoDB Atlas API public_key which should be created by user > Go to MongoDB Atlas account > Projects > Access Manager > Api Keys tab > Create API Key or select existing

    `atlas_mongo_private_key` => Same section as above

    `atlas_org_id` => Go to MongoDB Atlas account > Select Settings Icon > Settings > Copy Organization ID

    `mongo_user_name` = Your MongoDB user name

    `mongo_user_password` = Your MongoDB password

    `mongo_database_name` = "reaction"

    `mongo_local_database_name` = "local"

    Variables in the file `mongo.tf`:

    - `cidr_block` => Go to MongoDB Atlas account > Projects > Select Project > Network Access > IP Whitelist tab > Copy existing address or create new ("0.0.0.0/0" allows connection from any IP)

    - `atlas_cidr_block` => Go to MongoDB Atlas account > Projects > Select Project > Network Access > Peering tab > Add Peering Connection or Select existing > For new Peering Connection Select aws > copy VPC CIDR

    ---

    ## AWS Variables

    `aws_account_id` => Go to AWS Console > Select 'My Account' (top dropdown mentu for current user) > Copy 'Account Id'

    Variables in the file `vpc.tf`:

    - `cidr_block`

    - for resource "aws_vpc" => Go to AWS Console > Services > VPC > Your VPCs (left menu) > Select 'IPv4 CIDR' field for specific VPC
    - for each resource "aws_subnet" => for subnets replace /16 with /24 and set different IP for each subnet (example: "0.0.10.0/24", "0.0.20.0/24", "0.0.30.0/24")

    - `destination_cidr_block`
    - for each resource "aws_route" "...-gateway" => "0.0.0.0/0"
    - for each resource "aws_route" "...-mongo" => Go to MongoDB Atlas account > Projects > Select Project > Network Access > Peering tab > Add Peering Connection or Select existing > For new Peering Connection Select aws > copy VPC CIDR

    Additional variable - always when AWS region is mentioned:

    `aws_region` => Name of the AWS region selected by user in AWS console (e.x. "eu-central-1")

    ---

    # Backend

    `stripe_secret_key` => your Stripe API secret key

    - [stripe Log in](https://stripe.com/) > Dashboard > Developers > API keys > Create secret key or use existing Secret key

    ---

    # Hydra

    `ocid_subject_identifiers_pairwise_salt` => Generate ocid subject identifier

    `secret_system` => Generate session secret

    ---

    # Frontend

    `oauth2_client_secret` => Generate oauth client secret

    `session_secret` => Generate session secret (different from OAUTH2_CLIENT_SECRET)

    `stripe_public_api_key` => your Stripe API public key

    - [stripe Log in](https://stripe.com/) > Dashboard > Developers > API keys > Create secret key or use existing Publishable key

    ---

    # Route53

    `domain_name` => http://yoursite.com

    ---

    ## PostgreSQL Variables

    # Postgres

    `postgres_identifier` = "hydra" (Set itentifier - can be the same as database name)

    `postgres_database_name` = "hydra"

    `postgres_username` = "postgres"

    `postgres_password` => Set database unique password

    `postgres_instance_name` => Unique name cross all DB instances owned by current AWS account

    `postgres_db_password` => Generate password

    `postgres_port` => Default port for PostgreSQL: 5432

    ---

    ## OTHER

    # Repo paths

    `admin_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-admin"

    `backend_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction"

    `identity_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-identity"

    `hydra_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-hydra"

    `storefront_repo_path` => External; In our case: "User/<user-name>/projects/<project-name>/reaction-storefront"

    ---

    ## Other Arguments Explanation

    `local-exec commands` > Get commands to build docker images based on each repository > Go to AWS Console > Services > ECR > Select repository > View push commands

    ---

    ## Helpful Links

    ---

    AWS

    [AWS Working with VPCs and subnets](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-vpcs.html)

    [AWS ECS](https://github.com/arminc/terraform-ecs)

    [Redirects with AWS ALB using terraform](https://letslearndevops.com/2019/08/20/aws-alb-redirect/)

    [AWS What is VPC peering](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html)

    [AWS VPCs and subnets](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html#vpc-sizing-ipv4)

    ---

    Terraform

    [Terraform Environment Variables](https://www.terraform.io/docs/commands/environment-variables.html)

    [AWS Provider](https://www.terraform.io/docs/providers/aws/index.html)

    [MongoDB Atlas Provider](https://www.terraform.io/docs/providers/mongodbatlas/index.html)

    [PostgreSQL Provider](https://www.terraform.io/docs/providers/postgresql/index.html)

    ---

    Terraform Resources

    [aws_ecr_repository](https://www.terraform.io/docs/providers/aws/r/ecr_repository.html)

    [aws_ecs_cluster](https://www.terraform.io/docs/providers/aws/r/ecs_cluster.html)

    [aws_lb_listener](https://www.terraform.io/docs/providers/aws/r/lb_listener.html)

    [aws_lb_target_group](https://www.terraform.io/docs/providers/aws/r/lb_target_group.html)

    [aws_eip (Elastic IP)](https://www.terraform.io/docs/providers/aws/r/eip.html)

    [aws_ecs_task_definition](https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html)

    [aws_lb](https://www.terraform.io/docs/providers/aws/r/lb.html)

    [aws_lb_target_group](https://www.terraform.io/docs/providers/aws/r/lb_target_group.html)

    [aws_lb (Application Load Balancer)](https://www.terraform.io/docs/providers/aws/r/lb.html)

    [aws_db_security_group](https://www.terraform.io/docs/providers/aws/r/db_security_group.html)

    [postgresql_role](https://www.terraform.io/docs/providers/postgresql/r/postgresql_role.html)

    [aws_db_instance](https://www.terraform.io/docs/providers/aws/r/db_instance.html)

    [aws_acm_certificate](https://www.terraform.io/docs/providers/aws/r/acm_certificate.html)

    [mongodbatlas_project](https://www.terraform.io/docs/providers/mongodbatlas/r/project.html)

    [mongodbatlas_cluster](https://www.terraform.io/docs/providers/mongodbatlas/r/cluster.html)

    [mongodbatlas_network_container](https://www.terraform.io/docs/providers/mongodbatlas/r/network_container.html)

    [mongodbatlas_network_peering](https://www.terraform.io/docs/providers/mongodbatlas/r/network_peering.html)

    ---

    Terraform Data Source

    [aws_lb_listener](https://www.terraform.io/docs/providers/aws/d/lb_listener.html)

    [aws_vpc](https://www.terraform.io/docs/providers/aws/d/vpc.html)

    ---

    Other

    [Configure Atlas API Access](https://docs.atlas.mongodb.com/configure-api-access/)

    [HOW TO CREATE A VPC WITH TERRAFORM](https://letslearndevops.com/2017/07/24/how-to-create-a-vpc-with-terraform/)

    [ECS Deployment](https://github.com/arminc/terraform-ecs/blob/master/deployment/README.md)

    [Setup a Container Cluster on AWS with Terraform](http://blog.shippable.com/setup-a-container-cluster-on-aws-with-terraform-part-2-provision-a-cluster)

    [ECS cluster with dynamic port mappings using terraform](https://letslearndevops.com/2018/12/24/ecs-cluster/)

    [How to create an ECS Cluster with Terrafrom](https://github.com/markdavidburke/ECS-Cluster)