如何通过cloudformation更新现有的lambda(不是由cloudformation创建的).通过云形成建立管



我正在通过创建更改集和执行更改集来设置使用云形成堆栈的管道。但是这第一次创建了另一个lambda,并且没有办法更新或部署已经创建的lambda。

buildspec.yml

version: 0.1
phases:
install:
commands:
- echo "nothing to do in install phase"
pre_build:
commands:
- mvn clean install
build:
commands:
- aws cloudformation package --template-file samTemplate.yaml --s3-bucket saurabh-lambda-pipeline --output-template-file outputSamTemplate.yaml
artifacts:
type: zip
files:
- samTemplate.yaml
- outputSamTemplate.yaml

samTemplate.yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: CD Lambda
Resources:
testLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: testLambda
Handler: com.test.handler.calculator::handleRequest
Runtime: java8
CodeUri: target/emi-calculator.jar
AutoPublishAlias: prod
Description: 'Lambda function for CD'
MemorySize: 128
Timeout: 30
Events:
getAZsAPI:
Type: Api
Properties:
Path: /calculator
Method: post
Environment:
Variables:
calculatorType: 30

您可以将现有资源添加到现有云形成堆栈中。AWS控制台>Cloudformation祝辞打开你的Stack>行动比;导入现有资源。https://aws.amazon.com/de/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/然后将您的本地cloudformation模板与cloudformation中的模板进行比较。

最新更新