- (Exam Topic 4)
In the below configuration, how would you reference the module output vpc_id?
Type your answer in the field provided. The text field is not case sensitive and all variations of the correct answer are accepted.
Solution:
https://cloudcasts.io/course/terraform/community-vpc-module
Does this meet the goal?
Correct Answer:A
- (Exam Topic 1)
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers?
Correct Answer:D
"Within the module that declared a variable, its value can be accessed from within expressions as var.<NAME>, where <NAME> matches the label given in the declaration block:
Note: Input variables are created by a variable block, but you reference them as attributes on an object named var."
https://www.terraform.io/language/values/variables#using-input-variable-values
- (Exam Topic 4)
Consider the following Terraform 0.12 configuration snippet:
* 1. variable "vpc_cidrs" {
* 2. type = map
* 3. default = {
* 4. us-east-1 = "10.0.0.0/16"
* 5. us-east-2 = "10.1.0.0/16"
* 6. us-west-1 = "10.2.0.0/16"
* 7. us-west-2 = "10.3.0.0/16"
* 8. }
* 9. }
* 10.
* 11. resource "aws_vpc" "shared" {
* 12. cidr_block = ______
* 13. }
How would you define the cidr_block for us-east-1 in the aws_vpc resource using a variable?
Correct Answer:C
- (Exam Topic 4)
Named workspaces are not a suitable isolation mechanism for strong separation between staging and production?
Correct Answer:A
Organizations commonly want to create a strong separation between multiple deployments of the same infrastructure serving different development stages (e.g. staging vs. production) or different internal teams. In this case, the backend used for each deployment often belongs to that deployment, with different credentials and access controls. Named workspaces are not a suitable isolation mechanism for this scenario.
https://www.terraform.io/docs/state/workspaces.html#when-to-use-multiple-workspaces
- (Exam Topic 4)
What does terraform refresh modify?
Correct Answer:B
The terraform refresh command reads the current settings from all managed remote objects and updates the Terraform state to match. Source: https://www.terraform.io/cli/commands/refresh
- (Exam Topic 2)
True or False: A list(...) contain a number of values of the same type while an object(...) can contain a number of values of different types.
Correct Answer:B
Collection Types
A collection type allows multiple values of one other type to be grouped together as a single value. The type of value within a collection is called its element type. All collection types must have an element type, which is provided as the argument to their constructor.
For example, the type list(string) means "list of strings", which is a different type than list(number), a list of numbers. All elements of a collection must always be of the same type.
The three kinds of collection type in the Terraform language are:
* list(...): a sequence of values identified by consecutive whole numbers starting with zero.
The keyword list is a shorthand for list(any), which accepts any element type as long as every element is the same type. This is for compatibility with older configurations; for new code, we recommend using the full form.
* map(...): a collection of values where each is identified by a string label.
The keyword map is a shorthand for map(any), which accepts any element type as long as every element is the same type. This is for compatibility with older configurations; for new code, we recommend using the full form.
* set(...): a collection of unique values that do not have any secondary identifiers or ordering. https://www.terraform.io/docs/configuration/types.html
Structural Types
A structural type allows multiple values of several distinct types to be grouped together as a single value. Structural types require a schema as an argument, to specify which types are allowed for which elements.
The two kinds of structural type in the Terraform language are:
* object(...): a collection of named attributes that each have their own type.
The schema for object types is {
* tuple(...): a sequence of elements identified by consecutive whole numbers starting with zero, where each element has its own type.
The schema for tuple types is [
comma-separated series of types. Values that match the tuple type must have exactly the same number of elements (no
more and no fewer), and the value in each position must match the specified type for that position.
For example: an object type of object({ name=string, age=number }) would match a value like the following:
{
name = "John" age = 52
}
Also, an object type of object({ id=string, cidr_block=string }) would match the object produced by a reference to an aws_vpc resource, like aws_vpc.example_vpc; although the resource has additional attributes, they would be discarded during type conversion.
Finally, a tuple type of tuple([string, number, bool]) would match a value like the following: ["a", 15, true]
https://www.terraform.io/docs/configuration/types.html