十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

terraform-provider-aws 6.6.0 版本亮点解析:新资源、增强特性与关键修复

terraform-provider-aws 6.6.0 版本亮点解析:新资源、增强特性与关键修复 terraform-provider-aws 6.6.0 版本亮点解析新资源、增强特性与关键修复【免费下载链接】terraform-provider-awsThe AWS Provider enables Terraform to manage AWS resources.项目地址: https://gitcode.com/GitHub_Trending/te/terraform-provider-awsterraform-provider-aws 的 6.6.0 版本发布于 2025 年 7 月 28 日本次迭代新增了两个实用资源Amazon Connect 电话号码-联系流关联、VPC NAT 网关 EIP 关联并围绕 CloudWatch Events、SSM Patch Baseline、Bedrock Guardrail 等多项服务补充了全新参数同时修复了若干影响日常使用的更新与导入问题。读完本文你将全面掌握 6.6.0 版本引入的新资源用法、各服务的参数增强细节以及如何安全地升级和使用这些新能力。版本总览与升级建议6.6.0 版本的主要内容可以用三句话概括新增 2 个资源、扩充 20 余处参数能力、修复 3 个具体缺陷。整体而言这是一个增强型版本不涉及破坏性变更升级风险较低但其中aws_nat_gateway资源secondary_allocation_ids参数行为的调整需要引起注意详见下文需要注意的变更一节。本仓库的版本号维护在 version/VERSION 与 version/version.go 中CHANGELOG 位于仓库根目录的 CHANGELOG.md本次版本发布说明的原文记录在 .changes/6.x/6.6.0.md。新增资源一aws_connect_phone_number_contact_flow_association该资源用于将联系流Contact Flow关联到已在 Amazon Connect 实例中认领claim的电话号码即把某个电话号码的来电/去电路由绑定到指定的流程上。配置示例官方文档 website/docs/r/connect_phone_number_contact_flow_association.html.markdown 给出了最基本的用法resource aws_connect_phone_number_contact_flow_association example { phone_number_id aws_connect_phone_number.example.id instance_id aws_connect_instance.example.id contact_flow_id aws_connect_contact_flow.example.contact_flow_id }三个参数均为必填参数说明phone_number_id已认领到 Amazon Connect 实例的电话号码 ID必填instance_idAmazon Connect 实例 ID必填contact_flow_id联系流 ID必填region可选资源所属区域默认使用 Provider 配置中的区域该资源不导出任何额外的属性Attribute Reference 为空因为它本质上是电话号码 ↔ 联系流的绑定关系资源标识信息全部由入参构成。源码实现解析实现文件位于 internal/service/connect/phone_number_contact_flow_association.go是一个基于 Terraform Plugin Framework 构建的资源。从源码结构可以观察到几个关键设计三个入参全部Required且带RequiresReplace()修饰第 47-64 行这意味着任一参数变更都会触发资源重建而不是原地更新。结合framework.WithNoUpdate嵌入第 41 行该资源明确不支持 Update 操作。Create 调用的是 Connect API 的AssociatePhoneNumberContactFlow第 79-85 行把contact_flow_id、instance_id、phone_number_id打包进请求。Delete 调用DisassociatePhoneNumberContactFlow第 134-138 行并且对ResourceNotFoundException做了幂等处理——资源已被删除时直接返回成功第 140-142 行。Read 通过三分键查询findPhoneNumberContactFlowAssociationByThreePartKey第 168-189 行先按 ID 查电话号码与联系流再调用ListFlowAssociations按ResourceType: VoicePhoneNumber过滤并在结果中匹配PhoneNumberArn与FlowId最后用AssertSingleValueResult确保唯一命中若查不到则从 State 中移除资源。Import 采用逗号分隔的三段式 IDphone_number_id,instance_id,contact_flow_id第 151-166 行由intflex.ExpandResourceId按 3 段解析。导入已有资源官方文档提供了两种导入方式均使用phone_number_id,instance_id,contact_flow_id逗号分隔的三段 IDimport { to aws_connect_phone_number_contact_flow_association.example id 36727a4c-4683-4e49-880c-3347c61110a4,fa6c1691-e2eb-4487-bdb9-1aaed6268ebd,c4acdc79-395e-4280-a294-9062f56b07bb }或使用命令行% terraform import aws_connect_phone_number_contact_flow_association.example 36727a4c-4683-4e49-880c-3347c61110a4,fa6c1691-e2eb-4487-bdb9-1aaed6268ebd,c4acdc79-395e-4280-a294-9062f56b07bb新增资源二aws_nat_gateway_eip_association该资源用于将弹性 IPEIP关联到 VPC NAT 网关作为其辅助地址使 NAT 网关具备多个公网 IP 能力。它对应 EC2 的AssociateNatGatewayAddress/DisassociateNatGatewayAddressAPI实现位于 internal/service/ec2/vpc_nat_gateway_eip_association.go。重要警告官方文档明确提示不要在配置了secondary_allocation_ids的aws_nat_gateway资源上同时使用本资源否则可能造成 perpetual differences永不收敛的漂移并导致关联关系被互相覆盖。两种管理辅助 EIP 的方式只能二选一。配置示例resource aws_nat_gateway_eip_association example { allocation_id aws_eip.example.id nat_gateway_id aws_nat_gateway.example.id }参数说明参数说明allocation_id要与 NAT 网关关联的弹性 IP 分配 ID必填nat_gateway_id要关联弹性 IP 的 NAT 网关 ID必填region可选资源所属区域默认使用 Provider 配置中的区域timeouts可选create默认10mdelete默认30m与 Connect 关联资源不同本资源会导出一个 Computed 属性association_id即 NAT 网关地址关联 ID源码中在 Create 成功后通过waitNATGatewayAddressAssociated等待关联生效并将 API 返回的AssociationId写入 Statevpc_nat_gateway_eip_association.go。实现细节与等待机制从源码可以看出该资源同样基于 Plugin Framework且具备以下特性两个入参均带RequiresReplace()资源同样不支持原地更新framework.WithNoUpdateCreate 流程是发起关联 → 轮询等待available状态超时默认 10 分钟构造函数第 35-36 行设置默认值Delete 流程调用DisassociateNatGatewayAddress对InvalidParameter错误做幂等处理并等待解绑完成默认 30 分钟Read 通过findNATGatewayAddressByNATGatewayIDAndAllocationIDSucceeded查询关联状态NotFound 时自动从 State 移除资源Import 使用nat_gateway_id,allocation_id两段逗号分隔 ID。导入已有关联import { to aws_nat_gateway_eip_association.example id nat-1234567890abcdef1,eipalloc-1234567890abcdef1 }% terraform import aws_nat_gateway_eip_association.example nat-1234567890abcdef1,eipalloc-1234567890abcdef1配套变更aws_nat_gateway 的 secondary_allocation_ids 调整与新增资源配套6.6.0 将aws_nat_gateway的secondary_allocation_ids参数从仅可选调整为Optional Computed见 internal/service/ec2/vpc_nat_gateway.go 第 175 行附近的 Schema 定义。这意味着该属性现在可以由系统回填例如通过aws_nat_gateway_eip_association创建的关联从而避免两套管理方式并存时产生漂移。同时从源码第 704-705 行可以看到当connectivity_type不是 public 时配置secondary_allocation_ids会直接报错该约束依旧有效。增强特性数据源与资源的新参数6.6.0 为多个数据源和资源新增了参数下面按服务逐项说明。CloudWatch Eventslog_config数据源aws_cloudwatch_event_bus与资源aws_cloudwatch_event_bus同时新增log_config参数用于为事件总线配置日志记录策略如是否包含事件明细include_detail。实现见 internal/service/events/bus.go第 81 行 Schema、第 139 行读取、第 197 行flattenLogConfig回写与 internal/service/events/bus_data_source.go第 49 行 Schema、第 92 行回写。resource aws_cloudwatch_event_bus example { name example-bus log_config { include_detail false } }SSM Patch Baselineavailable_security_updates_compliance_status数据源aws_ssm_patch_baseline与资源aws_ssm_patch_baseline新增available_security_updates_compliance_status参数用于控制补丁基线对可用安全更新的合规性判定策略如COMPLIANT/NON_COMPLIANT。资源侧实现位于 internal/service/ssm/patch_baseline.go第 125 行定义 Schema第 277 行在 Create 时读取第 351 行在 Read 时回写第 392-393 行在 Update 时检测变更并映射为PatchComplianceStatus类型后写入 API 请求数据源侧见 internal/service/ssm/patch_baseline_data_source.go 第 87、251 行。Athena Databaseworkgroup资源aws_athena_database新增workgroup参数可指定创建数据库时使用的 Athena 工作组。实现在 internal/service/athena/database.go第 114 行定义 Schema第 156 行与第 213 行分别在 Create / Update 时读取该值。Batch Compute Environmentimage_kubernetes_version资源aws_batch_compute_environment的compute_resources.ec2_configuration块新增image_kubernetes_version参数用于指定 EKS 集群的 Kubernetes 版本镜像配置。Bedrock Guardrail跨区域配置与分级策略资源aws_bedrock_guardrail新增cross_region_config、content_policy_config.tier_config、topic_policy_config.tier_config三个参数用于配置护栏的跨区域部署能力以及对内容策略、主题策略的分级tier配置。Cognitoname 支持就地更新资源aws_cognito_resource_server与aws_cognito_user_pool的name参数从不可变调整为支持原地更新in-place update无需再通过替换资源来改名简化了用户池与资源服务器的命名维护。SSM Service Setting短格式 setting_id资源aws_ssm_service_setting的setting_id现在支持带/ssm/前缀的短格式例如可直接使用ec2optimization或对应短 ID无需拼写完整路径降低配置书写成本。资源身份Resource Identity支持批量落地6.6.0 为一批资源引入了资源身份Resource Identity能力——即以稳定的业务标识而非内部生成 ID作为资源标识便于导入与跨资源引用。涉及资源包括Global Acceleratoraws_globalaccelerator_custom_routing_endpoint_group、aws_globalaccelerator_custom_routing_listener、aws_globalaccelerator_endpoint_group、aws_globalaccelerator_listenerImage Builderaws_imagebuilder_container_recipe、aws_imagebuilder_distribution_configuration、aws_imagebuilder_image、aws_imagebuilder_image_pipeline、aws_imagebuilder_image_recipe、aws_imagebuilder_infrastructure_configuration、aws_imagebuilder_workflowInspectoraws_inspector_assessment_target、aws_inspector_assessment_template、aws_inspector_resource_group。关于该项目资源身份Identity机制的完整设计可参阅 docs/resource-identity.md 与 docs/id-attributes.md了解ID 属性标准化如 docs/design-decisions/standardize-use-of-the-id-attribute.md背后的整体策略。缺陷修复BUG FIXES6.6.0 共修复 3 个具体问题aws_appsync_api_cache 更新报错修复了更新操作中 missing required field缺少必填字段错误。此前更新缓存配置时因请求构造不完整导致 API 拒绝本次修正了更新路径上的字段填充逻辑。aws_cloudwatch_log_delivery_destination 更新失败修复了设置标签tags后执行更新失败的问题确保打标操作与更新操作可以正确共存。aws_ecs_service 负载均衡配置误写修复了load_balancer.advanced_configuration块中未指定的test_listener_rule被错误地置为空字符串的问题避免对未配置字段产生非预期变更。这些修复与回归测试一并落地例如 EC2 相关的 NAT 网关 EIP 关联测试位于 internal/service/ec2/vpc_nat_gateway_eip_association_test.goConnect 关联资源的销毁/存在性校验测试见 internal/service/connect/phone_number_contact_flow_association_test.go均使用本项目 internal/acctest 的接受测试框架acctest.ParallelTest验证。需要注意的变更辅助 EIP 管理方式冲突aws_nat_gateway_eip_association与aws_nat_gateway的secondary_allocation_ids不可混用否则可能出现持续漂移与关联互相覆盖。推荐迁移路径若你正使用secondary_allocation_ids管理辅助 EIP升级后保持现状即可该参数已兼容 Computed 回填若要切换到新资源管理请先移除secondary_allocation_ids并terraform apply再引入aws_nat_gateway_eip_association。三个新参数依赖底层 AWS API 能力log_configEventBridge 托管日志、available_security_updates_compliance_statusSSM 安全更新合规策略、image_kubernetes_versionBatch EKS 镜像均需对应 AWS 服务在所用区域支持相应 API建议先在测试环境验证。Connect 关联资源参数不可变三个入参任一变更都会触发替换RequiresReplace计划变更前需评估重建影响涉及号码与联系流的重新绑定。小结terraform-provider-aws 6.6.0 是一次典型的小版本大扩充两个新关联资源补齐了 Connect 与 NAT 网关在辅助地址管理上的短板secondary_allocation_ids的 OptionalComputed 调整消除了潜在的漂移冲突而一批 Identity 能力与参数增强则让日常配置表达更简洁。升级时重点核对本文需要注意的变更中的冲突场景即可平滑落地。【免费下载链接】terraform-provider-awsThe AWS Provider enables Terraform to manage AWS resources.项目地址: https://gitcode.com/GitHub_Trending/te/terraform-provider-aws创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表