使用terraform调试route53托管区域问题

时间:2016-02-03 21:23:23

标签: amazon-web-services amazon-route53 terraform

在Atlas上运行terraform应用并且在AWS路由53上失败时,我遇到以下错误:

Apply execution has failed
The apply encountered an errored while executing 10 minutes ago. State information was persisted and subsequent applies will continue making changes in a safe way.
Terraform v0.6.11

Setting up remote state...
Downloading remote modules...
Refreshing Terraform state prior to plan...
aws_route53_zone.zone: Destroying...
module.prod_website.aws_iam_access_key.website: Creating...
  secret:            "" => "<computed>"
  ses_smtp_password: "" => "<computed>"
  status:            "" => "<computed>"
  user:              "" => "domain.tld"
module.prod_website.aws_iam_access_key.website: Creation complete
Error applying plan:

1 error(s) occurred:

* aws_route53_zone.zone: HostedZoneNotEmpty: The specified hosted zone contains non-required resource record sets  and so cannot be deleted.
    status code: 400, request id: 8305ce48-cab3-11e5-92ae-d57244aa6db1

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

如何确定托管区域的ID以便我可以删除它?或者,我如何找出正在使用的资源并污染该资源?此申请的回购是:https://github.com/zinedistro/infrastructure

编辑:以下是full debug logs

4 个答案:

答案 0 :(得分:0)

看起来terraform试图以某种方式创建/销毁/操纵的托管区域已经存在。这可能来自先前失败的创建尝试或之前手动添加区域的人。解决此错误的一个选项是通过控制台进入并确定已存在哪个特定区域(&#34;网站&#34;?),然后手动将其删除,然后使用Terraform重新创建。

答案 1 :(得分:0)

使用AWS CLI,您可以运行aws route53 list-hosted-zones以获取托管区域列表。

另外,您可以转到AWS控制台&gt; <路线53>托管区域并查看Hosted Zone ID列。

答案 2 :(得分:0)

如果甚至有一个非默认记录集,则删除托管区域 。 请在AWS docs

中查看

答案 3 :(得分:0)

Terraform 0.7.1 introduced能够为区域指定force_destroy参数,如果设置为true,将删除区域中的所有记录,然后删除区域本身。

如果您希望Terraform完全管理区域,但是其他工具可能会添加Terraform不知道的记录,这可能很有用。