简体   繁体   English

AWS 基础设施即代码的文档

[英]Documentation for AWS infrastructure as code

Recently, while trying to build a terraform IaC, I found that I couldn't get the API Gateway to route to the Lambda properly.最近,在尝试构建一个 terraform IaC 时,我发现我无法让 API 网关正确路由到 Lambda。 It turned out that when using the console AWS automatically assigns the permissions the gateway needs for the Lambda, but with IaC in terraform this must be assigned explicitly.事实证明,当使用控制台时,AWS 会自动分配网关对 Lambda 所需的权限,但对于 terraform 中的 IaC,这必须明确分配。

The above is understandable but for a newbie, to both AWS and terraform, confusing.上面是可以理解的,但是对于新手来说,AWS和terraform这两个,一头雾水。

Is there documentation which explains the required components within an infrastructure connection, such as that above?是否有说明基础结构连接中所需组件的文档,例如上面的文档?

I know of the AWS docs and the terraform docs are particularly well thought out but none of it actually explains (as far as I've seen) that a certain resource is required in any particular (however common or obscure) setup.我知道 AWS 文档和 terraform 文档经过特别深思熟虑,但没有一个真正解释(据我所知)在任何特定(无论多么常见或晦涩)设置中都需要某种资源。 Inferring these connections from general searching is not a great replacement.从一般搜索中推断出这些联系并不是一个很好的替代方法。

I don't think that there is a documentation that lists "all of the required components" in one single page/area.我不认为有一个文档在一个页面/区域中列出“所有必需的组件”。 But you can get different pieces of information from different docs, and as you mentioned AWS and Terraform do both a great job at this.但是您可以从不同的文档中获取不同的信息,正如您提到的 AWS 和 Terraform 在这方面都做得很好。

Talking about AWS, in the case of permissions in API gateway, I can think of two useful links (the 1st one is referenced from the 2nd one though):谈到 AWS,在 API 网关中的权限的情况下,我可以想到两个有用的链接(第一个是从第二个引用的):

I agree in the fact that sometimes it's a lot of guesses to translate AWS into terraform if you don't really know what you are trying to achieve.我同意这样一个事实,即如果您真的不知道要实现的目标,有时将 AWS 转换为 terraform 会产生很多猜测。 Usually when I am blocked on something that "should theoritically work" in IaC vs AWS console, I step back from the problem and try to figure out what kind of components am I really trying to glue together in AWS world.通常当我在 IaC vs AWS 控制台中被“理论上应该工作”的东西所阻止时,我会从问题中退后一步,并试图弄清楚我真正想在 AWS 世界中将哪些组件粘合在一起。 Then usually things become more obvious.然后通常事情会变得更加明显。

Because in terraform it's really creating small independant pieces of infrastructure and make them work together.因为在 terraform 中,它实际上是在创建小型独立的基础设施,并使它们协同工作。 Comparing with other IaC, in my experience it's a lot more granular than CloudFormation for instance.与其他 IaC 相比,根据我的经验,它比 CloudFormation 等更精细。

A personal practice that helps me figure out things faster is to read every single intro doc of the components I am working on in Terraform. For instance, if I am writing lambda in terraform IaC, I would quickly read all the lambda_xxxx_yyyy intro parts to get less stuck and react faster when something fails.帮助我更快弄清楚事情的个人做法是阅读我在 Terraform 中处理的组件的每一个介绍文档。例如,如果我在 terraform IaC 中编写 lambda,我会快速阅读所有 lambda_xxxx_yyyy 介绍部分以获得发生故障时卡住的情况更少,反应更快。 It usually works for me.它通常对我有用。

I haven't see such a documentation, but I can share my work-around for similar cases.我没有看到这样的文档,但我可以分享我针对类似情况的解决方法。

You can make changes you need using AWS console - manually, using UI.您可以使用 AWS 控制台进行所需的更改 - 手动使用 UI。 Then you can define resources you just created in your TF files, defining only/required required set of properties, even random values will work.然后你可以定义你刚刚在你的 TF 文件中创建的资源,定义 only/required 所需的属性集,即使是随机值也可以。 Then you import what you created manually into resources you defined.然后将您手动创建的内容导入到您定义的资源中。

By running terraform plan you will see the differences, that will allow you to adjust your TF files accordingly.通过运行terraform plan ,您将看到差异,这将允许您相应地调整您的 TF 文件。

After few iterations you will replicate what you have just done in the UI using TF.几次迭代后,您将使用 TF 复制您刚刚在 UI 中完成的操作。 As a final test you can manually revert your changes, run terraform apply and ensure that everything works as expected.作为最终测试,您可以手动还原更改,运行terraform apply并确保一切按预期工作。

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

相关问题 如何在 AWS 上部署基础设施即代码 - How to deploy Infrastructure as Code on AWS Oracle 云基础设施上的 AWS Lambda 替代方案 - AWS Lambda alternative on Oracle Cloud Infrastructure 如何将 Terraform 状态与我的 AWS 基础设施同步 - How to sync Terraform state with my AWS infrastructure 基础设施即 azure 上的代码,使用 python - infrastructure as a code on azure using python Github 操作恢复/销毁 terraform Terraform 计划创建的 AWS 基础设施 - Github Actions revert/destroy terraform AWS infrastructure created by Terraform Plan 如何使用 AWS Lambda 脚本部署 AWS 基础设施与 Terraform - How can you use AWS Lambda scripts to deploy AWS Infrastructure with Terraform Azure Terraform 使用基础架构即代码构建通用组件 - Azure Terraform Build Generic Components using Infrastructure as Code 应用程序中嵌入的 Hazelcast 5.0.2 的实施在迁移到 AWS EKS 基础设施时无法检测到自身和第二个 pod - Implementation of Hazelcast 5.0.2 embedded in application fails to detect itself and second pod when migrated to AWS EKS Infrastructure AWS - Amazon S3 文档示例不起作用 SignatureDoesNotMatch - AWS - Amazon S3 documentation example not working SignatureDoesNotMatch 延迟 AWS 代码管道: - Delay AWS Code Pipeline:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM