0 votes
in AWS by

You're in charge of creating a cloud formation template. This template needs to create resources for multiple types of environments. The template needs to be flexible so that it can create resources based on the type of environment.

How can you achieve this? Choose 2 answers from the options given below.

1 Answer

0 votes
by

Answer - A and D.

This is given in the AWS Documentation.

The optional Conditions section contains statements that define the circumstances under which entities are created or configured.

For example, you can create a condition and then associate it with a resource or output so that AWS CloudFormation only creates the resource or output if the condition is true.

Similarly, you can associate the condition with a property so that AWS CloudFormation only sets the property to a specific value if the condition is true.

If the condition is false, AWS CloudFormation sets the property to a different value that you specify.

You might use conditions when you want to reuse a template that can create resources in different contexts, such as a test environment versus a production environment.

You can add an EnvironmentType input parameter in your template, which accepts either prod or test as inputs.

Since this is clearly given in the documentation, all other options are incorrect.

For more information on conditions in a Cloudformation template, please refer to the below URL-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html

To create a CloudFormation template that can create resources for multiple types of environments, the following approaches can be taken:

A. Create an Input Parameter to take in the type of environment: This approach involves creating an Input Parameter in the template that can take in the type of environment as input during the stack creation process. The parameter can be defined in the Parameters section of the template, and its value can be used to conditionally create resources based on the type of environment. For example, if the input parameter is set to 'development', the template can create resources suitable for a development environment, and if it is set to 'production', resources suitable for a production environment can be created.

D. Use the Conditions section to create resources based on the type of environment: This approach involves defining conditions in the Conditions section of the CloudFormation template based on the type of environment. These conditions can then be used to conditionally create resources in the Resources section of the template. For example, if the environment is 'development', a certain resource can be created, and if it is 'production', a different resource can be created. The conditions can be defined based on input parameters, environment variables, or any other criteria.

B. Use the Outputs section to define the type of environment: The Outputs section in a CloudFormation template can be used to define the type of environment based on the resources created by the template. This approach involves defining output values that can indicate the type of environment, such as a URL for a web application deployed in a certain environment. These output values can then be used by other CloudFormation stacks or AWS services to conditionally create resources based on the type of environment.

C. Use the Custom Resources feature to create resources based on the type of environment: The Custom Resources feature in CloudFormation can be used to create custom resources based on the type of environment. This approach involves writing custom code, such as Lambda functions, that can be used to conditionally create resources based on the input parameters or other criteria. The custom resources can then be defined in the Resources section of the CloudFormation template.

In summary, options A and D are the correct answers, as they involve creating input parameters and defining conditions in the CloudFormation template to create resources based on the type of environment. Option B is not the best approach, as it involves defining the type of environment based on output values, which may not be the most flexible solution. Option C is also a valid approach, but it involves writing custom code, which may be more complex than necessary for this use case.

...