我已经创建了一个VPC窥视之间的2个AWS帐户。帐户A的一个VPC在美国东部-1号,第二个VPC在帐户B在美国-west-2。
,
# VPC peering connection #
# (3) #
##########################
resource "aws_vpc_peering_connection" "this_3" {
count = var.create_peering_3 ? 1 : 0
peer_owner_id = var.peer_account_id_3
peer_vpc_id = var.vpc_peer_id_3
vpc_id = module.vpc-us-west-2.vpc_id
auto_accept = var.auto_accept_peering_3
}这些变量是:
##########################
# VPC peering connection #
# (3) #
##########################
variable "peer_account_id_3" {
description = "AWS owner account ID"
default = "**account*A**"
}
variable "vpc_peer_id_3" {
description = "Peer VPC ID"
default = "vpc-029***"
}
variable "peer_cidr_block_3" {
description = "Peer VPC CIDR block"
default = "192.168.0.0/16"
}
variable "auto_accept_peering_3" {
description = "Auto accept peering connection"
default = true
}
variable "create_peering_3" {
description = "Create peering connection, 0 to not create"
default = true
type = bool
}
variable "this_vpc_id_3" {
description = "This VPC ID"
default = "vpc-0e2**"
}
variable "private_route_table_ids_3" {
type = list(string)
description = "A list of private route tables"
default = ["rtb-0**, rtb-04**"]
}
variable "public_route_table_ids_3" {
type = list(string)
description = "A list of public route tables"
default = ["rtb-0f**"]
}
variable "peering_id_3" {
description = "Provide already existing peering connection id"
default = "pcx-0878***"
}现在,当我运行tf计划时,它正在创建它。我不想让它做,因为它已经做好了!
terraform import aws_vpc_peering_connection.this_3 pcx-0878******但它给了我一个错误:
Error: Cannot import non-existent remote object
While attempting to import an existing object to
aws_vpc_peering_connection.this_3, the provider detected that no object exists
with the given id. Only pre-existing objects can be imported; check that the
id is correct and that it is associated with the provider's configured region
or endpoint, or use "terraform apply" to create a new remote object for this
resource.发布于 2020-12-21 03:39:12
确认您是否使用了来自帐户B的正确凭据。
provider "aws" {
alias = "account_b"
region = "us-west-2"
access_key = "my-access-key"
secret_key = "my-secret-key"
}
resource "aws_vpc_peering_connection" "this_3" {
provider = "aws.account_b"
count = var.create_peering_3 ? 1 : 0
peer_owner_id = var.peer_account_id_3
peer_vpc_id = var.vpc_peer_id_3
vpc_id = module.vpc-us-west-2.vpc_id
auto_accept = var.auto_accept_peering_3
}并尝试再次运行导入。
https://stackoverflow.com/questions/65387073
复制相似问题