首页 > 解决方案 > 在 aws -terraform 中使用凭证获取 accountid:getcalleridentity 时出错

问题描述

我为 terraform -administrator 访问创建了一个 aws 帐户和一个 IAM 用户并获得了我的凭证。我现在正在尝试使用 terraform 在 AWS 中创建 EC2 实例。我正在从 git bash 运行以下 terraform 脚本。

provider "aws"{
access_key = "Axxxxxxxxx"
secret_key = "Lxxxxxxxxxxxxxx"
region="us-east-1"
}
resource "aws_instance" "example"{
ami="ami-0323c3dd2da7fb37d"
instance_type="t2.micro"
}

当我给出 terraform 计划时,出现以下错误:

Error: error using credentials to get account ID: error calling sts:GetCallerIdentity: SignatureDoesNotMatch: Signature not yet current: 20200518T060344Z is still later than 20200518T041739Z (20200518T040239Z + 15 min.)
        status code: 403, request id: 7d93e368-bf05-4110-9876-1bf6064dd255

  on instance.tf line 1, in provider "aws":
   1: provider "aws"{

我是 AWS 和 terraform 的新手。您能告诉我为什么会出现此错误吗?我尝试更新 git bash。如果我遗漏了什么,请告诉我。

标签: amazon-web-servicesamazon-ec2terraform

解决方案


您的系统时钟可能配置错误。

这个AWS 论坛主题:

API 服务验证时间戳在实际时间的5 分钟内。如果系统时钟关闭超过 5 分钟,则 API 请求将失败


推荐阅读