使用CDK,是否可以通过lambda触发它以部署堆栈 [英] With CDK, can it be triggered through a lambda to deploy the stack

查看:65
本文介绍了使用CDK,是否可以通过lambda触发它以部署堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CDK有助于构建AWS应用程序堆栈.据我所知,我们可以编写CDK代码,然后使用 cdk deploy 部署我们创建的应用程序堆栈.

CDK is good to building the AWS application stack. As far as I know, we can write CDK code and then use cdk deploy to deploy the application stack we created.

但是可以通过编程方式触发CDK代码吗?例如,我将CDK代码包装到lambda中,并按需触发(将传入一些参数,以便可以自定义我们创建的应用程序),然后在lambda完成时,便创建了应用程序堆栈.

But is that possible to programmatically trigger the CDK code? For example, I wrap CDK code into lambda, and trigger it on demand (will pass in some parameters so that the application we create can be customized), and when lambda finishes, we have the application stack created.

推荐答案

这是可能的-但很混乱.

That's possible - but messy.

在这种情况下,您的Lambda函数仅需要具有与CloudFormation进行对话并创建它可能需要的所有资源的权限.

In that case your Lambda Function just needs to have permissions to talk to CloudFormation and to create all the resources it might need.

然后您会陷入通过代码触发CDK的混乱之中.

Then you get into the mess of triggering the CDK via Code.

有几个人尝试过此方法,也许这对您的研究有所帮助:

There are a couple of people that have tried this, maybe this helps with your research:

  • How to package AWS CDK into Lambda layer? (Stack Overflow)
  • How to deploy CDK app via Lambda (Github)

根据您的用例,可能值得考虑通过CodePipeline进行此操作,或者让用户通过Service Catalogue来配置基础结构.

Depending on your use case it might be worth considering doing this via CodePipeline or have users provision infrastructure via Service Catalogue.

这篇关于使用CDK,是否可以通过lambda触发它以部署堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆