Skip to content

Commit

Permalink
Merge pull request #30 from arjunrajshekhar/feature/add-aws-vpc-conne…
Browse files Browse the repository at this point in the history
…ction-id

Feature - add aws vpc connection
  • Loading branch information
jordanbraiuka authored Jun 16, 2020
2 parents 99dbd61 + 97ad3a7 commit eec1ab4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BIN_NAME="terraform-provider-instaclustr"
VERSION=v1.1.0
VERSION=v1.2.0

.PHONY: install clean all build test testacc

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ peer_vpc_id|The ID of the VPC with which you are creating the VPC peering connec
peer_account_id|The account ID of the owner of the accepter VPC|Required
peer_subnet|The subnet for the VPC|Required
peer_region| The Region code for the accepter VPC, if the accepter VPC is located in a Region other than the Region in which you make the request. | Not Required
aws_vpc_connection_id| The ID of the VPC peering connection. | Computed


#### Example
Expand Down
14 changes: 14 additions & 0 deletions instaclustr/resource_vpc_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func resourceVpcPeering() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},

"aws_vpc_connection_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -92,6 +97,14 @@ func resourceVpcPeeringCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(id)
d.Set("vpc_peering_id", id)
d.Set("cdc_id", cdcID)

vpcPeering, err := client.ReadVpcPeering(cdcID, id)
if err != nil {
return fmt.Errorf("[Error] Error reading VPC peering connection: %s", err)
}

d.Set("aws_vpc_connection_id", vpcPeering.AWSVpcConnectionID)

log.Printf("[INFO] VPC peering request %s has been created.", id)
return nil
}
Expand All @@ -116,6 +129,7 @@ func resourceVpcPeeringRead(d *schema.ResourceData, meta interface{}) error {
d.Set("cdc_id", vpcPeering.ClusterDataCentre)
d.Set("peer_vpc_id", vpcPeering.PeerVpcID)
d.Set("peer_account_id", vpcPeering.PeerAccountID)
d.Set("aws_vpc_connection_id", vpcPeering.AWSVpcConnectionID)

before, _ := d.GetChange("peer_subnet")
d.Set("peer_subnet", before)
Expand Down

0 comments on commit eec1ab4

Please sign in to comment.