github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/resource_aws_vpc_peering_connection_accepter.go (about) 1 package aws 2 3 import ( 4 "errors" 5 "log" 6 7 "fmt" 8 9 "github.com/hashicorp/terraform/helper/schema" 10 ) 11 12 func resourceAwsVpcPeeringConnectionAccepter() *schema.Resource { 13 return &schema.Resource{ 14 Create: resourceAwsVPCPeeringAccepterCreate, 15 Read: resourceAwsVPCPeeringRead, 16 Update: resourceAwsVPCPeeringUpdate, 17 Delete: resourceAwsVPCPeeringAccepterDelete, 18 19 Schema: map[string]*schema.Schema{ 20 "vpc_peering_connection_id": &schema.Schema{ 21 Type: schema.TypeString, 22 Required: true, 23 ForceNew: true, 24 Computed: false, 25 }, 26 "auto_accept": { 27 Type: schema.TypeBool, 28 Optional: true, 29 }, 30 "accept_status": { 31 Type: schema.TypeString, 32 Computed: true, 33 }, 34 "vpc_id": { 35 Type: schema.TypeString, 36 Computed: true, 37 }, 38 "peer_vpc_id": { 39 Type: schema.TypeString, 40 Computed: true, 41 }, 42 "peer_owner_id": { 43 Type: schema.TypeString, 44 Computed: true, 45 }, 46 "accepter": vpcPeeringConnectionOptionsSchema(), 47 "requester": vpcPeeringConnectionOptionsSchema(), 48 "tags": tagsSchema(), 49 }, 50 } 51 } 52 53 func resourceAwsVPCPeeringAccepterCreate(d *schema.ResourceData, meta interface{}) error { 54 id := d.Get("vpc_peering_connection_id").(string) 55 d.SetId(id) 56 57 if err := resourceAwsVPCPeeringRead(d, meta); err != nil { 58 return err 59 } 60 if d.Id() == "" { 61 return fmt.Errorf("VPC Peering Connection %q not found", id) 62 } 63 64 // Ensure that this IS as cross-account VPC peering connection. 65 if d.Get("peer_owner_id").(string) == meta.(*AWSClient).accountid { 66 return errors.New("aws_vpc_peering_connection_accepter can only adopt into management cross-account VPC peering connections") 67 } 68 69 return resourceAwsVPCPeeringUpdate(d, meta) 70 } 71 72 func resourceAwsVPCPeeringAccepterDelete(d *schema.ResourceData, meta interface{}) error { 73 log.Printf("[WARN] Will not delete VPC peering connection. Terraform will remove this resource from the state file, however resources may remain.") 74 d.SetId("") 75 return nil 76 }