地形错误可以帮助我解决这个问题,但我在密钥文件中提供了有效的令牌


terraform plan -var-file=uservar.tfvars
[0m[1mRefreshing Terraform state in-memory prior to plan...[0m
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
[0m
[31mError refreshing state: 1 error(s) occurred:
* provider.aws: InvalidClientTokenId: The security token included in the request is invalid.
status code: 403, request id: 39888d7e-b3f1-11e7-b6d2-9b6dc0727868[0m[0m
Build step 'Execute shell' marked build as failure
Finished: FAILURE

您需要先运行terraform init,然后运行terraform plan

首先浏览此文档:地形命令:init

其次,对于错误The security token included in the request is invalid.,请检查aws配置,以确保您正确设置了aws安全令牌。

我得到了这个问题的解决方案。你从Git中提取代码吗?如果是,只拉动一次

注意:Git上的代码没有access_key和secret_key,所以如果你的jenkins作业包含每个构建的源代码管理,那么值(access_key and secret_key)就会被覆盖。->只拉一次代码->在您的jenkins/workspaces中,设置access_key和secret_key(或者您也可以在JenkinsBuild中提及它)

在执行Jenkins作业之前,请设置aws-cli参数aws配置设置access_key、secret_key&区域

然后执行地形初始化地形平面图-var file=uservar.tfvars

最新更新