【问题标题】:Debugging route53 hosted zone issues with terraform使用 terraform 调试 route53 托管区域问题
【发布时间】:2016-05-13 07:06:02
【问题描述】:

在 Atlas 上运行 terraform apply 时,它在 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 以便将其删除?或者,我怎样才能找出正在使用的资源并污染该资源?此应用的 repo 在这里:https://github.com/zinedistro/infrastructure

编辑:这里是full debug logs

【问题讨论】:

  • 您可以在启用调试的情况下再次运行吗? TF_LOG=DEBUG; terraform apply.你得到了什么?

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


【解决方案1】:

看起来 terraform 试图以某种方式创建/销毁/操作的托管区域已经存在。这可能来自之前的失败创建尝试或之前手动添加区域的人。解决此错误的一种方法是进入控制台并确定已经存在的特定区域(“网站”?),然后手动删除它,然后使用 Terraform 重新创建。

【讨论】:

    【解决方案2】:

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

    此外,您可以转到 AWS 控制台 > Route 53 > 托管区域并查看 Hosted Zone ID 列。

    【讨论】:

      【解决方案3】:

      如果有一个非默认记录集,则不能删除托管区域。 请在AWS docs 中查看。

      【讨论】:

        【解决方案4】:

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

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

        【讨论】:

          猜你喜欢
          • 2017-07-25
          • 2020-08-07
          • 2020-12-03
          • 2015-12-06
          • 2018-07-09
          • 1970-01-01
          • 1970-01-01
          • 2018-03-08
          • 1970-01-01
          相关资源
          最近更新 更多