Skip to content

Commit

Permalink
Changes after additional code review on hashicorp#3255.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Ewbank authored and Kit Ewbank committed Jun 22, 2018
1 parent a119b6d commit 5af4581
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion aws/resource_aws_dx_hosted_public_virtual_interface_accepter.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepterRead(d *schema.ResourceDat
d.SetId("")
return nil
}
vifState := aws.StringValue(vif.VirtualInterfaceState)
if vifState != directconnect.VirtualInterfaceStateAvailable &&
vifState != directconnect.VirtualInterfaceStateDown &&
vifState != directconnect.VirtualInterfaceStateVerifying {
log.Printf("[WARN] Direct Connect virtual interface (%s) is '%s', removing from state", vifState, d.Id())
d.SetId("")
return nil
}

d.Set("virtual_interface_id", vif.VirtualInterfaceId)
if err := getTagsDX(conn, d, d.Get("arn").(string)); err != nil {
Expand All @@ -102,7 +110,8 @@ func resourceAwsDxHostedPublicVirtualInterfaceAccepterUpdate(d *schema.ResourceD
}

func resourceAwsDxHostedPublicVirtualInterfaceAccepterDelete(d *schema.ResourceData, meta interface{}) error {
return dxVirtualInterfaceDelete(d, meta)
log.Printf("[WARN] Will not delete Direct Connect virtual interface. Terraform will remove this resource from the state file, however resources may remain.")
return nil
}

func resourceAwsDxHostedPublicVirtualInterfaceAccepterImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: |-

# aws_dx_hosted_public_virtual_interface

Provides a Direct Connect hosted public virtual interface resource.
Provides a Direct Connect hosted public virtual interface resource. This resource represents the allocator's side of the hosted virtual interface.
A hosted virtual interface is a virtual interface that is owned by another AWS account.

## Example Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ The following arguments are supported:
* `virtual_interface_id` - (Required) The ID of the Direct Connect virtual interface to accept.
* `tags` - (Optional) A mapping of tags to assign to the resource.

### Removing `aws_dx_hosted_public_virtual_interface_accepter` from your configuration

AWS allows a Direct Connect hosted public virtual interface to be deleted from either the allocator's or accepter's side.
However, Terraform only allows the Direct Connect hosted public virtual interface to be deleted from the allocator's side
by removing the corresponding `aws_dx_hosted_public_virtual_interface` resource from your configuration.
Removing a `aws_dx_hosted_public_virtual_interface_accepter` resource from your configuration will remove it
from your statefile and management, **but will not delete the Direct Connect virtual interface.**


## Attributes Reference

The following attributes are exported:
Expand Down

0 comments on commit 5af4581

Please sign in to comment.