Skip to content

Commit daa73fe

Browse files
authored
Merge pull request #36 from brikis98/2nd-edition
2nd edition
2 parents 0f67c39 + 740c996 commit daa73fe

File tree

356 files changed

+7942
-1743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+7942
-1743
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This repo contains the code samples for the book *[Terraform: Up and Running](ht
55

66

77

8+
## IMPORTANT NOTE ON 2ND EDITION
9+
10+
The 2nd edition of *Terraform: Up & Running* will be available shortly! If you're reading an early copy of the new edition of the book, please head over to the [2nd-edition branch](https://github.com/brikis98/terraform-up-and-running-code/tree/2nd-edition), which has all the code updated to Terraform 0.12, tons of new code for the new chapters in the book, and so on. It's a work in progress, so think of this branch as a preview of what things will look like when all the updates are finished.
11+
812

913
## IMPORTANT NOTE ON 2ND EDITION
1014

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[webservers]
2+
11.11.11.11
3+
11.11.11.12
4+
11.11.11.13
5+
11.11.11.14
6+
11.11.11.15
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- hosts: webservers
2+
roles:
3+
- webserver
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- ec2:
2+
count: 10
3+
image: ami-0c55b159cbfafe1f0
4+
instance_type: t2.micro
5+
6+
- ec2:
7+
count: 5
8+
image: ami-0c55b159cbfafe1f0
9+
instance_type: t2.micro
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- name: Update the apt-get cache
2+
apt:
3+
update_cache: yes
4+
5+
- name: Install PHP
6+
apt:
7+
name: php
8+
9+
- name: Install Apache
10+
apt:
11+
name: apache2
12+
13+
- name: Copy the code from the repository
14+
git: repo=https://github.com/brikis98/php-app.git dest=/var/www/html/app
15+
16+
- name: Start Apache
17+
service: name=apache2 state=started enabled=yes

code/bash/01-why-terraform/setup-webserver.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ set -e
66
# Update the apt-get cache
77
sudo apt-get update
88

9-
# Install PHP
10-
sudo apt-get install -y php
11-
12-
# Install Apache
13-
sudo apt-get install -y apache2
9+
# Install PHP and Apache
10+
sudo apt-get install -y php apache2
1411

1512
# Copy the code from the repository
1613
sudo git clone https://github.com/brikis98/php-app.git /var/www/html/app

code/bash/03-terraform-state/user-data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ cat > index.html <<EOF
66
<p>DB port: ${db_port}</p>
77
EOF
88

9-
nohup busybox httpd -f -p "${server_port}" &
9+
nohup busybox httpd -f -p ${server_port} &

code/packer/01-why-terraform/webserver.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
"builders": [{
33
"ami_name": "packer-example",
44
"instance_type": "t2.micro",
5-
"region": "us-east-1",
5+
"region": "us-east-2",
66
"type": "amazon-ebs",
7-
"source_ami": "ami-40d28157",
7+
"source_ami": "ami-0c55b159cbfafe1f0",
88
"ssh_username": "ubuntu"
99
}],
1010
"provisioners": [{
1111
"type": "shell",
1212
"inline": [
1313
"sudo apt-get update",
14-
"sudo apt-get install -y php",
15-
"sudo apt-get install -y apache2",
14+
"sudo apt-get install -y php apache2",
1615
"sudo git clone https://github.com/brikis98/php-app.git /var/www/html/app"
16+
],
17+
"environment_vars": [
18+
"DEBIAN_FRONTEND=noninteractive"
1719
]
1820
}]
1921
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def example_function()
2+
puts "Hello, World"
3+
end
4+
5+
# Other places in your code
6+
example_function()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def example_function(param1, param2)
2+
return "Hello, #{param1} #{param2}"
3+
end
4+
5+
# Other places in your code
6+
return_value = example_function("foo", "bar")

0 commit comments

Comments
 (0)