Terraform 给出错误无法加载插件架构

mic*_*set 8 amazon-s3 terraform terraform-provider-aws

我有下面的代码,用于通过 terraform 在 aws 中创建 s3 存储桶和云前端,但 terraform 给出错误。\n我正在使用适用于 Windows 的最新版本的 terraform cli exe。\n Main.tf \n请找到下面的 main.tf 代码。 tf 文件:

\n
terraform {\n  required_providers {\n    aws = {\n      source = "hashicorp/aws"\n      version = "3.70.0"\n    }\n  }\n}\n\nprovider "aws" {\n    access_key = "${var.aws_access_key}"\n    secret_key = "${var.aws_secret_key}"\n    region = "${var.aws_region}"\n}\n\nresource "aws_s3_bucket" "mybucket" {\n    bucket = "${var.bucket_name}"\n    acl = "public-read"\n\n    website {\n        redirect_all_requests_to = "index.html"\n    }\n\n    cors_rule {\n        allowed_headers = ["*"]\n        allowed_methods = ["PUT","POST"]\n        allowed_origins = ["*"]\n        expose_headers = ["ETag"]\n        max_age_seconds = 3000\n    }\n\n    policy = <<EOF\n{\n    "Version": "2008-10-17",\n    "Statement": [\n        {\n            "Sid": "PublicReadForGetBucketObjects",\n            "Effect": "Allow",\n            "Principal": {\n                "AWS": "*"\n            },\n            "Action": "s3:GetObject",\n            "Resource": "arn:aws:s3:::${var.bucket_name}/*"\n        }\n    ]\n}\nEOF\n}\n\nresource "aws_cloudfront_distribution" "distribution" {\n    origin {\n        domain_name = "${aws_s3_bucket.mybucket.website_endpoint}"\n        origin_id   = "S3-${aws_s3_bucket.mybucket.bucket}"\n\n        custom_origin_config  {\n            http_port = 80\n            https_port = 443\n            origin_protocol_policy = "match-viewer"\n            origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]\n        }\n    }\n    default_root_object = "index.html"\n    enabled             = true\n\n    custom_error_response {\n        error_caching_min_ttl = 3000\n        error_code            = 404\n        response_code         = 200\n        response_page_path    = "/index.html"\n    }\n\n    default_cache_behavior {\n        allowed_methods  = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]\n        cached_methods   = ["GET", "HEAD"]\n        target_origin_id = "S3-${aws_s3_bucket.mybucket.bucket}"\n\n        forwarded_values {\n            query_string = true\n\n            cookies {\n                forward = "none"\n            }\n      }\n\n        viewer_protocol_policy = "allow-all"\n        min_ttl                = 0\n        default_ttl            = 3600\n        max_ttl                = 86400\n    }\n\n    # Restricts who is able to access this content\n    restrictions {\n        geo_restriction {\n            # type of restriction, blacklist, whitelist or none\n            restriction_type = "none"\n        }\n    }\n\n    # SSL certificate for the service.\n    viewer_certificate {\n        cloudfront_default_certificate = true\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

请查找以下错误消息:

\n
Error: Failed to load plugin schemas\n\xe2\x94\x82\n\xe2\x94\x82 Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/aws: failed to retrieve schema\n\xe2\x94\x82 from provider "registry.terraform.io/hashicorp/aws": Plugin did not respond: The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).GetProviderSchema call. The\n\xe2\x94\x82 plugin logs may contain more details...\n
Run Code Online (Sandbox Code Playgroud)\n

请帮助解决这个问题,我是 terraforms 的新手。\n P.S. 地形规划时生成此错误

\n

Ani*_*iya 12

我也遇到过同样的问题。但错误有点不同。我正在关注 HashiCups 提供商的示例。

当初始化无法升级或检测到损坏的缓存提供程序时,或者如果您更改了版本但仅运行时,terraform init它会在缓存中找到版本并决定使用它,就会发生这种情况。删除terraform目录和lock文件,然后再次initterraform init -upgrade

如果您在 Apple M1 芯片上运行它,您可能还需要进行以下设置:

export GODEBUG=asyncpreemptoff=1;
Run Code Online (Sandbox Code Playgroud)

https://discuss.hashicorp.com/t/terraform-aws-provider-panic-plugin-did-not-respond/23396 https://github.com/hashicorp/terraform/issues/26104