4

Terraform Amazon . , bash, HTML IP .

:

user_data              = <<EOF
#!/bin/bash
apt -y update
apt -y install apache2
myip=`curl http://169.254.169.254/latest/meta-data/local-ipv4`
echo "<h2>WebServer with IP: $myip</h2><br> Build by Terraform!" > /var/www/html                                                                                                                                                             /index.html
sudo service httpd start
chkconfig httpd on
EOF  

, , . , , . Terraform , bash Linux PowerShell Windows. , .

Lesson-3 mkdir Lesson-3.

, WebServer.tr, nano webserver.tr :

nano webserver.tr

. user_data.sh. - nano user_data.sh. . , ! #!/bin/bash , bash. . , , . Terraform , . . - nano webserver.tr. , . :

user_data = file(./dir/myfile.txt) 

, . , Terraform user_data = file(user_data.sh).

, , Terraform, terraform init. Terraform, , . , , Terraform . , , 2 . . terraform apply . , .

.

. , .

Instance State

ip , , . , .

Public IP

, . , http. - http://18.157.187.102/.

Web Server

.

, .

Terraform , .


50% Merion Academy