2
votes

I've been playing around with writing a custom resource for AWS which combines other resources in a useful way. (It's too complex to achieve effectively with a Terraform module.)

The documentation (starting with the Plugins page) outlines how to create a completely new resource from scratch. However, is it possible to "attach" my custom resource to the AWS provider? This would allow me to:

  • name my resources e.g. aws_foo instead of awscontrib_foo
  • presumably, access AWS credentials already defined for that provider
2
You could PR it to the AWS provider. - Matt Schuchard
That makes sense :) I'm still interested in whether Terraform has the capability to "augment" an existing provider with new resource types. One, it means my work would not go down the drain if the terraform-provider-aws maintainers declined the PR, and two, it looks like an interesting problem. Plus, the first paragraph of the plugin development page seems to imply that it's possible - Ryan Kennedy
Sure, but imagine the upkeep and maintenance on that code as the provider and Terraform change. If you PR it, then you know it will basically work forever with little to no effort from you. This is more of a solution to your inherited problem and not your specific question I know. - Matt Schuchard
This question should have an answer considering how the terraform plugin doc says that plugins are used if "You want to add a new resource type to an existing provider". But I haven't found how :-/ I guess they mean via forking the existing provider...? - Roly
@RyanKennedy I can suggest to use Pulumi for more advanced "modules". Pulumi uses the Terraform providers underneath. - Dominik

2 Answers

1
votes

You can use the following provider to do exactly the same with Custom Resources in AWS CloudFormation.

https://github.com/mobfox/terraform-provider-multiverse

you can use even AWS Lambda and use any language you like to manage your resources, it also keep state of your resource, so you can delete, read, update them too. It create a resource, so it is not like External Data

0
votes

Yes, the process is outlined here

https://github.com/hashicorp/terraform#developing-terraform

Your customised terraform can be in your own version of the AWS plugin