Sunday, August 30, 2020

Terraform create dev instance and deploy mariadb+springboot+vusjs+apache.

 This short blog post shows how to use terraform to provision first dev springboot+mariadb+vuejs+apache on aws linux instance(ec2).

This cloud be useful if you provision ec2 instance oftentimes.(sometimes for aws different regions-just change region)

The application I will deploy is just basic crud from frontend(vuejs)+apache2->backend springboot-> mariadb on just one amazon ec2 instance.(t2.micro)

Based on "", I added bootstrap into main.js and java spring boot linux service library into pom.xml.

To deploy, I used a few shell scripts. 

1. Install terraform. I used latest version as of today.(LINUX DISTRO ISUBUNTU18.04+XUBUNTU)

 *)terraform install page:

oyj@controller:~/prac/terra-aws-dp/aws-terra-dev-dp$ terraform --version

Your version of Terraform is out of date! The latest version
is 0.13.1. You can update by downloading from
Terraform v0.13.0
+ provider v2.70.0
+ provider v1.2.0

2. Install node-

#The fronted will need node(npm etc)

oyj@controller:~/tst/aws-terra-dev-dp$ which node
oyj@controller:~/tst/aws-terra-dev-dp$ node --version
oyj@controller:~/tst/aws-terra-dev-dp$ npm --version

3.Clone my github and do terraform init.(Of course after aws ec2 cli setting completed-

oyj@controller:~/tst$ git clone
Cloning into 'aws-terra-dev-dp'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 49 (delta 3), reused 9 (delta 2), pack-reused 37
Unpacking objects: 100% (49/49), done.
oyj@controller:~/tst$ ls
oyj@controller:~/tst$ cd aws-terra-dev-dp/

oyj@controller:~/tst/aws-terra-dev-dp$ terraform init

Initializing the backend...

oyj@controller:~/tst/aws-terra-dev-dp$ bash
data.http.myip: Refreshing state...
aws_key_pair.dev_pub: Creating... Creating...
aws_key_pair.dev_pub: Creation complete after 0s [id=dev_pub] Creation complete after 1s [id=vpc-083def0ce4c22a2e8] Creating... Creating...

Apply complete! Resources: 10 added, 0 changed, 0 destroyed.


instance_ip_addr =

4. Connect (oupputted by run terraform apply) with browser.

5. Let's destry after testing.

oyj@controller:~/tst/aws-terra-dev-dp$ bash
 Destroy complete! Resources: 10 destroyed.



Well, this automation is somewhat useful for studying and practicing.
I think, after provisioning this instance, each instance should be managed by  
configuration manager such "ansible,chef,puppet and etc".