CDK 是否执行编排?除了提供 [英] Does CDK perform orchestration ? apart from provisioning

查看:28
本文介绍了CDK 是否执行编排?除了提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 CloudFormation/Terraform 在 AWS 中配置资源.

We used CloudFormation/Terraform for provisioning resources in AWS.

配置是关于创建一个新状态

Provisioning is about creating a new state

将一种状态转换为另一种状态.

transforming one state to another.

例如:一个状态是一台安装了apache web x.y的机器

for example: a state is a machine installed with apache web x.y

我们使用 ansible 工具来编排配置

We used ansible tool to orchestrate provisioning

自动化是定义可以自动执行的任务.

Automation is to define task that can be executed automatically.

可以在单个系统上使用自动化.编排采用自动化并协调多个系统之间的过程.通常是因为一个系统在完成其任务之前可能依赖于另一个系统.没有自动化,就无法进行编排.

Automation may be used on the single system. Orchestration takes the automation and coordinates the process between multiple systems. Usually because one system may be dependent on another system before it can accomplish its task. You cannot have orchestration without automation.

因此,编排就是解决依赖关系

So, Orchestration is about resolving dependencies

Ansible playbook 有助于编排

Ansible playbooks help in orchestration

但 AWS CDK 看起来对程序员更友好

But AWS CDK looks more programmer friendly for provisioning

下面的命令

aws cdk init

aws cdk synth

aws cdk deploy

负责在 AWS 中进行配置

are take care of provisioning in AWS

对于编排,AWS CDK 是否也负责解决依赖关系?在配置中

For orchestration, Does AWS CDK also take care of resolving dependencies? amidst provisioning

推荐答案

是的,您可以在 CDK 应用程序中设置堆栈之间的依赖关系,以类似于其他 CloudFormation 编排工具的方式来编排构建堆栈的方式,例如堆垛机.通过 CDK 中的抽象,依赖项可以是显式或隐式的.

Yes, you can set dependencies between stacks within a CDK application that will orchestrate how it would build the stacks similar to how other CloudFormation orchestration tools would, e.g. Stacker. Dependencies can be explicit or implicit via abstractions within CDK.

CDK 示例存储库中 Python 的跨堆栈参考示例中的示例:https://github.com/aws-samples/aws-cdk-examples/tree/master/python/cross-stack-resources/native-对象

An example would be in the cross-stack reference examples for Python in the CDK examples repository: https://github.com/aws-samples/aws-cdk-examples/tree/master/python/cross-stack-resources/native-objects

在上面的示例中,基础设施和应用程序堆栈之间存在一个隐式依赖集,其中应用程序堆栈依赖于由基础设施堆栈创建的 Lambda 来构建自己的 API 网关.

In the above example, there's an implicit dependency set between the Infrastructure and the Application stack where the Application stack depends on the Lambda being created by the Infrastructure stack to build the its own API Gateway.

一个明确的例子是使用 add_dependency(construct) 方法,例如

An explicit example would be using the add_dependency(construct) method, e.g.

shared_stack = SharedStack(
    app,
    "SharedStack",
    stack_name='-'.join( [ app.node.try_get_context('app_name'), 'shared', app.node.try_get_context('env') ] ),
    **splat
)

lambda_stack = LambdaStack(
    app,
    "LambdaStack",
    stack_name='-'.join( [ app.node.try_get_context('app_name'), 'lambda', app.node.try_get_context('env') ] ),
    **splat
)

lambda_stack.add_dependency(shared_stack)

这篇关于CDK 是否执行编排?除了提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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