AWS SAM管道

2024-04-28 21:23:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Python 3.8为标准AWS SAM HelloWorld模板构建一个管道。我使用this template作为管道示例。我对管道所做的唯一更改是环境/图像,我正在从3.6.5更改为3.8.3,就像这样

     CodeBuildProject:
        Type: AWS::CodeBuild::Project
        Properties:
            Name: {{cookiecutter.project_name.lower().replace(' ', '-')}}
            Description: Build project for the {{cookiecutter.project_name}}
            Artifacts:
              Type: CODEPIPELINE
            Environment: 
                Type: LINUX_CONTAINER
                ComputeType: BUILD_GENERAL1_SMALL
                # Image: aws/codebuild/python:3.6.5 - *Commenting this out*
                Image: aws/codebuild/python:3.8.3 - *Using this instead*
                EnvironmentVariables:
                  - 
                    Name: BUILD_OUTPUT_BUCKET
                    Value: !Ref BuildArtifactsBucket
            Cache:
              Type: S3
              Location: !Sub ${BuildArtifactsBucket}/codebuild-cache
            ServiceRole: !GetAtt CodeBuildServiceRole.Arn
            Source: 
                Type: CODEPIPELINE
            Tags: 
              - 
                Key: "Stack"
                Value: !Ref AWS::StackName
              -
                Key: "Project"
                Value: {{cookiecutter.project_name}}

问题

我之所以进行此更改,是因为我的lambda运行时是python3.8。如果我将管道的映像保留为aws/codebuild/python:3.6.5,则会出现以下错误

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aws_lambda_builders/workflow.py", line 58, in wrapper
    valid_path = binary_checker.validator.validate(executable_path)
  File "/usr/local/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/validator.py", line 45, in validate
    raise MisMatchRuntimeError(language=self.language, required_runtime=self.runtime, runtime_path=runtime_path)
aws_lambda_builders.exceptions.MisMatchRuntimeError: python executable found in your path does not match runtime. 
 Expected version: python3.8, Found version: /usr/local/bin/python.

然而,当我将管道的映像更改为aws/codebuild/python:3.8.3时,我在CodeBuild的配置阶段遇到了这个错误

BUILD_CONTAINER_UNABLE_TO_PULL_IMAGE: Unable to pull customer's container image. CannotPullContainerError: Error response from daemon: pull access denied for aws/codebuild/python, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

当我搜索“codebuild BUILD\u CONTAINER\u UNABLE\u TO\u PULL\u IMAGE”时,我发现错误来自使用自定义构建映像

我的问题

  1. 我将管道的映像更改为aws/codebuild/python:3.8.3正确吗
  2. aws/codebuild/python:3.8.3是有效的映像吗

关于#2,我发现this page,虽然筛选有点复杂,但我相信3.8.3是一个有效的图像

任何帮助我的管道运行将不胜感激


Tags: pathlambdanamebuildprojectaws管道value
1条回答
网友
1楼 · 发布于 2024-04-28 21:23:52

这是因为它正试图从具有throttling enabled for pulling images的docker hub中提取新映像。因此,您可以做的是从AWS Public ECR中提取图像,并在您的环境中使用相同的图像

还有另一种方法,您可以在帐户中创建自己的ECR回购,并将所述图像推送到您自己的ECR,然后在模板中使用该图像

相关问题 更多 >