【发布时间】:2020-12-19 10:47:45
【问题描述】:
最近在 AWS 上设置了一个基本 CodePipeline(遵循本指南:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html),当 CodeCommit 存储库上有新提交时触发。
但即使管道成功执行后,lambda 函数也不会更新。
我的 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
我的模板.yaml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
helloWorld
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
还有什么需要做的额外配置吗?
【问题讨论】:
-
请查看 codebuild 生成的 'outputtemplate.yml'。如果资源“AWS::Serverless::Function”下的 CodeUri 是静态 s3 路径(如 zip 文件的路径),则 CloudFormation 可能无法“检测”到更改。
标签: amazon-web-services aws-lambda amazon-cloudformation aws-codepipeline aws-code-deploy