amazon-web-services - 如何通过 cloudformation 更新我现有的 lambda(不是由 cloudformation 创建的)。通过 cloudformation 建立管道
问题描述
我正在通过创建变更集并执行变更集来设置使用云形成堆栈的管道。但是第一次这会创建另一个 lambda,并且没有办法更新或部署现有创建的 lambda。
构建规范.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 > 打开您的堆栈 > 操作 > 导入现有资源。 https://aws.amazon.com/de/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/ 然后将您的本地 cloudformation 模板与 CloudFormation 中的模板进行比较。
推荐阅读
- node.js - Mongoose 在空数组中找到结果,并且很确定所有模型都匹配
- c++ - 使用类时,计时器似乎运行得更快。在 C 版本中,它按预期工作
- math - 为什么在十进制到二进制转换期间反转余数?
- bash - 没有 Emacs,Bash 命令行编辑在 Emacs 模式下如何工作?
- azure - 移动应用:在 Xamarin.Forms 中使用“Microsoft.Azure.Cosmos”.NET SDK V3 - 跨平台
- c - 结构字段声明顺序在 Rust 中是否重要?
- jquery - 无法正确地将 JSON 对象转换为 HTML
- mysql - VueJs Web 应用程序无法显示记录
- system-verilog - 如何在不使用 systemverilog 约束的情况下随机化 -5 到 21 之间的变量值?
- swift - jonkykong/侧边菜单。无法让选项工作