From a6a3b264b81c6b57c3af34861c6277dfabbae757 Mon Sep 17 00:00:00 2001 From: Ivan Savciuc Date: Mon, 13 Jan 2020 14:34:18 +0100 Subject: [PATCH] add to VPC peering connection resource state_info property --- aiven/resource_vpc_peering_connection.go | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/aiven/resource_vpc_peering_connection.go b/aiven/resource_vpc_peering_connection.go index 3dbbfa4be..b9f1c7a9b 100644 --- a/aiven/resource_vpc_peering_connection.go +++ b/aiven/resource_vpc_peering_connection.go @@ -45,6 +45,11 @@ var aivenVPCPeeringConnectionSchema = map[string]*schema.Schema{ Description: "State of the peering connection", Type: schema.TypeString, }, + "state_info": { + Computed: true, + Description: "State-specific help or error information", + Type: schema.TypeMap, + }, "peering_connection_id": { Computed: true, Description: "Cloud provider identifier for the peering connection if available", @@ -178,20 +183,37 @@ func copyVPCPeeringConnectionPropertiesFromAPIResponseToTerraform( project string, vpcID string, ) error { - d.Set("vpc_id", buildResourceID(project, vpcID)) - d.Set("peer_cloud_account", peeringConnection.PeerCloudAccount) - d.Set("peer_vpc", peeringConnection.PeerVPC) + if err := d.Set("vpc_id", buildResourceID(project, vpcID)); err != nil { + return err + } + if err := d.Set("peer_cloud_account", peeringConnection.PeerCloudAccount); err != nil { + return err + } + if err := d.Set("peer_vpc", peeringConnection.PeerVPC); err != nil { + return err + } if peeringConnection.PeerRegion != nil { - d.Set("peer_region", peeringConnection.PeerRegion) + if err := d.Set("peer_region", peeringConnection.PeerRegion); err != nil { + return err + } + } + if err := d.Set("state", peeringConnection.State); err != nil { + return err } - d.Set("state", peeringConnection.State) + if peeringConnection.StateInfo != nil { peeringID, ok := (*peeringConnection.StateInfo)["aws_vpc_peering_connection_id"] if ok { - d.Set("peering_connection_id", peeringID) + if err := d.Set("peering_connection_id", peeringID); err != nil { + return err + } } } + if err := d.Set("state_info", peeringConnection.StateInfo); err != nil { + return err + } + return nil }