Using Dynamic Blocks in Terraform

preview_player
Показать описание
Some resources in Terraform can have multiple instances of the same nested block. For instance, the virtual network in Azure or the tags in an AWS auto-scale group. Instead of creating each block by hand, you can use dynamic blocks and a for_each argument. I don't love the solution for reasons I discuss in the video, but I'm a pragmatist at heart. Sometimes good enough is good enough.

-----------------------------------------------------------------------------------------------------

Music by Evan Williams ©2020

Intro 0:00
What are dynamic blocks? 2:38
Normal Form with Data 3:36
Dynamic Block Syntax 7:13
Azure Example with Dynamic Blocks 9:09
Different Data Types for Dynamic Blocks 14:47
Azure Example without Dynamic Blocks 17:00
Outro 20:30
Рекомендации по теме
Комментарии
Автор

This should be added to the official documentation !! thanks

nah
Автор

Thanks some complex stuff described here but very thorough.

dudasamsung
Автор

Hi Ned, thanks for your time in sharing the knowledge. How to create different volumes with different sizes using launching template through terraform and attaching to the instances created via autoscaling group?

harishdevarapalli
Автор

Any inputs on the cdn endpoints delivery_rultle using dynamic block

TheMyvelmurugan
Автор

say i have the following code

targets = {
my_app1_vm1 = {
target_id = var.private_ec2_ids[0]
port = 80
},
my_app1_vm2 = {
target_id = var.private_ec2_ids[1]
port = 80
}
}

it appears to me it can use dynamic group, or can we? because in your example, it is a map ingress

but when it come to a assignment ingress = {}  can we use dynamic group for repeating code? and How?

jiansu
Автор

@ned - What if I have 2 resources groups in 2 locations, and I need to create 2 vnets and each vnet in each resource group. Will using dynamic block help my requirement, while creating vnet block, I need to iterate/loop the resource group, so that the first vnet create should make use of the first rg and the second vnet created should use the 2nd resource group?

omega
Автор

Great Vid,

Question how would this work with KMS keys in AWS?

michaelhanley
Автор

Ty Ned! can't wait for next Tue :) PS: why u keep publishing at pluralsight and not udemy there are not too many author to follow at pluralsight so that membership might not worse it. where at udemy we can selectively choose the course

mosksky
Автор

Thanks Ned ! Been provisioning EC2 instances using for_each, which works, but I can't figure out yet out to reference each instance (to get its private IP address for example).

...




Error parsing instance address:

This command requires that the address references one specific instance.
To view the available instances, use "terraform state list". Please modify
the address to reference a specific instance.

Error parsing instance address: module.ec2[ec2_nat]

This command requires that the address references one specific instance.
To view the available instances, use "terraform state list". Please modify
the address to reference a specific instance.

What is it that I don't understand here ? Any clue please ?

stefstef
Автор

A good video but seems to be targeting those who already have an understanding of dynamic block: the examples are too complex for those trying to understand the basic concepts.

HendersonHood