简体   繁体   English

AWS CLI:找不到配置文件(测试)

[英]AWS CLI: The config profile (test) could not be found

I am automating the AWS IAM user creation from Jenkins.我正在从 Jenkins 自动创建 AWS IAM 用户。 We have multiple Accounts with programmatic access.我们有多个具有程序访问权限的帐户。 I am trying to create user account for one account from CLI.我正在尝试从 CLI 为一个帐户创建用户帐户。 It's working fine from CLI, but not from jenkins Pipeline.它在 CLI 中运行良好,但在 jenkins Pipeline 中运行良好。

Output through CLI通过 CLI 输出

aws iam create-user --user-name --profile test tets

{
    "User": {
    "Path": "/",
    "UserName": "tets",
    "UserId": "AIDAXTRPYNIV6HK7XE43R",
    "Arn": "arn:aws:iam::523012434475:user/tets",
    "CreateDate": "2019-09-18T06:49:41Z"
}



node
{
    stage ('creating IAM user'){
    sh 'aws iam create-user --user-name --profile test $Username'       
}

The config profile (test) could not be found is the error i am getting from Jenkins Pipeline.找不到配置文件(测试)是我从 Jenkins Pipeline 得到的错误。

AWS CLI is configured on jenkins server. AWS CLI 在 jenkins 服务器上配置。 From ssh i am able to execute all the commands.从 ssh 我能够执行所有命令。

I've just hit this problem too.我也刚遇到这个问题。 Took an hour to unpick but FWIW in the interests of saving others' time (providing they have the same setup):为了节省其他人的时间(前提是他们有相同的设置),花了一个小时来解开 FWIW:

We use jenkins on an ec2 instance in AWS (built with "ubuntu" as the user).我们在 AWS 中的 ec2 实例上使用 jenkins(使用“ubuntu”作为用户构建)。 The actual home dir for jenkins is mounted on /data/jenkins jenkins 的实际主目录安装在 /data/jenkins

ssh'ing on to the server as ubuntu user puts you in shell as ubuntu. ssh 连接到服务器,因为 ubuntu 用户将您作为 ubuntu 置于 shell 中。 cd ~ # takes you to the home directory (you're already in) pwd # shows you in /home/ubuntu sudo su -jenkins # change to jenkins user cd ~ # actually still takes you to /home/ubuntu pwd # prooves you're still in /home/ubuntu cd ~ # 带你到主目录(你已经在) pwd # 显示在 /home/ubuntu sudo su -jenkins # 改为 jenkins 用户 cd ~ # 实际上仍然带你到 /home/ubuntu pwd # 证明你'仍在 /home/ubuntu

Creating the .aws folder with config and credentials at this location means you can't use the --profile switch with aws cli commands in the pipeline.在此位置使用配置和凭据创建 .aws 文件夹意味着您无法将 --profile 开关与管道中的 aws cli 命令一起使用。 The jenkins home dir is actually /data/jenkins so when the pipeline runs, calls to the aws cli will be looking for the .aws folder in /data/jenkins jenkins 主目录实际上是 /data/jenkins,所以当管道运行时,对 aws cli 的调用将在 /data/jenkins 中查找 .aws 文件夹

Copying the .aws folder from /home/ubuntu to /data/jenkins, chowning objects for jenkins:jenkins and ensuring read perms (I used chmod 660) means that when the cli runs, it should see the config in /data/jenkins and the annoying "The config profile could not be found"将 .aws 文件夹从 /home/ubuntu 复制到 /data/jenkins,为 jenkins:jenkins chowning 对象并确保读取权限(我使用 chmod 660)意味着当 cli 运行时,它应该看到 /data/jenkins 中的配置和烦人的“找不到配置文件”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM