How can i install docker-engine using terraform file because i am creating AWS instances using terraform and i want docker to be installed within those instances So
I’d pick another automation tool – I’m partial to Ansible, Terraform ships with support for Chef – and use that to install software on your system. In principle you can run e.g. apt-get install
from a provisioner block but this gets tricky to debug, and if the list of commands gets long, tricky to manage.
(I’d probably also totally ignore Terraform’s Docker provider: most other tools that support basic Docker container lifecycle management, including Ansible and Docker Compose, are significantly more powerful, and it’s both difficult and dangerous to connect it up to a newly provisioned instance.)
I have followed steps given in your Documentation so that i could install Docker on AWS instance manually . But i want to install Docker on my AWS instance at the same time of instance creation .We actually create AWS instance using Terraform so i have asked is there any way to install Docker using terraform
There is no single built-in Terraform action for “install Docker on this aws_instance resource I just created”.
You could write out the steps you need to do to install Docker in a provisioner block, or use a combination of tools where Terraform is good at getting cloud infrastructure resources and something else like Ansible to manage the software installed on your EC2 instances. (And, again, invoke Ansible in a provisioner block.)