2016-11-06 3 views
1

アカウント間でVPCピアを作成しようとしていますが、それを自動受け入れますが、権限エラーで失敗します。ここでTerraformでvpcピアリングをauto_acceptしようとすると、パーミッションエラーが発生するのはなぜですか?

はここ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 

任意のアイデア?

答えて

0

Terraformのauto_accept引数は、同じアカウントのVPCでのみ使用できます。 documentationから:

auto_accept - (Optional) Accept the peering (both VPCs need to be in the same AWS account).

...

If both VPCs are not in the same AWS account do not enable the auto_accept attribute. You will still have to accept the VPC Peering Connection request manually using the AWS Management Console, AWS CLI, through SDKs, etc.

だからあなただけのauto_acceptなしテラフォームでこの-側のピアリング接続を作成する必要がありますし、手動またはプログラム的にそれを受け入れますターゲットアカウント。いくつかのプログラムによるオプション:

だけでなく、このためのマッチング方法を持っている必要があり、選択した言語でAWS SDK。

+0

ありがとうございましたAnthony。、私はそれを回避する方法を見つけました。 local_execおよびaws cliコマンドを実行して、リモートアカウントのピアを受け入れます。 –

+0

素晴らしい!うれしいことに、あなたの問題を解決しました。 –

1

ピアを受け入れるlocal_execを実行することができました。ここ

は一例であり:

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}" 

    provisioner "local-exec" { 
    command = "aws ec2 accept-vpc-peering-connection --vpc-peering-connection-id=${aws_vpc_peering_connection.peer.id} --region=${var.region} --profile=${var.profile}" 

    } 

    tags { 
    Name = "VPC Peering between ${var.peer_vpc_id} and ${var.vpc_id}" 
    } 
} 
0

VPCピアリングは、一のVPCからアクセスするために受け入れられるための辺VPCピアリング必要両方で、同じアカウントまたは異なるaccoutと同じ領域で起こります別のvpcに

関連する問題