# 错误：获取状态锁失败：请求错误：发送请求失败，原因：Post "https://s3.us-east-1.amazonaws.com/my-bucket/terraform.tfstate"：拨号 TCP 52.95.139.7:443：I/O 超时

- **ID:** `terraform/state-lock-s3-request-timeout`
- **领域:** terraform
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

网络连接问题导致 Terraform 无法访问用于状态锁定的 S3 存储桶，通常由防火墙规则、VPN 问题或 AWS 临时中断引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform v1.5 | active | — | — |
| Terraform v1.6 | active | — | — |
| Terraform v1.7 | active | — | — |
| AWS Provider v5.0+ | active | — | — |

## 解决方案

1. ```
   Check network connectivity to S3 endpoint: run 'curl -v https://my-bucket.s3.us-east-1.amazonaws.com' to verify reachability. If blocked, add firewall rule to allow outbound HTTPS to S3 IP ranges. Then retry 'terraform apply'.
   ```
2. ```
   If behind a proxy, set HTTP_PROXY and HTTPS_PROXY environment variables: 'export HTTPS_PROXY=http://proxy.company.com:8080' and run 'terraform init' again.
   ```

## 无效尝试

- **** — The error is a network timeout, not a stale lock. force-unlock doesn't fix connectivity and may cause state corruption if the lock is still held by another process. (95% 失败率)
- **** — The timeout is at the TCP level, not the S3 API level. TCP dial timeout is controlled by OS network stack, not AWS CLI settings. (80% 失败率)
- **** — This bypasses the lock but risks concurrent state modifications, leading to state corruption or lost updates. (60% 失败率)
