我在账户 A 中有一个具有管理员权限的 IAM 用户,并arn:aws:iam::aws:policy/AWSCodeArtifactReadOnlyAccess附加了一个很好的措施。
账户 A 中的 iam 用户的 arn 为arn:aws:iam::***:user/test-user。
帐户 B 有一个 CodeArtifact 存储库,arn 为arn:aws:codeartifact:***:***:domain/test-repo。该仓库的资源政策为
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::***:user/test-user"
},
"Action": "codeartifact:*",
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
运行 AWS CLI 命令时,我使用账户 A 中 IAM 用户的访问密钥。以下命令有效:
$ aws codeartifact get-repository-endpoint --domain test-repo --domain-owner *** --query repositoryEndpoint --output text --repository test --format pypi
Run Code Online (Sandbox Code Playgroud)
结果是
https://test-repo-***.d.codeartifact.***.amazonaws.com/pypi/test/
这表明我的资源策略正在发挥作用(将 翻转Effect为Deny成功会使上述命令失败)。
但是,以下命令
$ aws codeartifact …Run Code Online (Sandbox Code Playgroud) 这是我的(简化的)Dockerfile
# https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base
FROM public.ecr.aws/lambda/python:3.8
# get the amazon linux extras
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras install epel -y
Run Code Online (Sandbox Code Playgroud)
RUN amazon-linux-extras install epel -y当它在构建过程中到达线路时,它会得到
Step 6/8 : RUN amazon-linux-extras install epel -y
---> Running in dbb44f57111a
/var/lang/bin/python: No module named amazon_linux_extras
The command '/bin/sh -c amazon-linux-extras install epel -y' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)
我认为这与一些 python 2 vs. 3 的东西有关,但我不确定
我有以下内容buildspec.yml
version: 0.2
env:
shell: bash
phases:
install:
runtime-versions:
nodejs: 12
commands:
- source cicd/app_cicd.sh
- npm_install
Run Code Online (Sandbox Code Playgroud)
哪里cicd/app_cicd.sh
#!/bin/bash
function npm_install() {
npm install
}
Run Code Online (Sandbox Code Playgroud)
但 CodeBuild 输出显示
[Container] 2021/05/23 01:55:32 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2021/05/23 01:55:32 Phase context status code: Message:
[Container] 2021/05/23 01:55:33 Entering phase INSTALL
[Container] 2021/05/23 01:55:33 Running command export CICD_ROOT=$(pwd)
[Container] 2021/05/23 01:55:33 Running command source cicd/app_cicd.sh
[Container] 2021/05/23 01:55:33 Running command npm_install
/codebuild/output/tmp/script.sh: line 4: npm_install: command not found …Run Code Online (Sandbox Code Playgroud)