News! Tech related notes are NOW published
to ShippingBytes.
See you there! I always felt this was not the right place for me to write
consistently about tech and tools. So if you want to read more about that see
you at the other side
Hey! I see you use an adblocker as I do as
well! I use Carbon Adv to support this tiny website a network with developers
in mind. Please consider disabling the adblocker for this website to support my
work.
There are few environments during my developer workflow, today I chose a little example:
Production enviroment always exists, it runs the stable application and you can not use it for your test.
Staging enviroment is a “pre-production” state.
Develop enviroment is instable and it runs new features and fixes, here there’s the work of all team but it’s not ready to go in production.
Staging environment in my opinion could be “volatile” version, we use it when our product is ready to go in production for the last time it was unused. Maybe this statement isn’t real in your work but if you think a little team of consultants that
work on different projects maybe this words have a sense.
AWS Cloudformation
CloudFormation is an AWS service that helps you to orchestate all AWS services, you can write a template in JSON and you can use it to create an infrastructure with one click.
This solution helps me to build and destroy this environment and we can pay it only if it’s necessary, if you use a stagin env == production env it can be very very expensive.
This solution could help you to down cost.
Current infrastructure
This is my template to build a simple application Frontend + MySQL (RDS).
In this implementation I build network configuration and I create one instance of RDS and one EC2 (my frontend).
Parameters key is the list of external parameters that I can use to configure my template, for example database and EC2 key pair, my root’s password..
Resources key contains description of all actors of this infrastructure.
Conclusion
You can load this teamplate in your account and after environment creations you are ready to work with one EC2 instance and one RDS with MySQL 5.6 installed.
You can log into the web interface with key-pair chosen during the creation flow (default ga-eu) and I set default this mysql credential:
user gianarb
password test1234
But you can change it before running this template because they are Parameters.
This approach in my opinion is very powerful because you can start versioning your infrastructure and you can delete and restore it quickly because if you delete the cloudformation stack it rollbacks all resources, it is very easy!
Trick
Parameters node create a form into the AWS CloudFormation console to choose a lot of different variable values, for example name of intances or key-pair to log in your EC2.
Resources node contains all elements of your infrastructure, EC2, RDS, VCP.. You can use the parameteters with a simple Ref Key.
es. [{"Key": "Name", "Value": "ProjectName"}] describe the name of the specific project into the parameter form.
In your template you can describe VPC and create its subnet. You can also describe the specific resource and you can use it to build another
In this example I resumed Staging VPC to build its subnet.
This chapter is insteresting because it creates a RecordSet to map a CNAME DNS in your VPC and now in your Web instances you can resolve MYSql host with db.app.staging.