Top AWS CloudFormation Interview Questions (2020) | CodeUsingJava

Most likely asked AWS CloudFormation Interview Questions

What is AWS CloudFormation ?

  • AWS CloudFormation is a service that helps you model and set up your Amazon Web Services resources so that you spend less time managing your resources and more time focusing on your applications that run in AWS.
  • It is useful if you have to launch the same type of infrastructure multiple times and simplifies provisioning and management on AWS.
  • AWS CloudFormation is a configuration orchestration tool that allows you to modify your infrastructure to automate your deployments.
  • AWS CloudFormation gives developers and systems administrators an easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion.

Explain CloudFormation's working model ?

  • Firstly we have to code our infrastructure in a YAML or JSON text-based file which is called a template.
  • Then locally we write our code in the AWS CloudFormation tool. Otherwise we can upload a YAML or JSON file into the S3 bucket.
  • Next use the GUI of AWS CF or the Command Line Interface to create a stack based on our template code.
  • At last, CloudFormation will deploy resources, provision it and configures the template which we specified.

What are benefits of AWS CloudFormation ?

  • All code: Treat your infrastructure as a code which simplifies and makes it easy to modify and do changes accordingly.
  • Automation of Infrastructure: We do not have to work on provisioning resources, we only need to make his application better. All the provisioning and managing of resources will be taken care of by CloudFormation
  • Safety controls: The controls are automated to reduce effort and increase quality and performance.
  • Extensibility: CloudFormation stack provides an extensible mechanism to make our own extensions and add it to the CloudFormation template. Custom provisioning of extensions can be developed for a third party resource.
  • Customization through parameters.

What is a circular dependency in AWS CloudFormation ?

    There is interleaved dependency between two resources.
  • Resource X is dependent on Resource Y, and Resource Y is dependent on Resource X.
  • When this type of situation occurs, you will get a circular dependency error because AWS CloudFormation is unable to clearly determine which resource should be created first.
  • The AWS CloudFormation circular dependency can be caused by interactions between services that cause them to be mutually dependent.

How to solve circular dependency error in AWS CloudFormation ?

  • When two are dependent on one another we will get a circular dependency error because AWS CloudFormation is unable to clearly determine which resource should be created first
  • The first step is to examine the resources that are outlined and make sure that AWS CloudFormation can determine what resource order it should take.
  • To resolve a dependency error, add a DependsOn attribute to resources that depend on other resources in your template.
  • Using DependsOn, we can specify that a particular resource needs to be created before the other resource.

How can you create and delete stacks of AWS ?

  • In AWS CloudFormation related resources are managed as a single unit called a stack.
  • It is possible to create, update, and delete a collection of resources by creating, updating, and deleting stacks.
  • All the resources in a stack are defined by the stack's AWS CloudFormation template.

What does AWS Serverless Application Model add on top of CloudFormation ?

  • AWS Serverless Application Model is an open-source framework you can use to build serverless applications on AWS.
  • AWS SAM has a template which is used to define serverless application
  • AWS CloudFormation enables you to create a template that defines your application's resources and lets you manage the application as a stack.
  • You create a template that describes all the AWS resources that you want and AWS CloudFormation takes care of further provisioning and configuring those resources for you.
  • AWS SAM is basically an extension for the AWS CloudFormation template language that lets you define serverless AWS Lambda applications at a higher level.
  • It helps CloudFormation to setup things for serverless applications and their deployment.
  • It automates common tasks such as function role creation, and makes it easier to write CloudFormation templates for your serverless applications.

How does AWS Cloud Pipeline interact with CloudFormation ?

  • You can use AWS CodePipeline to trigger a Cloud Formation template to run in the deployment phase.
  • The pipeline has following stages:
  • Source phase: Fetch the latest commit.
  • Build phase: Build the code into a docker image and push it to ECR.
  • Deploy phase: Take the latest docker image from ECR, deploy it to ECS

How are shell scripts used with AWS CloudFormation templates ?

    EC2 instances can run shell scripts when they are launched using CloudFormation.
  • Provide commands in user data section while launching an instance
  • If instance is a part of auto scaling group,user data can also be provided using launch configuration
  • We can use CodeDeploy for deploying apps on EC2 instances and it requires shell scripts to follow intended actions.