Creating AWS Resources Not Supported By Terraform

This question originally came in via the support at gruntwork dot io email alias:

We would like to use AWS Direct Connect Private Interfaces and they aren’t yet supported by Terraform. Do you have any best practices around integrating them with Terraform code?

I think the best solution for this scenario would to be to implement a series of scripts and Terraform resources to simulate a native Terraform resource:

  • check-if-xxx-exists.sh
  • create-xxx.sh
  • destroy-xxx.sh

Then in Terraform:

  • Create an external data source that calls check-if-xxx-exists.sh
  • Add a null resource that configures the external data source as a trigger and uses a local provisioner to call create-xxx.sh as necessary.
  • Add a when = "destroy" provisioner that calls destroy-xxx.sh