Skip to content

Commit

Permalink
Merge pull request #131 from aiven/savciuci-vpc-peering-add-state-info
Browse files Browse the repository at this point in the history
add to VPC peering connection resource state_info property

#131
  • Loading branch information
rikonen authored Jan 14, 2020
2 parents 36de8dc + a6a3b26 commit 8d5fbfd
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions aiven/resource_vpc_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 8d5fbfd

Please sign in to comment.