惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
美团技术团队
J
Java Code Geeks
V
Visual Studio Blog
T
Threat Research - Cisco Blogs
博客园 - 聂微东
雷峰网
雷峰网
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threatpost
PCI Perspectives
PCI Perspectives
S
Security @ Cisco Blogs
S
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V2EX - 技术
V2EX - 技术
L
Lohrmann on Cybersecurity
博客园 - Franky
O
OpenAI News
博客园 - 叶小钗
T
Tor Project blog
AI
AI
SecWiki News
SecWiki News
WordPress大学
WordPress大学
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
Help Net Security
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
F
Full Disclosure
H
Heimdal Security Blog
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Project Zero
Project Zero
Recorded Future
Recorded Future
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Application and Cybersecurity Blog
Application and Cybersecurity Blog
L
LINUX DO - 热门话题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
小众软件
小众软件
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Palo Alto Networks Blog
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 数据收集原理分析 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 几种方法 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 check the export on the very top of this document so we can use $do mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 运维自动化之ANSIBLE | mafeifan 的编程技术分享 延伸 -- 关于前端路由 xdebug 3 和 2 的区别
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

dynamic 可以在 resource 内创建重复的block

dynamic 支持在 resource, data, provider 和 provisioner blocks 内使用

举例 ​

下列的 subnet 定义是重复的

resource "azurerm_virtual_network" "dynamic_block" {
    name                = "vnet-dynamicblock-example-centralus"
    resource_group_name = azurerm_resource_group.dynamic_block.name
    location            = azurerm_resource_group.dynamic_block.location
    address_space       = ["10.10.0.0/16"]

    subnet {
        name           = "snet1"
        address_prefix = "10.10.1.0/24"
    }

    subnet {
        name           = "snet2"
        address_prefix = "10.10.2.0/24"
    }

    subnet {
        name           = "snet3"
        address_prefix = "10.10.3.0/24"
    }

    subnet {
        name           = "snet4"
        address_prefix = "10.10.4.0/24"
    }
}

使用 dynamic 进行封装 ​

hcl

resource "azurerm_virtual_network" "dynamic_block" {
    name                = "vnet-dynamicblock-example-centralus"
    resource_group_name = azurerm_resource_group.dynamic_block.name
    location            = azurerm_resource_group.dynamic_block.location
    address_space       = ["10.10.0.0/16"]

    dynamic "subnet" {
        for_each = var.subnets
            iterator = item   #optional
            content {
                name           = item.value.name
                address_prefix = item.value.address_prefix
            }
    }
}

subnets 改为通过变量传入

hcl

variable "subnets" {
    description = "list of values to assign to subnets"
    type = list(object({
        name           = string
        address_prefix = string
    }))
}

实际的值类似

subnets = [
    { name = "snet1", address_prefix = "10.10.1.0/24" },
    { name = "snet2", address_prefix = "10.10.2.0/24" },
    { name = "snet3", address_prefix = "10.10.3.0/24" },
    { name = "snet4", address_prefix = "10.10.4.0/24" }
]

Dynamic 支持多级嵌套 ​

hcl

dynamic "origin_group" {
    for_each = var.load_balancer_origin_groups
    iterator = outer_block
    content {
        name = outer_block.key
        dynamic "origin" {
            for_each = outer_block.value.origins
            iterator = inner_block
            content {
                hostname = inner_block.value.hostname
            }
        }
    }
}

再举例

Cloudfront 在prod下绑定的域名是https,有个cloudfront_default_certificate属性需要是false,其他环境需要是true,所以我们可以这么写

hcl

resource "aws_cloudfront_distribution" "govplt-s3-website-distribution" {
    // .....
    dynamic "viewer_certificate" {
        for_each = var.env_name == "prod" ? [1] : []
        content {
            cloudfront_default_certificate = false
            iam_certificate_id             = data.aws_iam_server_certificate.govplt-management-domain.id
            minimum_protocol_version       = "TLSv1.2_2021"
            ssl_support_method             = "sni-only"
        }
    }

    dynamic "viewer_certificate" {
        for_each = var.env_name != "prod" ? [1] : []
        content {
            cloudfront_default_certificate = true
        }
    }
}