Python AWS SAM管道
我正在尝试使用Python 3.8为标准AWS SAM HelloWorld模板构建一个管道。我用它作为管道示例。我对管道所做的唯一更改是环境/图像,我正在从3.6.5更改为3.8.3,就像这样Python AWS SAM管道,python,aws-lambda,aws-codepipeline,aws-codebuild,aws-sam-cli,Python,Aws Lambda,Aws Codepipeline,Aws Codebuild,Aws Sam Cli,我正在尝试使用Python 3.8为标准AWS SAM HelloWorld模板构建一个管道。我用它作为管道示例。我对管道所做的唯一更改是环境/图像,我正在从3.6.5更改为3.8.3,就像这样 CodeBuildProject: Type: AWS::CodeBuild::Project Properties: Name: {{cookiecutter.project_name.lower().replace(' ', '-')
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”时,我发现错误来自使用自定义构建映像
我的问题
aws/codebuild/python:3.8.3
aws/codebuild/python:3.8.3
是有效的映像吗如果您能帮助我运行管道,我们将不胜感激。这是因为它正试图从docker hub中提取新的映像,docker hub已经发布了。因此,您可以从中提取图像并在您的环境中使用它
还有另一种方法,您可以在帐户中创建自己的ECR回购,并将提及的图像推送到您自己的ECR中,然后在模板中使用该图像。谢谢@samjackball。你的解决方案奏效了!