You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform创建启用DNS的S3 Interface Endpoint参数配置问题

解决Terraform创建S3接口端点的PrivateDnsOnlyForInboundEndpoint问题

问题分析

你在创建启用私有DNS的S3接口端点时触发的错误,根源在于AWS默认会将PrivateDnsOnlyForInboundEndpoint设为true,而该选项要求VPC中必须存在对应的S3网关端点。但你实际不需要开启这个选项,需要显式禁用它。

解决方案

虽然Terraform官方文档未提及private_dns_only_for_inbound_endpoint参数,但该参数对应AWS API的同名字段,Terraform的aws_vpc_endpoint资源支持传递该参数。只需在配置中显式设置该参数为false即可:

resource "aws_vpc_endpoint" "s3_interface" {
  vpc_id                      = data.aws_vpc.vpc_id.id
  service_name                = "com.amazonaws.${var.aws_region}.s3"
  vpc_endpoint_type           = "Interface"
  subnet_ids                  = [data.aws_subnet.mgmt_private_subnet.id]
  security_group_ids          = [data.aws_security_group.sg.id]
  private_dns_enabled         = true
  private_dns_only_for_inbound_endpoint = false # 显式禁用仅入站私有DNS选项
  dns_options {
    dns_record_ip_type = "ipv4"
  }
}

原理说明

当你设置private_dns_enabled = true时,AWS API默认会自动尝试开启PrivateDnsOnlyForInboundEndpoint,进而触发必须存在S3网关端点的校验。通过显式设置private_dns_only_for_inbound_endpoint = false,可以强制AWS跳过这个校验,直接创建启用私有DNS但不限制仅入站的S3接口端点。

内容的提问来源于stack exchange,提问作者shasi222

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 22:02:14