Setting up Development, staging and prod environments

My question may sound like its been asked before. But questions are focussed mostly on environmental variables and different aws profiles but this question is more pointed towards architecting a serverless workflow from dev to production.

Requirement :
Simple I want to setup 3 individual environments dev, staging and prod with serverless infrastructure.

Proposed Solution (from blog and forum) :
Aws advices us to have separate accounts with consolidated billing for each new environment.

Infrastructure Overview

  1. Frontend in Angularjs 2.0 served via S3 / Cloudfront.
  2. Dynamodb used for database.
  3. Serverless Lambda functions used for backend.
  4. AWS Codecommit used for git repository.

So i created AWS_DEV, AWS _STAGING & AWS_PROD accounts.

I ran into couple of problems while implementing the environments :

1. Domain Routing :

Ideal domains i would like to have are

WEBSITE :

DEV : dev.example.com
STAGING : staging.example.com
PROD : www.example.com

API :

DEV : dev-api.example.com
STAGING : staging-api.example.com
PROD : api.example.com

Doubts for WEBSITE :

example.com is been operated with Route53 in AWS_PROD account. So i can point

AWS_PROD ROUTE 53 => AWS_PROD S3 bucket to show website.

But how do i do the same for dev and staging environment ?

Since Domain exists only in PROD Route 53 , how can we point the it to DEV / STAGING S3 bucket ?

In the above scenario how would we have custom domain urls for all 3 environments ?

2. Continous Integration / Continous Deployment

I am using aws Code Commit to store my code in git repository.

Sample Workflow :
A simple deployment workflow can be pull the code from codecommit git repo, run tests and deploy the files in S3 bucket.

In this case which environment should my git repo exist ? Also there is an limitation where i cannot access AWS_DEV git repo in AWS_PROD environment.

A simple solution can be done here by storing my git repositories with some other providers. But if i would like to use AWS CodeCommit. How do we resolve this issue ?

1 Like

It’s hard to answer this in a general sense. I’ll give you what I’m doing though:

I have an ownership account which manages DNS, cloudtrail, etc. I have a CI account and a prod account for the app. I run my staging workflows from my CI account. Right now, DNS is manual (I update the ALIAS entry in the ownership account once the stacks have been created in the CI or prod account).

I have code-pipelines in both my CI and my prod accounts. CI does the build, puts it on staging, etc. There is then an approval stage. When approval is authorized, I have a custom Lambda function that moves the code into a production S3 Bucket. I then have a pipeline in production that builds the code from S3 (as opposed to github).

2 Likes