AWS SAM 管道
AWS SAM pipeline
我正在尝试使用 Python 3.8 为标准 AWS SAM HelloWorld 模板构建管道。我使用 this template 作为管道示例。我对管道所做的唯一更改是 Environment/Image,我正在将其从 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_CONTAINER_UNABLE_TO_PULL_IMAGE”时,我发现错误来自使用自定义构建映像。
我的问题
- 我将管道的图像更改为
aws/codebuild/python:3.8.3
是否正确
aws/codebuild/python:3.8.3
是有效图像吗?
关于 #2,我找到了 this page,虽然筛选起来有点复杂,但我相信 3.8.3 是一个有效的图像。
如能协助我获取管道 运行,我们将不胜感激。
这是因为它正试图从 docker 集线器中提取新图像,该集线器具有 throttling enabled for pulling images. So what you can do is pull the image from AWS Public ECR 并在您的环境中使用相同的图像。
还有另一种方法,您可以在帐户中创建自己的 ECR 存储库,并将提到的图像推送到您自己的 ECR 并在模板中使用它。
我正在尝试使用 Python 3.8 为标准 AWS SAM HelloWorld 模板构建管道。我使用 this template 作为管道示例。我对管道所做的唯一更改是 Environment/Image,我正在将其从 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_CONTAINER_UNABLE_TO_PULL_IMAGE”时,我发现错误来自使用自定义构建映像。
我的问题
- 我将管道的图像更改为
aws/codebuild/python:3.8.3
是否正确
aws/codebuild/python:3.8.3
是有效图像吗?
关于 #2,我找到了 this page,虽然筛选起来有点复杂,但我相信 3.8.3 是一个有效的图像。
如能协助我获取管道 运行,我们将不胜感激。
这是因为它正试图从 docker 集线器中提取新图像,该集线器具有 throttling enabled for pulling images. So what you can do is pull the image from AWS Public ECR 并在您的环境中使用相同的图像。
还有另一种方法,您可以在帐户中创建自己的 ECR 存储库,并将提到的图像推送到您自己的 ECR 并在模板中使用它。