2017-03-05 73 views
1

當我嘗試創建與現有VPC關聯的新託管私有區域時,Terraform似乎無法創建AW​​S私有託管Route53區域,並死於以下錯誤:Terraform無法創建AW​​S私有託管路由53區域

Error applying plan: 
    1 error(s) occurred: 
    aws_route53_zone.analytics: InvalidVPCId: The VPC: vpc-xxxxxxx you provided is not authorized to make the association. 
    status code: 400, request id: b411af23-0187-11e7-82e3-df8a3528194f 

這是我的.tf文件:

provider "aws" { 
    region = "${var.region}" 
    profile = "${var.environment}" 
} 

variable "vpcid" { 
    default = "vpc-xxxxxx" 
} 

variable "region" { 
    default = "eu-west-1" 
} 

variable "environment" { 
    default = "dev" 
} 

resource "aws_route53_zone" "analytics" { 
    vpc_id = "${var.vpcid}" 
    name = "data.int.example.com" 
} 

我不知道如果錯誤指的是任一一個:

  • VPC不知何故需要被授權與區域提前聯繫。
  • 的AWS帳號運行terraform需要正確的IAM權限區域與VPC關聯

會有人有線索,我怎麼能進一步解決?

+0

有什麼terraform版本?似乎你運行舊版本。 – BMW

回答

0

檢查terraform版本是否運行最新或沒有。

其次,如果與sample

data "aws_route53_zone" "selected" { 
    name = "test.com." 
    private_zone = true 
} 

resource "aws_route53_record" "www" { 
    zone_id = "${data.aws_route53_zone.selected.zone_id}" 
    name = "www.${data.aws_route53_zone.selected.name}" 
    type = "A" 
    ttl = "300" 
    records = ["10.0.0.1"] 
} 
+0

我在Terraform v0.8.2上,看起來我的版本和最新版本之間的項目文檔有很大差異: –

+0

僅僅因爲示例不同並不意味着OP的代碼是錯誤的。事實上,這應該可以正常工作。我猜可能是因爲VPC ID錯誤,或者用戶/角色沒有必要的VPC相關權限。 – ydaetskcoR

0

比較你的代碼是錯誤的error code你得到是因爲無論你的用戶/角色沒有必要VPC相關的權限,或者你使用了錯誤的VPC ID。

我建議你仔細檢查你使用的是VPC ID,可能使用VPC data source去取:

# Assuming you use the "Name" tag on the VPC resource to identify your VPCs 
variable "vpc_name" {} 

data "aws_vpc" "selected" { 
    tags { 
    Name = "${var.vpc_name}" 
    } 
} 

resource "aws_route53_zone" "analytics" { 
    vpc_id = "${data.aws_vpc.selected.id}" 
    name = "data.int.example.com" 
} 

你還需要檢查你的用戶/角色擁有必要的VPC相關的權限。爲此,您可能會想所有在docs列出的權限:

enter image description here

+0

我在AWS提供商中使用配置文件時遇到問題。無論我做了什麼(v 0.8.7),它總是默認爲我在環境中設置的帳戶訪問權限。一旦我改變了env變量來訪問我想要做的工作的帳戶,它工作得很好。 – jpancoast

相關問題