0
votes

I'm considering an opportunity to describe the existing AWS infrastructure in Terraform. I analyzed all that is in use and noticed one important detail — we have an EC2 instance that is connected to a specific VPC via classiclink.

So I'm curious is it possible to describe such a relation between an EC2 and a VPC in Terraform syntax? I've read the Terraform EC2 docs, but haven't found anything about that.

1

1 Answers

3
votes

It's not currently possible.

The aws_vpc resource has support for enabling ClassicLink but there's no way to attach an EC2 instance to a VPC via ClassicLink. There's an existing, stale feature request for it but not much interest in it.

Unfortunately EC2 Classic things are deprecated in favour of VPC based EC2 resources and it's not even possible for a person without an EC2 Classic enabled account to be able to test the functionality either so feature requests like this must be driven entirely by the very few AWS customers still using EC2 Classic but are also using Terraform for automation. If you feel up to the task you could raise a pull request to expose the functionality requested in that issue via the AttachClassicLinkVPC API call.

I'd recommend migrating your remaining EC2 Classic instances to VPC based ones to avoid issues around the use of EC2 Classic.