Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services gitlab ci中打包程序的AWS未授权错误_Amazon Web Services_Gitlab Ci_Packer - Fatal编程技术网

Amazon web services gitlab ci中打包程序的AWS未授权错误

Amazon web services gitlab ci中打包程序的AWS未授权错误,amazon-web-services,gitlab-ci,packer,Amazon Web Services,Gitlab Ci,Packer,当我的gitlab runner运行以下命令时: time packer build -var "git_branch=$CI_BUILD_REF_NAME" -var "git_hash=$CI_BUILD_REF" -color=false packer-application.json 我得到以下错误: Build 'amazon-ebs' errored: Error creating temporary keypair: UnauthorizedOperation: You are

当我的gitlab runner运行以下命令时:

time packer build -var "git_branch=$CI_BUILD_REF_NAME" -var "git_hash=$CI_BUILD_REF" -color=false packer-application.json
我得到以下错误:

Build 'amazon-ebs' errored: Error creating temporary keypair: UnauthorizedOperation: You are not authorized to perform this operation.
status code: 403, request id: 
但是,如果我通过ssh连接到gitlab runner并手动运行该命令,则该命令将成功运行


有什么想法吗?

您需要确保构建有权访问AWS API密钥,并有权更改资源。虽然生成容器在运行程序上运行,但它是完全隔离的,无法访问基础主机上的环境

您可以在项目的变量页面下添加(排序)机密环境变量。它们将可用于所有构建,因此请小心不要让开发人员或更高级别的人员访问不应该能够看到密钥的人

如果您在runner主机上附加了一个EC2角色,并且希望利用该角色访问API,您可以将runner配置为在
shell
模式下运行构建,这意味着它们将作为传统的Jenkins构建直接在主机上执行