我正在嘗試在帳戶之間創建VPC對等並自動接受它,但它失敗並顯示權限錯誤。爲什麼在嘗試在Terraform中auto_accept vpc對等時收到權限錯誤?
這裏是提供商在main.tf
provider "aws" {
region = "${var.region}"
shared_credentials_file = "/Users/<username>/.aws/credentials"
profile = "sandbox"
}
data "aws_caller_identity" "current" { }
這裏是vpc_peer模塊:
resource "aws_vpc_peering_connection" "peer" {
peer_owner_id = "${var.peer_owner_id}"
peer_vpc_id = "${var.peer_vpc_id}"
vpc_id = "${var.vpc_id}"
auto_accept = "${var.auto_accept}"
accepter {
allow_remote_vpc_dns_resolution = true
}
requester {
allow_remote_vpc_dns_resolution = true
}
tags {
Name = "VPC Peering between ${var.peer_vpc_id} and ${var.vpc_id}"
}
}
這裏在maint.ft
模塊執行module "peering" {
source = "../modules/vpc_peer"
region = "${var.region}"
peer_owner_id = "<management account number>"
peer_vpc_id = "<vpc-********>"
vpc_id = "${module.network.vpc_id}"
auto_accept = "true"
}
現在,我從「沙盒」提供商使用的IAM用戶具有管理帳戶中的VPC中的VPC對等的權限。
我使用AWS以下步驟:http://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_cross-account-with-roles.html
不幸的是我一直用下面的錯誤而失敗:
1 error(s) occurred:
* aws_vpc_peering_connection.peer: Unable to accept VPC Peering Connection: OperationNotPermitted: User 651267440910 cannot accept peering pcx-f9c55290
status code: 400, request id: cfbe1163-241e-413b-a8de-d2bca19726e5
任何想法?
謝謝安東尼,我找到了解決這個問題的方法。 通過運行local_exec和aws cli命令來接受遠程帳戶上的同位體。 –
太棒了!很高興你解決了你的問題。 –