You are a developer for your company.
You are working on creating Cloudformation templates for different environments.
You want to be able to base the creation of the environments on the values passed at runtime to the template.
How can you achieve this?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - B.
You can use the Parameters section to take in values at runtime.
You can then use the values of those parameters to define how the template gets executed.
The AWS Documentation also mentions the following.
Parameters (optional)
"Values to pass to your template at runtime (when you create or update a stack)
You can refer to parameters from the Resources and Outputs sections of the template".
Option A is invalid since this is used to describes the values that are returned whenever you view your stack's properties.
Option C is invalid since this is used to specify objects that provide additional information about the template.
Option D is invalid since this is used to specify options for the SAM Model.
For more information on the working of cloud formation templates, please refer to the below URL-
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.htmlThe correct answer is B. Specify a parameters section.
CloudFormation templates allow you to create infrastructure as code, which can be versioned, reviewed, and tested like any other code. The Parameters section of the CloudFormation template allows you to pass runtime values into the template at the time of stack creation or update. By using parameters, you can make your templates more reusable, as the same template can be used for different environments with different input values.
Here's an example of a CloudFormation template with a Parameters section:
yamlParameters: EnvironmentType: Type: String Default: Dev AllowedValues: - Dev - Prod
In this example, we define a parameter named EnvironmentType
of type String
. We also set a default value of Dev
, and specify that only Dev
and Prod
are allowed values.
When the template is run, the user will be prompted to enter a value for the EnvironmentType
parameter. The user can enter either Dev
or Prod
, and the CloudFormation stack will be created accordingly.
To summarize, the Parameters section of a CloudFormation template allows you to pass runtime values into the template at the time of stack creation or update, making your templates more reusable and flexible.