We use terraform
, and I'm trying to enable developers to spin up on-demand resources for development.
A use case is: I've opened a new branch, written some code, and I'd like to run things on an EC2 instance + RDS instance pair. Is there a best-practice way of spinning these resources up dynamically using terraform?
My inclination is to create a terraform module that takes in variables, and then enable developers to supply variables via the command line:
terraform apply -var 'ec2_instance_type=m4.xlarge' -var 'rds_instance_type=db.m4.xlarge'
But I'm not sure if this is the correct way of going about this.
Does anyone have experience with this? Questions I have are:
- Is it dangerous to have these temporary resources live in remote terraform state?
- Should terraform be used like this, or should I be writing raw awscli scripts?
- Is there a way to automatically tear-down these resource after a set amount of time?
Thanks so much for your help!