【问题标题】:Jenkins Cloudformation plugin gives InValid Client Id errorJenkins Cloudformation 插件给出 InValid Client Id 错误
【发布时间】:2019-02-18 17:12:56
【问题描述】:

我正在尝试通过 jenkins-cloudformation 插件从存储在 git 中的模板启动 cloudformation 堆栈,但即使我提供了正确的 access_key 和 secret_key,我也会收到错误“无效的客户端 ID”。

此外,适当的 IAM 角色附加到运行 jenkins 的 ec2 实例,并且 jenkins 用户可以访问实例元数据。

无论我是否在jenkins配置中传递了secretKey、accessKey,都会出现这个错误。

谁能指导我哪里出错了。

错误

Building in workspace /apps/jenkins/.jenkins/workspace/Cloudformation_Test
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url https://xxxx.git # timeout=10
Fetching upstream changes from https://xxxx.git
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials Gitlab user webadmdeamon to perform CICD with Jenkins
 > /usr/bin/git fetch --tags --progress https://xxx.get +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 827b91075eb0ae5901b641a7588b9b5769ad2ce7 (refs/remotes/origin/master)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f 827b91075eb0ae5901b641a7588b9b5769ad2ce7
Commit message: "Add new file"
 > /usr/bin/git rev-list --no-walk 827b91075eb0ae5901b641a7588b9b5769ad2ce7 # timeout=10
Determining to create or update Cloud Formation stack: JenkinsCloudformationTest
Stack not found: JenkinsCloudformationTest. Reason: Detailed Message: The security token included in the request is invalid. (Service: AmazonCloudFormation; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: be71618c-3027-11e9-8d00-45421bf87ce0)
Status Code: 403
Error Code: InvalidClientTokenId

Creating Cloud Formation stack: JenkinsCloudformationTest
Failed to create stack: JenkinsCloudformationTest. Reason: Detailed Message: The security token included in the request is invalid. (Service: AmazonCloudFormation; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: be73364d-3027-11e9-8d00-45421bf87ce0)
Status Code: 403
Error Code: InvalidClientTokenId

Finished: FAILURE

编辑---

我能够在同一个 ec2 实例和同一个用户中使用 aws cli 创建一个堆栈。

【问题讨论】:

    标签: amazon-web-services jenkins amazon-cloudformation


    【解决方案1】:

    日志显示您的问题与身份验证有关:

    Reason: Detailed Message: The security token included in the request is invalid.
    (Service: AmazonCloudFormation; Status Code: 403; Error Code: InvalidClientTokenId; Request 
    ID: be71618c-3027-11e9-8d00-45421bf87ce0)
    Status Code: 403
    Error Code: InvalidClientTokenId
    

    问题可能是 Jenkins 插件中的错误,或者(更有可能)是您提供给插件的密钥的问题。

    同时,插件的源代码 (code ref) 似乎表明插件总是尝试使用您提供的访问密钥。如果您将键字段留空,我猜它会尝试空字符串作为键。因此,附加到实例的 IAM 角色可能不相关。

    请注意,您收到的错误 InvalidClientTokenId 已记录在 here

    InvalidClientTokenId

    我们的记录中不存在提供的 X.509 证书或 AWS 访问密钥 ID。

    HTTP 状态码:403

    现在,您在更新中提到:

    我能够在同一个 ec2 实例和同一个用户中使用 aws cli 创建一个堆栈。

    首先,再试一次,然后查看CloudTrail。按 EventName=CreateStack 过滤,然后你会看到如下内容:

    真的是同一个用户和Access Key吗?

    我怀疑您会发现它不是,并且您的解决方法是提供正确的访问密钥。如果没有,请告诉我,我们可以考虑其他可能性。

    【讨论】:

    • Yw。找到根本原因了吗?
    • 确实问题与 IAM 用户有关。我试图改用 IAM 角色,但它不起作用。
    猜你喜欢
    • 1970-01-01
    • 2019-07-31
    • 1970-01-01
    • 2019-03-07
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    相关资源
    最近更新 更多