Cloud and Container Basics

An environment was created by applying, with a declarative IaC (Infrastructure as Code) tool, a file that defines a network and two virtual machines. Immediately afterwards, the same file is applied again without any changes. Which of the following is what happens?

  1. AThere is no difference between the definition and the actual state, so nothing is changed
  2. BAnother identical set is created, giving four virtual machines
  3. CBecause the environment already exists, the second apply stops with an error
Show answer and explanation

Answer: A. There is no difference between the definition and the actual state, so nothing is changed

With declarative IaC, the code describes the desired configuration rather than the steps, and the tool compares it with the actual state and creates, changes or deletes only what differs. Applying the same definition any number of times therefore gives the same result (idempotence), and the second apply changes nothing. If someone changes a setting by hand and the actual state drifts from the definition (configuration drift), the next apply brings it back to the defined state. Managing the definitions in Git also allows history checks and reviews in the same way as for programs.

  • A. Correct. Only the differences are changed, so applying the same definition any number of times leads to the same state.
  • B. This could happen if a script describing the creation steps were run twice. A declarative tool does not recreate what already exists.
  • C. A declarative tool compares existing resources with the definition and does nothing if there is no difference.
Practice this topic Back to topic

Books on Cloud and Container Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Cloud and Container Basics questions

  1. Which of the following is an appropriate way to update the software on production servers in line with the idea of immutable infrastructure?
  2. Two environments with the same configuration as production are prepared; the current version keeps running in one while the new version is installed and checked in the other, and then the load balancer is switched over to it all at once. If there is a problem, switching back quickly returns to the old version. Which of the following is this release method?
  3. A service that receives 12,000 requests per hour performs a canary release of a new version, sending only 5% of the requests to it. The new version has a bug that makes 3% of the requests it receives fail; it is noticed after one hour, and all requests are returned to the old version. Which of the following is the number of requests that failed because of the bug during that hour?
  4. A container image built by a CI/CD pipeline was tested in the staging environment and passed. Which of the following is the most appropriate way to release this image to production?
  5. As shown above, the database connection target is not written into the image but passed as an environment variable when the container starts. Which of the following is the most appropriate main advantage of this design?