简体   繁体   English

cdk diff 注释实际上是否从 AWS 读取以与 cdk.out 中生成的文件进行比较?

[英]Does cdk diff comment actually read from AWS to compare with file generated in cdk.out?

I have read the AWS doc that CDK diff Compares the specified stack and its dependencies with the deployed stacks or a local CloudFormation template , I can see that my local CFN template are generated under cdk.out folder but where is the "deployed stacks" it compares with to show me the diff?我已经阅读了 CDK diff Compares the specified stack and its dependencies with the deployed stacks or a local CloudFormation templateAWS 文档,我可以看到我的本地 CFN 模板是在 cdk.out 文件夹下生成的,但是它的“已部署堆栈”在哪里比较以显示差异? Does it actually read from cloud to get that or it also somewhere has a local copy of latest deployed CFN?它实际上是从云中读取以获取它还是在某处有最新部署的 CFN 的本地副本?

if it reads from the cloud to do the diff, does it mean if I change anything manually through aws console, then the diff will be differently each time?如果它从云中读取数据来做差异,是否意味着如果我通过 aws 控制台手动更改任何内容,那么每次差异都会不同?

Thanks谢谢

As per command documentation cdk diff can either compare your cdk.out with the actual CloudFormation stack or with another template stored locally.根据命令文档cdk diff可以将您的 cdk.out 与实际的 CloudFormation 堆栈或与本地存储的另一个模板进行比较。

Does it actually read from cloud to get that or it also somewhere has a local copy of latest deployed CFN?它实际上是从云中读取以获取它还是在某处有最新部署的 CFN 的本地副本?

If you are running cdk diff against actual CloudFormation stack, then yes command will fetch template from the cloud (AWS CloudFormation) and compare two templates.如果您针对实际的 CloudFormation 堆栈运行cdk diff ,则 yes 命令将从云 (AWS CloudFormation) 中获取模板并比较两个模板。

If you are running cdk diff against locally stored template (for example, if you did a backup of previous cdk.out result), then it won't fetch anything from the cloud and will do a local comparison only.如果您正在针对本地存储的模板运行cdk diff (例如,如果您对之前的 cdk.out 结果进行了备份),那么它不会从云端获取任何内容,只会进行本地比较。

if it reads from the cloud to do the diff, does it mean if I change anything manually through aws console, then the diff will be differently each time?如果它从云中读取数据来做差异,是否意味着如果我通过 aws 控制台手动更改任何内容,那么每次差异都会不同?

Depends on what you mean by manual changes.取决于您所说的手动更改是什么意思。 If you make manual changes to the CloudFormation template, then cdk diff will see that and adjust difference accordingly.如果您对 CloudFormation 模板进行手动更改,则cdk diff将看到并相应地调整差异。 If, however, you make manual change to the actual AWS resource (ex: S3 bucket), then cdk diff won't see that because your actual CloudFormation template will not change.但是,如果您手动更改实际的 AWS 资源(例如:S3 存储桶),那么cdk diff将看不到它,因为您的实际 CloudFormation 模板不会更改。 To find differences between CloudFormation template and actual AWS resources you can use CloudFormation drift detection feature要查找 CloudFormation 模板与实际 AWS 资源之间的差异,您可以使用CloudFormation 漂移检测功能

Local Template <-- cdk diff --> ☁️ Deployed Template <-- Drift --> ☁️ AWS resources本地模板 <-- cdk diff --> ☁️ 部署模板 <-- 漂移--> ☁️ AWS 资源

cdk diff compares two templates. cdk diff比较两个模板。 By default, it compares your locally synth-ed template with the currently deployed cloud-side template in CloudFormation.默认情况下,它将您本地合成的模板与 CloudFormation 中当前部署的云端模板进行比较。 You can instead compare two local templates by passing the --template flag.您可以通过传递--template标志来比较两个本地模板。

Does it actually read from cloud to get that?它实际上是从云中读取的吗?

Yes.是的。 When your run cdk diff , the CDK CLI calls the CloudFormation DescribeStacks API to retrieve the cloud-side template.当您运行cdk diff时,CDK CLI 调用 CloudFormation DescribeStacks API 来检索云端模板。

If I change anything manually through aws console, then the diff will be differently each time?如果我通过 aws 控制台手动更改任何内容,那么每次差异都会不同?

No. cdk diff compares two templates.cdk diff比较两个模板。 Differences between the intended configuration (the deployed template) and actual configuration (what resources actually exist) can arise if changes are made to a stack's resources via the console or APIs.如果通过控制台或 API 对堆栈的资源进行更改,则预期配置(部署的模板)和实际配置(实际存在的资源)之间可能会出现差异。 These differences are called drift .这些差异称为漂移 CloudFormation can detect some of these deviations with the DescribeStackResourceDrifts API. CloudFormation 可以使用DescribeStackResourceDrifts API 检测其中的一些偏差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM