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
- Frontend in Angularjs 2.0 served via S3 / Cloudfront.
- Dynamodb used for database.
- Serverless Lambda functions used for backend.
- 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 ?