{"id":48998,"date":"2023-07-26T05:47:15","date_gmt":"2023-02-06T15:45:41","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/"},"modified":"2024-04-30T15:24:10","modified_gmt":"2024-04-30T07:24:10","slug":"%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/","title":{"rendered":"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55"},"content":{"rendered":"<p>\u5728\u4f7f\u7528Terraform\u8fdb\u884c\u8d44\u6e90\u7ba1\u7406\u65f6\uff0c\u901a\u8fc7import\u547d\u4ee4\u53ef\u4ee5\u5c06\u73b0\u6709\u8d44\u6e90\u7eb3\u5165\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5f53\u4f7f\u7528ACM\u83b7\u53d6\u8bc1\u4e66\u5e76\u521b\u5efa\u7528\u4e8eDNS\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55\uff08CNAME\uff09\u65f6\uff0c\u5982\u679c\u5bfc\u5165\u540e\u6267\u884cterraform plan\u547d\u4ee4\uff0c\u4f1a\u8f93\u51fa&#8221;\u5c06\u9500\u6bc1\u5e76\u91cd\u65b0\u521b\u5efa\u73b0\u6709\u8d44\u6e90&#8221;\u7684\u4fe1\u606f\u3002\u867d\u7136\u5982\u679c\u8bc1\u4e66\u7684DNS\u9a8c\u8bc1\u8bb0\u5f55\u5df2\u7ecf\u5b8c\u6210\u9a8c\u8bc1\uff0c\u91cd\u65b0\u521b\u5efa\u53ef\u80fd\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u662f\u6211\u8003\u8651\u5230\u76ee\u6807\u8bc1\u4e66\u662f\u7528\u4e8eECS\u7684ALB\u4e0a\uff0c\u5982\u679c\u8bc1\u4e66\u51fa\u73b0\u95ee\u9898\uff0c\u6062\u590d\u53ef\u80fd\u4f1a\u5f88\u9ebb\u70e6\u3002\u56e0\u6b64\uff0c\u6211\u5c1d\u8bd5\u9a8c\u8bc1\u4e86\u4e00\u79cd\u65b9\u6cd5\uff0c\u4ee5\u786e\u4fddTerraform\u4e0d\u4f1a\u91cd\u65b0\u521b\u5efa\u73b0\u6709\u8bb0\u5f55\u3002<\/p>\n<h1>\u7ee7\u7eed\u8bb0\u5f55<\/h1>\n<p>\u5728\u9a8c\u8bc1\u8fc7\u7a0b\u4e2d\uff0c\u7531\u4e8e\u5728ACM\u4e0a\u521b\u5efa\u8bc1\u4e66\u7684\u65f6\u95f4\u5df2\u7ecf\u8fc7\u53bb\u4e86\u4e00\u6bb5\u65f6\u95f4\uff0c\u56e0\u6b64\u8bc1\u4e66\u548c\u5176\u9a8c\u8bc1\u8bb0\u5f55\u4e4b\u95f4\u7684\u5173\u7cfb\u4e0d\u660e\u786e\u3002\u6211\u62c5\u5fc3\u91cd\u65b0\u521b\u5efa\u9a8c\u8bc1\u8bb0\u5f55\u53ef\u80fd\u4f1a\u5f71\u54cd\u8bc1\u4e66\u7684\u5931\u6548\u6216\u9a8c\u8bc1\u72b6\u6001\u7684\u66f4\u6539\u3002\u7136\u800c\uff0c\u4ed4\u7ec6\u8003\u8651\u540e\uff0c\u6211\u53d1\u73b0\u5728\u521b\u5efa\u8bc1\u4e66\u65f6\u5e76\u6ca1\u6709\u76f8\u5e94\u7684\u9a8c\u8bc1\u8bb0\u5f55\u5b58\u5728\u3002\u800c\u4e14\u5728\u5b8c\u6210\u9a8c\u8bc1\u540e\u7684\u4e00\u6bb5\u65f6\u95f4\u5185\uff0c\u9a8c\u8bc1\u8bb0\u5f55\u4f3c\u4e4e\u6ca1\u6709\u88ab\u4f7f\u7528\u3002\u6240\u4ee5\u5373\u4f7f\u8fd0\u884cdestroy\/create\u64cd\u4f5c\uff0c\u5e94\u8be5\u4e5f\u4e0d\u4f1a\u6709\u95ee\u9898\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u8bfb\u53d6\u8bc1\u4e66\u9a8c\u8bc1\u4e0e\u5f53\u524d\u4f7f\u7528\u7684ALB\u5173\u8054\u7684\u8bb0\u5f55\u7684\u76ee\u7684\u662f\u4e00\u4e2a\u654f\u611f\u7684\u95ee\u9898\uff0c\u4f46\u5355\u7eaf\u5730\u5c06Route53\u8bb0\u5f55\u5bfc\u5165\u5230Terraform\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\uff08allow_overwrite=true\uff09\u53c2\u6570\u800c\u65e0\u9700\u4f7f\u7528import\u547d\u4ee4\u3002\u8fd9\u5c31\u662f\u6211\u8ba4\u4e3a\u7684\u3002<\/p>\n<h1>\u53e6\u5916\u8865\u5145<\/h1>\n<p>\u6211\u660e\u767d\u539f\u56e0\u4e86\u3002\u7531\u4e8e\u4f7f\u7528\u4e86for_each\u521b\u5efa\u7684\u8d44\u6e90\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5fc5\u987b\u6307\u5b9aaws_route53_record.cert_validation[&#8220;*.xxx.example.com&#8221;]\u3002<\/p>\n<h1>\u9a8c\u8bc1<\/h1>\n<p>\u73b0\u6709\u8bc1\u4e66\u7684\u72b6\u6001\u5982\u4e0b\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c9\u30e1\u30a4\u30f3\u540d: *.xxx.example.com \u203b\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u8a3c\u660e\u66f8<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u72b6\u6cc1: \u767a\u884c\u6e08\u307f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4f7f\u7528\u4e2d?: \u306f\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u72b6\u6cc1\u306e\u8a73\u7d30: \u8a3c\u660e\u66f8\u306f 2021-XX-XXTXX:XX:XXUTC \u306b\u767a\u884c\u3055\u308c\u307e\u3057\u305f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u691c\u8a3c\u72b6\u614b: \u6210\u529f<\/ul>\n<p>Terraform\u7684\u5b9a\u4e49\u4ee5acm_certificate_validation\u7684\u53c2\u8003\u8d44\u6599\u4e2d\u7684\u4ee5\u4e0b\u65b9\u5f0f\u5448\u73b0\u3002\u5b83\u4f1a\u81ea\u52a8\u6267\u884c\u4e00\u7cfb\u5217\u7684\u64cd\u4f5c\uff08\u5305\u62ec\u5728ACM\u4e2d\u9881\u53d1\u8bc1\u4e66\u5e76\u8fdb\u884cDNS\u9a8c\u8bc1\u7684\u64cd\u4f5c\uff09\uff0c\u5e76\u5e2e\u52a9\u6211\u4eec\u521b\u5efa\u8bc1\u4e66\u548c\u5bf9\u5e94\u7684Route53\u8bb0\u5f55\u3002<\/p>\n<pre class=\"post-pre\"><code>resource \"aws_acm_certificate\" \"example\" {\r\n  domain_name       = \"*.xxx.example.com\"\r\n  validation_method = \"DNS\"\r\n}\r\n\r\ndata \"aws_route53_zone\" \"example\" {\r\n  name         = \"xxx.example.com\"\r\n  private_zone = false\r\n}\r\n\r\nresource \"aws_route53_record\" \"example\" {\r\n  for_each = {\r\n    for dvo in aws_acm_certificate.example.domain_validation_options : dvo.domain_name =&gt; {\r\n      name   = dvo.resource_record_name\r\n      record = dvo.resource_record_value\r\n      type   = dvo.resource_record_type\r\n    }\r\n  }\r\n\r\n  allow_overwrite = true\r\n  name            = each.value.name\r\n  records         = [each.value.record]\r\n  ttl             = 60\r\n  type            = each.value.type\r\n  zone_id         = data.aws_route53_zone.example.zone_id\r\n}\r\n\r\nresource \"aws_acm_certificate_validation\" \"example\" {\r\n  certificate_arn         = aws_acm_certificate.example.arn\r\n  validation_record_fqdns = [for record in aws_route53_record.example : record.fqdn]\r\n}\r\n<\/code><\/pre>\n<p>\u5047\u8bbe\u73b0\u6709\u7684ACM\u8bc1\u4e66\u5df2\u7ecf\u88ab\u6210\u529f\u5bfc\u5165\uff08\u8d44\u6e90\u6307\u5b9a\u4f7f\u7528ARN\u65b9\u5f0f\u6709\u70b9\u7279\u6b8a\uff09\u3002<\/p>\n<p>\u521b\u5efa\u5b9a\u4e49\u540e\uff0c\u9996\u5148\u4f7f\u7528\u5e38\u89c4\u65b9\u6cd5\u5bfc\u5165\u8d44\u6e90\uff0c\u7136\u540e\u5728\u8ba1\u5212\u4e2d\u8fdb\u884c\u5dee\u5f02\u786e\u8ba4\u3002\u6267\u884c\u5bfc\u5165\u64cd\u4f5c\u3002<br \/>\n\uff08\u8bf7\u6ce8\u610f\uff0c\u8d44\u6e90\u6307\u5b9a\u683c\u5f0f\u4e3a\u533a\u57dfID_\u8bb0\u5f55_\u8bb0\u5f55\u7c7b\u578b\u3002ACM\u8bc1\u4e66DNS\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55\u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934\uff0c\u56e0\u6b64\u5728\u533a\u57dfID\u548c\u8bb0\u5f55\u4e4b\u95f4\u4f7f\u7528\u8fde\u7eed\u7684\u4e0b\u5212\u7ebf\u8fdb\u884c\u5206\u9694\uff09<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform import aws_route53_record.cert_validation XXXXXXXXXX__XXXXXXXXXX.xxx.example.com_CNAME\r\n\r\nImport successful!\r\n\r\nThe resources that were imported are shown above. These resources are now in\r\nyour Terraform state and will henceforth be managed by Terraform.\r\n<\/code><\/pre>\n<p>\u53d6\u5f97\u6210\u529f\u3002<br \/>\n\u968f\u540e\u6309\u7167\u4e0a\u8ff0\u5b9a\u4e49\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform plan\r\n\r\nactions are indicated with the following symbols:\r\n  + create\r\n  - destroy\r\n\r\nTerraform will perform the following actions:\r\n\r\n  # module.common.aws_route53_record.cert_validation will be destroyed\r\n      - fqdn    = \"_XXXXXXXXXX.xxx.example.com\" -&gt; null\r\nom_CNAME\" -&gt; null\r\n      - name    = \"_XXXXXXXXXX.xxx.example.com\" -&gt; null\r\nd\r\n  + resource \"aws_route53_record\" \"cert_validation\" {\r\n      + allow_overwrite = true\r\n      + fqdn            = (known after apply)\r\n      + id              = (known after apply)\r\n      + name            = \"_XXXXXXXXXX.xxx.example.com\"\r\n      + records         = [\r\n          + \"_XXXXXXXXXX.XXXXXXXXXX.acm-validations.aws.\",\r\n        ]\r\n      + ttl             = 300\r\n      + type            = \"CNAME\"\r\n      + zone_id         = \"XXXXXXXXXX\"\r\n    }\r\n\r\nPlan: 1 to add, 0 to change, 1 to destroy.\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u5728\u8fc7\u7a0b\u4e2d\u6dfb\u52a0\u4e86\u5173\u4e8eaws_acm_certificate_validation\u7684\u63cf\u8ff0\uff0c\u56e0\u6b64\u6b64\u5904\u6ca1\u6709\u8f93\u51fa\u3002<\/p>\n<p>\u5df2\u7ecf\u8f93\u51fa\u4e86\u4e00\u4e2a\u9500\u6bc1\u73b0\u6709\u8bb0\u5f55\u5e76\u521b\u5efa\u65b0\u8bb0\u5f55\u7684\u8ba1\u5212\u3002<br \/>\n\u7531\u4e8e\u5e0c\u671b\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u6682\u65f6\u56de\u6eda\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform state rm aws_route53_record.cert_validation\r\n\r\nRemoved aws_route53_record.cert_validation\r\nSuccessfully removed 1 resource instance(s).\r\n<\/code><\/pre>\n<p>\u4e0d\u4f7f\u7528import\u7684\u60c5\u51b5\u4e0b\u5236\u5b9a\u8ba1\u5212\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform plan\r\n\r\nTerraform used the selected providers to generate the following execution plan. Resource     \r\nactions are indicated with the following symbols:\r\n  + create\r\n\r\nTerraform will perform the following actions:\r\n\r\n  # aws_acm_certificate_validation.cert will be created\r\n  + resource \"aws_acm_certificate_validation\" \"cert\" {\r\n      + certificate_arn         = \"arn:aws:acm:ap-northeast-1:XXXXXXXXXX:certificate\/XXXXXXXXXX\"\r\n      + id                      = (known after apply)\r\n      + validation_record_fqdns = (known after apply)\r\n    }\r\n\r\n  # aws_route53_record.cert_validation[\"*.xxx.example.com\"] will be created\r\n  + resource \"aws_route53_record\" \"cert_validation\" {\r\n      + allow_overwrite = true\r\n      + fqdn            = (known after apply)\r\n      + id              = (known after apply)\r\n      + name            = \"_XXXXXXXXXX.xxx.example.com\"\r\n      + records         = [\r\n          + \"_XXXXXXXXXX.XXXXXXXXXX.acm-validations.aws.\",\r\n        ]\r\n      + ttl             = 300\r\n      + type            = \"CNAME\"\r\n      + zone_id         = \"XXXXXXXXXX\"\r\n    }\r\n\r\nPlan: 2 to add, 0 to change, 0 to destroy.\r\n<\/code><\/pre>\n<p>\u5728Route53\u8bb0\u5f55\u7684\u53c2\u8003\u8d44\u6599\u4e2d\uff0c\u5982\u679callow_overwrite\u8bbe\u7f6e\u4e3atrue\uff0c\u90a3\u4e48\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u7684\u8bb0\u5f55\uff0c\u5c31\u4f1a\u8fdb\u884c\u8986\u76d6\u3002\u4f46\u662f\u5373\u4f7f\u662f\u8986\u76d6\uff0c\u53ea\u8981\u5728terraform\u4e0a\u4e0d\u88ab\u89c6\u4e3adestroy\uff0c\u8d44\u6e90\u5e94\u8be5\u4f1a\u7ee7\u7eed\u8fd0\u884c\u800c\u4e0d\u88ab\u5220\u9664\uff08\u81f3\u5c11\u6211\u5e0c\u671b\u5982\u6b64\uff09\u3002<\/p>\n<blockquote><p>\u5141\u8bb8\u8986\u76d6 -\uff08\u53ef\u9009\uff09\u5982\u679c\u6709\u7684\u8bdd\uff0c\u5141\u8bb8\u5728Terraform\u4e2d\u8986\u76d6\u73b0\u6709\u8bb0\u5f55\u4ee5\u521b\u5efa\u6b64\u8bb0\u5f55\u3002\u8fd9\u4e0d\u4f1a\u5f71\u54cd\u5728Terraform\u4e2d\u66f4\u65b0\u8bb0\u5f55\u7684\u80fd\u529b\uff0c\u4e5f\u4e0d\u4f1a\u963b\u6b62Terraform\u5185\u7684\u5176\u4ed6\u8d44\u6e90\u6216\u5728Terraform\u4e4b\u5916\u624b\u52a8\u8fdb\u884c\u7684Route 53\u66f4\u6539\u8986\u76d6\u6b64\u8bb0\u5f55\u3002\u9ed8\u8ba4\u4e3afalse\u3002\u4e0d\u5efa\u8bae\u5728\u5927\u591a\u6570\u73af\u5883\u4e2d\u4f7f\u7528\u6b64\u914d\u7f6e\u3002<\/p><\/blockquote>\n<p>\u6211\u7533\u8bf7\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform apply\r\n\r\nTerraform used the selected providers to generate the following execution plan. Resource     \r\nactions are indicated with the following symbols:\r\n  + create\r\n      + certificate_arn         = \"arn:aws:acm:ap-northeast-1:XXXXXXXXXX:certificate\/XXXXXXXXXX\"\r\n      + id                      = (known after apply)\r\n      + validation_record_fqdns = (known after apply)\r\n    }\r\n\r\n  # aws_route53_record.cert_validation[\"*.xxx.example.com\"] will be created\r\n  + resource \"aws_route53_record\" \"cert_validation\" {\r\n      + allow_overwrite = true\r\n      + fqdn            = (known after apply)\r\n      + id              = (known after apply)\r\n      + name            = \"_XXXXXXXXXX.xxx.example.com\"\r\n      + records         = [\r\n          + \"_eacbe743751c2f4f3d1aff8c466acc27.jddtvkljgg.acm-validations.aws.\",\r\n        ]\r\n      + ttl             = 300\r\n      + type            = \"CNAME\"\r\n      + zone_id         = \"XXXXXXXXXX\"\r\n    }\r\n\r\nPlan: 2 to add, 0 to change, 0 to destroy.\r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Creating...      \r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Still creating... [10s elapsed]\r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Still creating... [20s elapsed]\r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Still creating... [30s elapsed]\r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Still creating... [40s elapsed]\r\naws_route53_record.cert_validation[\"*.xxx.example.com\"]: Creation complete after 46s [id=XXXXXXXXXX__XXXXXXXXXX.xxx.example.com._CNAME]\r\naws_acm_certificate_validation.cert: Creating...\r\naws_acm_certificate_validation.cert: Creation complete after 1s [id=2021-05-21 00:34:19 +0000 UTC]\r\n\r\nApply complete! Resources: 2 added, 0 changed, 0 destroyed.\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u786e\u8ba4\u4e86\u7533\u8bf7\u4e4b\u524d\u548c\u4e4b\u540e\u8bc1\u4e66\u7684\u72b6\u6001\uff0c\u5b8c\u5168\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c9\u30e1\u30a4\u30f3\u540d: *.xxx.example.com \u203b\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u8a3c\u660e\u66f8<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u72b6\u6cc1: \u767a\u884c\u6e08\u307f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4f7f\u7528\u4e2d?: \u306f\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u72b6\u6cc1\u306e\u8a73\u7d30: \u8a3c\u660e\u66f8\u306f 2021-XX-XXTXX:XX:XXUTC \u306b\u767a\u884c\u3055\u308c\u307e\u3057\u305f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u691c\u8a3c\u72b6\u614b: \u6210\u529f<\/ul>\n<p>\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u6211\u4eec\u4f1a\u6267\u884c\u8fd9\u4e2a\u8ba1\u5212\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform plan\r\nNote: Objects have changed outside of Terraform\r\n\r\nTerraform detected the following changes made outside of Terraform since the last \"terraform \r\napply\":\r\n\r\n  # aws_route53_record.cert_validation[\"*.xxx.example.com\"] has been chang        id              = \"XXXXXXXXXX__XXXXXXXXXX.xxx.example.com        name            = \"_XXXXXXXXXX.xxx.example.com\"\r\n        # (6 unchanged attributes hidden)\r\n    }\r\n\r\nUnless you have made equivalent changes to your configuration, or ignored the relevant       \r\nattributes using ignore_changes, the following plan may include actions to undo or respond   \r\nto these changes.\r\n\r\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \r\n\r\n\r\nYour configuration already matches the changes detected above. If you'd like to update the   \r\nTerraform state to match, create and apply a refresh-only plan:\r\n  terraform apply -refresh-only\r\n<\/code><\/pre>\n<p>\u56e0\u4e3a\u8bbe\u7f6e\u6ca1\u6709\u5dee\u5f02\uff0c\u4f46\u5728tfstate\u4e2d\u5b58\u5728\u5dee\u5f02\uff0c\u6240\u4ee5\u8f93\u51fa\u4e86\u8981\u6267\u884c\u5237\u65b0\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform apply -refresh-only\r\n\r\nNote: Objects have changed outside of Terraform\r\n\r\nTerraform detected the following changes made outside of Terraform since the last \"terraform \r\napply\":\r\n\r\n  # aws_route53_record.cert_validation[\"*.xxx.example.com\"] has been changed\r\n  ~ resource \"aws_route53_record\" \"cert_validation\" {\r\n        id              = \"XXXXXXXXXX__XXXXXXXXXX.xxx.example.com._CNAME\"\r\n        name            = \"_XXXXXXXXXX.xxx.example.com\"\r\n        # (6 unchanged attributes hidden)\r\n    }\r\n\r\nThis is a refresh-only plan, so Terraform will not take any actions to undo these. If you    \r\nwere expecting these changes then you can apply this plan to record the updated values in    \r\nthe Terraform state without changing any remote objects.\r\n\r\nWould you like to update the Terraform state to reflect these detected changes?\r\n  Terraform will write these changes to the state without modifying any real infrastructure. \r\n  There is no undo. Only 'yes' will be accepted to confirm.\r\n\r\n  Enter a value: yes\r\n\r\n\r\nApply complete! Resources: 0 added, 0 changed, 0 destroyed.\r\n<\/code><\/pre>\n<p>\u6211\u5011\u5c07\u518d\u6b21\u57f7\u884c\u8a08\u5283\u3002<\/p>\n<pre class=\"post-pre\"><code>&gt; terraform plan\r\n\r\nNo changes. Your infrastructure matches the configuration.\r\n\r\nTerraform has compared your real infrastructure against your configuration and found no      \r\ndifferences, so no changes are needed.\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u4efb\u4f55\u6539\u53d8\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\n\u6211\u4eec\u4e86\u89e3\u5230\uff0c\u53ef\u4ee5\u4e0d\u5bfc\u5165Route53\u7684\u8bb0\u5f55\uff0c\u800c\u662f\u4f7f\u7528allow_overwrite=true\u6765\u8986\u76d6\u73b0\u6709\u8bb0\u5f55\u3002<br \/>\n\u4f46\u8bf7\u6ce8\u610f\uff0c\u7531\u4e8e\u6211\u4eec\u53ea\u662f\u9488\u5bf9ACM\u9a8c\u8bc1\u4f7f\u7528\u7684CNAME\u8bb0\u5f55\u8fdb\u884c\u4e86\u6d4b\u8bd5\uff0c\u5176\u4ed6\u8bb0\u5f55\u7c7b\u578b\u5c1a\u672a\u786e\u8ba4\u3002<\/p>\n<h1>\u8bf7\u63d0\u4f9b\u66f4\u591a\u7684\u4e0a\u4e0b\u6587\u6216\u8005\u53e5\u5b50\uff0c\u4ee5\u4fbf\u6211\u80fd\u51c6\u786e\u5730\u628a\u5b83\u7ffb\u8bd1\u6210\u4e2d\u6587\u3002<\/h1>\n<p>\u6839\u636eRoute53\u8bb0\u5f55\u7684\u53c2\u8003\u8d44\u6599\uff0c\u521b\u5efa\u533a\u57df\u65f6\u4e0d\u9700\u8981\u8fdb\u884cNS\/SOA\u8bb0\u5f55\u7684terraform\u5bfc\u5165\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528Terraform\u8fdb\u884c\u8d44\u6e90\u7ba1\u7406\u65f6\uff0c\u901a\u8fc7import\u547d\u4ee4\u53ef\u4ee5\u5c06\u73b0\u6709\u8d44\u6e90\u7eb3\u5165\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5f53\u4f7f\u7528ACM\u83b7\u53d6\u8bc1\u4e66 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-48998","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eacm\u8bc1\u4e66\u9a8c\u8bc1\u7684route53\u8bb0\u5f55\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55\" \/>\n<meta property=\"og:description\" content=\"\u5728\u4f7f\u7528Terraform\u8fdb\u884c\u8d44\u6e90\u7ba1\u7406\u65f6\uff0c\u901a\u8fc7import\u547d\u4ee4\u53ef\u4ee5\u5c06\u73b0\u6709\u8d44\u6e90\u7eb3\u5165\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5f53\u4f7f\u7528ACM\u83b7\u53d6\u8bc1\u4e66 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eacm\u8bc1\u4e66\u9a8c\u8bc1\u7684route53\u8bb0\u5f55\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-06T15:45:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T07:24:10+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/\",\"name\":\"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-02-06T15:45:41+00:00\",\"dateModified\":\"2024-04-30T07:24:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eacm\u8bc1\u4e66\u9a8c\u8bc1\u7684route53\u8bb0\u5f55\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55","og_description":"\u5728\u4f7f\u7528Terraform\u8fdb\u884c\u8d44\u6e90\u7ba1\u7406\u65f6\uff0c\u901a\u8fc7import\u547d\u4ee4\u53ef\u4ee5\u5c06\u73b0\u6709\u8d44\u6e90\u7eb3\u5165\u7ba1\u7406\u3002\u7136\u800c\uff0c\u5f53\u4f7f\u7528ACM\u83b7\u53d6\u8bc1\u4e66 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eacm\u8bc1\u4e66\u9a8c\u8bc1\u7684route53\u8bb0\u5f55\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-02-06T15:45:41+00:00","article_modified_time":"2024-04-30T07:24:10+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/","name":"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-02-06T15:45:41+00:00","dateModified":"2024-04-30T07:24:10+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Terraform\u6765\u7ba1\u7406\u73b0\u6709\u7684\u7528\u4e8eACM\u8bc1\u4e66\u9a8c\u8bc1\u7684Route53\u8bb0\u5f55"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8terraform%e6%9d%a5%e7%ae%a1%e7%90%86%e7%8e%b0%e6%9c%89%e7%9a%84%e7%94%a8%e4%ba%8eacm%e8%af%81%e4%b9%a6%e9%aa%8c%e8%af%81%e7%9a%84route53%e8%ae%b0%e5%bd%95%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/48998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=48998"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/48998\/revisions"}],"predecessor-version":[{"id":92714,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/48998\/revisions\/92714"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=48998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=48998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=48998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}