Posts AWS automation options

AWS automation options


We been asked below question by one of our dear friend

Using python boto3 client we can create vpc with designated IP, creating load balancer in a public subnet and EC2 instances in private subnet, autoscaling it etc.
1. Using cloudformation same can be achieved (aws bound)
2. Using terraform same can be achieved (multi cloud support.let’s assume here we use only AWS)
What I don’t understand is
1. which technique is efficient among the three..
2. Why is that efficient?

To summarise the question , all 3 methods are there to achieve the same goal , achieve Infra as code but which one to choose when.

Here we can categorise python boto3 , AWS CLI into one category and Terraform , Cloudformation into other

Terraform and Cloudformation

The advantage of going for Terraform / Cloudformation is you can template the resources (eg: VPC, EC2 etc) and can create as many resources , the beauty here is each resources created from template is tracked and once we delete them the resource created from it also will be deleted.

So the use case here is:

  • Whenever you need to template your resources and track them
  • You don’t need to worry about what all components created from the template and can be created and destroyed at fraction for seconds

People generally choose Terraform over Cloudformation majorly for below reasons

  • Terraform supports multi cloud
  • Terraform has strong community and anyone can release custom providers, so if any new service available in AWS, it will be available first in Terraform and takes time to arrive in Cloudformation

Cloudformation has upper hand in few services like AMI deployment

AWS CLI , Python ..

  • These are used for light usage / single operation, like rebooting the server
  • AWS CLI comes handy to query info about AWS resources
     $ aws s3 ls

    above list all S3 buckets in your account, so you can get info of S3 without even logging into console at fingertips.

  • Python you can onboard it to Lambda for your automation. Scenarios: Linking Lambda with Cloudwatch alarm to stop / start the instances

To summarise

  • AWS CLI -> To query info of AWS services from local machine on the fly
  • Python -> Link with Lambda and use it for modification to existing resources
  • Cloudformation / Terraform ->
    • To create resources
    • To Track what all resources been created
    • To enable templates and make developers life easy

Hope you find this helpful. Thanks for reading till the end.

Followus on insta @techpechu

Join Our Discord

We do run a youtube channel in Indian regional language Tamil called TechPechu. Do subscribe to us for moral support. Happy Learning.

Follow us on instagram @techpechu