已按照此处的教程尝试设置AWS管道:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
以下是一些操作,我已经尝试过了:
下面是我的buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
build:
commands:
- npm install
- export BUCKET=xx-test
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yml
artifacts:
type: zip
files:
- template.yml
- outputtemplate.yml
下面是我的template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
helloWorld
DZ Bank API Gateway connectivity helloWorld
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./
Handler: app.lambdaHandler
Runtime: nodejs12.x
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
答案 0 :(得分:6)
该错误实际上与CodeBuild有关,而不与CodePipeline有关。似乎CodeBuild没有对其附加服务角色的有效权限。
在控制台中,您可以通过执行以下操作找到附加的服务角色:
如果该IAM角色尚不存在,则需要被授予该权限(在您的情况下为“ s3:PutObject”)。
AWS在Create a CodeBuild service role文档中提供了完整的政策。
答案 1 :(得分:1)
与云形成和代码管道服务角色相关联的“ cfn-lambda-pipeline”角色。
S3权限应与 CodeBuild (CB)关联,因为CB将运行buildspec.yml
。因此,CB必须能够访问S3。
根据Update the build stage role部分中链接的教程,AmazonS3FullAccess
应添加到codebuild-lamba-pipeline-build-service-role
角色,而不是cfn-lambda-pipeline
或CodePipeline的角色。