我正试图使用Terraform:在AWS中创建一个非常简单的EC2实例
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_instance" "app_server" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
}
我已经创建了一个有效的AWS配置文件terraform
,使用它我可以通过AWS CLI进行精细登录。我已经从我的Mac终端执行了地形:
export AWS_PROFILE=terraform
export TF_LOG=TRACE
terraform init
terraform plan
它永远挂着。由于我启用了跟踪日志记录,我可以看到它在循环中运行,如下所示:
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: [DEBUG] [aws-sdk-go-v2] retrying request STS/GetCallerIdentity, attempt 4
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: [DEBUG] [aws-sdk-go-v2] Request
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: POST / HTTP/1.1
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Host: sts.us-west-2.amazonaws.com
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: User-Agent: APN/1.0 HashiCorp/1.0 Terraform/1.2.6 (+https://www.terraform.io) terraform-provider-aws/dev (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go-v2/1.16.10 os/macos lang/go/1.18.4 md/GOOS/darwin md/GOARCH/amd64 api/sts/1.16.4
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Content-Length: 43
2022-08-13T14:16:47.961+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Amz-Sdk-Invocation-Id: 6143fa8c-4e0c-4f5f-9594-fbe52b5ed650
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Amz-Sdk-Request: attempt=4; max=25
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Authorization: AWS4-HMAC-SHA256 Credential=xxx/20220813/us-west-2/sts/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-date, Signature=xxxyyy
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Content-Type: application/x-www-form-urlencoded
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: X-Amz-Date: 20220813T131647Z
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Accept-Encoding: gzip
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5:
2022-08-13T14:16:47.962+0100 [DEBUG] provider.terraform-provider-aws_v4.26.0_x5: Action=GetCallerIdentity&Version=2011-06-15
2022-08-13T14:16:48.320+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:16:48.321+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
2022-08-13T14:16:48.321+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:16:53.321+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:16:53.321+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:16:53.322+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
2022-08-13T14:16:58.323+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:16:58.323+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
2022-08-13T14:16:58.323+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:17:03.324+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:17:03.324+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
2022-08-13T14:17:03.324+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:17:08.324+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:17:08.324+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
2022-08-13T14:17:08.324+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:17:13.325+0100 [TRACE] dag/walk: vertex "root" is waiting for "provider["registry.terraform.io/hashicorp/aws"] (close)"
2022-08-13T14:17:13.325+0100 [TRACE] dag/walk: vertex "aws_instance.app_server (expand)" is waiting for "provider["registry.terraform.io/hashicorp/aws"]"
2022-08-13T14:17:13.325+0100 [TRACE] dag/walk: vertex "provider["registry.terraform.io/hashicorp/aws"] (close)" is waiting for "aws_instance.app_server (expand)"
TLDR-您的DNS服务器需要更新在今天的最后几个小时里,我一直在思考同样的问题。
如果你做了一个dig https://sts.us-east-1.amazonaws.com
,但什么都没有出现,那么你肯定会遇到DNS解析错误。
转到网络>选择您的网络(Wifi或任何名称(>DNS。在DNS中,添加来自Google或OpenDNS的DNS服务器。
这些是Google的DNS服务器-8.8.8.8
和8.8.4.4
(请参阅:https://developers.google.com/speed/public-dns/docs/using)
来自OpenDNS-208.67.222.222
和208.67.220.220
的DNS服务器(参考:https://www.opendns.com/setupguide/)
在此之后,如果您确实运行了相同的dig命令,它应该会解析。你的terraform plan
也是如此。
强调这不是地形或aws的问题。