Newbie: Installing applications on aws instance using terraform.

3,218 views
Skip to first unread message

Venson Joy

unread,
Aug 31, 2016, 6:32:13 AM8/31/16
to Terraform
Hi Guys,

Ive just started working on terraform so please correct me if i am wrong. I want to know if there is any way to install applications on aws instance using terraform, if its even possible.

Example: i want to host a web application (Node.js) in public instance accessing database (myql) in private instance and would like to know if this could be sone via terraform.

Thanks in advance guys,
Venson

Andrew Langhorn

unread,
Aug 31, 2016, 1:56:58 PM8/31/16
to terrafo...@googlegroups.com
Hi!

In this example, you can sort your VPCs, subnets, DHCP option sets etc., ASGs, routes and all that through Terraform, but Terraform's not used to add configuration to an instance; for that, you'll either be wanting to bake an AMI using, say, Packer first, and passing the AMI ID to Terraform, or having the instance pull a configuration on boot using cloudinit/userdata and run it -- something like Puppet or Chef would work for that.

Andrew

Venson Joy

unread,
Aug 31, 2016, 1:59:16 PM8/31/16
to terrafo...@googlegroups.com

Thank you so much for your prompt response andrew. This information is very useful for me.

Thanks,
Venson


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/eWpO1UviD2g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CAEpa1DL7bb0VU1cs2J8obds8%3DWOKYr0adG34AxL0CO7DALFN1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Langhorn

unread,
Aug 31, 2016, 5:04:53 PM8/31/16
to terrafo...@googlegroups.com
:)

Ionut Cadariu

unread,
Sep 1, 2016, 4:07:08 AM9/1/16
to Terraform
Hi Venson,

I've been using   something like this, and do all the needed configurations:

user_data                   = "${file("${path.module}/instance-provision.sh")}" # in case you are using modules
user_data                   = "${file("instance-provision.sh")}"              # without using modules

Hope it helps. 

Ionut

Lowe Schmidt

unread,
Sep 1, 2016, 11:41:57 PM9/1/16
to terrafo...@googlegroups.com
Hey,

I would advise against it, but you can use the Terraform provisioners to make some things you're asking for. See https://www.terraform.io/docs/provisioners/index.html

--
Lowe Schmidt | +46 723 867 157

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/cf715c7e-276d-45e7-beb0-3e13ca3618c7%40googlegroups.com.

Venson Joy

unread,
Sep 1, 2016, 11:41:57 PM9/1/16
to terrafo...@googlegroups.com

Thanks Inout,

So the user data part must be done in aws instance in advance rite? Or is there a place in terraform where i can write the installation scrip for individual instance?


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/eWpO1UviD2g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/4feb51f0-c141-4121-8b1f-78d3ddf7138f%40googlegroups.com.

ja...@fpcomplete.com

unread,
Sep 2, 2016, 7:43:24 AM9/2/16
to Terraform


I would recommend a) using packer to do pre-launch heavy lifting (install everything you want to use, configure what you can), and b) init provisioning to configure/run services you want running at launch. Launching the instance should be fast and simple. Before launching, the AMI should have all the apps/services you want to use, you should only need to configure/run during that init with Terraform. Regardless of what size operation, I highly recommend CM tooling to assist with a) and b).

Poluvex Tripplex

unread,
Sep 6, 2016, 9:45:36 AM9/6/16
to Terraform
One way of doing it however you end up heavy on AMI management - that is for complex apps you will end up with a lot of AMIs - even more if you need to manage code/config lifecycle and maintain different versions of your stack/configs.

Alternative, just bake a minimum image and use Ansible or Puppet to configure and build your app stack on top,
This way you only need single AMI and gain ability to reconfigure your apps on the fly.
Reply all
Reply to author
Forward
0 new messages