忽略Terraform中已经配置的资源-AWS
有一个Terraform代码可以在AWS中配置MWAA环境。当它第二次运行时,无需再次创建IAM角色或策略。因此,它给出了一个错误。
如何忽略TF中现有资源的创建?
There is a terraform code to configure an MWAA Environment in AWS. When it runs second time, no need to create IAM role or policy again. So it gives an error.
How to ignore the creation of existing resources in TF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应用了创建资源“ MWAA”的Terraform计划,然后您以某种方式丢失了州(本地存储和丢失了?或状态未与其他客户共享?),然后您再次重新应用计划并且Terraform告诉您,它再次创建了“ MWAA”。
在这种情况下,您的主要问题是您失去了状态,并且您需要确保通过将其存储在存储桶中来确保它坚持下去。
但是,如果您确实需要使Terraform了解已经创建的资源,则需要将其放在Terraform的状态下。这样做的一种工具是“ Terraform Import”,您可以在此处阅读更多信息: https:// https:// www .terraform.io/cli/导入
I assume that you applied a Terraform plan which created resource "MWAA", then you somehow lost the state (locally stored and lost?, or the state wasn't shared with a different client?), then you re-apply the plan again, and Terraform informs you that it created "MWAA", again.
In that case, your main problem is that you lost the state, and you need to make sure that you do persist it, e.g., by storing it in a bucket.
However, if you really need to make Terraform aware about an already created resource, you need to put it in Terraform's state. One tool to do that is "terraform import", about which you can read more here: https://www.terraform.io/cli/import
如果您已经有状态文件,并且Terraform试图再次重新安装它,则可以是一些标签更改或修改的时间戳值更改...
为了避免,您可以指定要使用Terraform应用的资源应用命令..
If you already have the statefile and if terraform is trying to re-install it again, then may be some tag change or modified timestamp value change...
In order to avoid it, you can specify the resource you want to apply using a terraform apply command..