Courseiva

AWS provider · topic practice

Dynamic HCL Configuration practice questions

Dynamic HCL Configuration covers expressions, variables, validation, and dynamic blocks in Terraform. Questions present real HCL snippets and ask you to choose correct syntax, predict plan/apply behavior, or fix errors. You must reason about type constraints, for expressions, validation rules, and nested dynamic blocks using the AWS provider.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: Dynamic HCL Configuration

What the exam tests

What to know about Dynamic HCL Configuration

You must read and write HCL that passes typed objects to modules, validates inputs with condition and error_message, transforms collections with for expressions, and generates nested blocks dynamically. The critical skill is matching type constraints and validation conditions to the actual data shape.

Defining complex object type constraints in variable blocks with optional() and required attributes

Using for expressions to transform lists, maps, and sets into new collections

Writing variable validation blocks with condition and error_message to reject invalid plans

Building dynamic blocks that generate aws_security_group ingress rules from list objects

Watch out for

Common Dynamic HCL Configuration exam traps

  • ▸Confusing for expressions with for_each meta-argument, producing invalid syntax or wrong iteration behavior
  • ▸Omitting optional() in object type constraints, causing errors when callers pass partial objects
  • ▸Placing validation in the wrong block or using a condition that references unavailable values at plan time

Practice set

Dynamic HCL Configuration questions

20 questions · select your answer, then reveal the explanation

You are using a dynamic block to define multiple 'tag' blocks inside an AWS resource. The dynamic block is failing because it expects a set of objects but receives a flat list. Which function best prepares your data?

You have a list of strings that you want to convert into a set to use with for_each. Which function is preferred?

In HCL, how do you handle a scenario where a variable might be null but you need to provide a non-null default value for a resource argument?

When defining a variable with a complex type, which keyword allows you to define a flexible schema where keys are strings and values are a specific type?

You are using a 'for' expression to transform a map. How do you ensure the resulting object is a map and not a list?

Which of the following is true regarding the 'content' block inside a dynamic block?

You are writing a module that accepts a list of objects. You want to validate that the 'port' attribute in each object is a number. How can you enforce this?

Which TWO of the following are valid meta-arguments for managing resource instances?

Which THREE of the following are valid HCL collection types?

Which TWO of the following are requirements when using a 'dynamic' block?

Which THREE of the following are valid ways to define optional resource attributes in an object type?

You are defining an input variable for a module that must accept a list of objects, each with a required `name` (string) and an optional `tags` attribute (map of strings). You want Terraform to reject any object that includes additional unexpected attributes. Which type constraint correctly enforces this?

You maintain a root module that instantiates a child module `network` for each AWS region defined in a local variable `regions` map. The module call uses `for_each = local.regions`. During a plan, Terraform reports that the module's `providers` argument references `each.key` in the `aws` provider alias. You want each module instance to use the AWS provider aliased to its own region. Which configuration correctly passes the region-specific provider instance into the module?

Question 14mediummulti select
Review the full subnetting walkthrough →

You are using a dynamic block to generate multiple ingress rules for an aws_security_group resource. The dynamic block iterates over a list of objects, each containing 'from_port', 'to_port', and 'cidr_blocks'. You need to access the current iteration's values inside the dynamic block. Which TWO of the following are valid ways to reference the current iteration object? (Choose two.)

You are authoring a module whose main configuration must merge a caller-supplied map of tags with a set of mandatory tags defined inside the module, giving the mandatory tags precedence when keys collide. The merged result is passed to the tags argument of an aws_instance resource. Which expression should you use?

You are using a dynamic block to generate multiple ingress rules for an AWS security group. The dynamic block iterates over a list of objects containing port, protocol, and cidr_blocks. Which two statements are true regarding the use of dynamic blocks in this scenario? (Choose two.)

A platform team stores environment definitions in a single variable "envs" typed as map(object({ region = string, instance_type = string, tags = map(string) })). They need to build locals for downstream modules. Which TWO local definitions correctly produce, respectively, a map of instance types keyed by environment name and a set of all distinct tag values across every environment? (Choose two.)

Question 18hardmultiple choice
Review the full subnetting walkthrough →

A platform team stores environment configuration in a single Terraform variable `env_config` of type `map(object({ cidr_block = string, az_count = number }))`. They want to create one `aws_subnet` per availability zone in each environment, with the subnet CIDR computed by calling `cidrsubnet` on the environment's `cidr_block`. Which expression produces a flattened collection suitable for `for_each` on `aws_subnet`, where each element's key uniquely identifies the environment and AZ index?

You are creating a Terraform module that must accept a list of objects representing AWS IAM policy statements. Each object has `effect`, `actions` (list of strings), and `resources` (list of strings). You want to validate that all `actions` and `resources` are non-empty lists and that `effect` is either "Allow" or "Deny". Which TWO of the following validation approaches are valid and correctly enforce these requirements? (Choose two.)

Question 20mediummultiple choice
Review the full subnetting walkthrough →

A configuration builds a local "az_map" with local.az_map = { for idx, az in data.aws_availability_zones.available.names : az => idx } and then uses for_each = local.az_map on aws_subnet resources. A reviewer asks what the resulting resource instance keys and values look like, and what happens if AWS later reorders the availability zone list. Which statement is accurate?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Dynamic HCL Configuration sessions

Start a Dynamic HCL Configuration only practice session

Every question in these sessions is drawn from the Dynamic HCL Configuration domain — nothing else.

Related practice questions

Related AWS provider topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the AWS provider exam test about Dynamic HCL Configuration?
You must read and write HCL that passes typed objects to modules, validates inputs with condition and error_message, transforms collections with for expressions, and generates nested blocks dynamically. The critical skill is matching type constraints and validation conditions to the actual data shape.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Dynamic HCL Configuration questions in a focused session?
Yes — the session launcher on this page draws every question from the Dynamic HCL Configuration domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other AWS provider topics?
Use the topic links above to move to related areas, or go back to the AWS provider question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the AWS provider exam covers. They are not copied from any real exam or dump site.