Skip to content

Commit 78350a8

Browse files
committed
fix typo
1 parent 27be3ff commit 78350a8

4 files changed

Lines changed: 140 additions & 4 deletions

File tree

05-iac/00-terraform/05-incorporando-nuevos-providers/16-demo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "aws_instance" "nginx1" {
4848
subnet_id = aws_subnet.subnet1.id
4949
vpc_security_group_ids = [aws_security_group.nginx-sg.id]
5050
+ iam_instance_profile = aws_iam_instance_profile.nginx_profile.name
51-
+ dependsdepends_on = [
51+
+ depends_on = [
5252
+ aws_iam_role_policy.allow_s3_all
5353
+ ]
5454
+
@@ -70,7 +70,7 @@ resource "aws_instance" "nginx2" {
7070
subnet_id = aws_subnet.subnet2.id
7171
vpc_security_group_ids = [aws_security_group.nginx-sg.id]
7272
+ iam_instance_profile = aws_iam_instance_profile.nginx_profile.name
73-
+ dependsdepends_on = [
73+
+ depends_on = [
7474
+ aws_iam_role_policy.allow_s3_all
7575
+ ]
7676
+

05-iac/00-terraform/05-incorporando-nuevos-providers/17-demo.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,68 @@ terraform plan -out d3.tfplan
1010
terraform apply "d3.tfplan"
1111
```
1212

13-
## Pasos
13+
Nuestro objetivo es actulaizar el script de `user_data`. Lo que queremos ahora, es recuperar los ficheros que están en S3 y definen nuestro site.
14+
15+
Las buenas noticias es que la AWS CLI ya viene instalada an la AMI que hemos seleccionado.
16+
17+
Actualizamos `instances.tf`
18+
19+
```diff
20+
# INSTANCES #
21+
resource "aws_instance" "nginx1" {
22+
ami = nonsensitive(data.aws_ssm_parameter.ami.value)
23+
instance_type = var.aws_instance_type
24+
subnet_id = aws_subnet.subnet1.id
25+
vpc_security_group_ids = [aws_security_group.nginx-sg.id]
26+
iam_instance_profile = aws_iam_instance_profile.nginx_profile.name
27+
depends_on = [
28+
aws_iam_role_policy.allow_s3_all
29+
]
30+
31+
user_data = <<EOF
32+
#! /bin/bash
33+
sudo amazon-linux-extras install -y nginx1
34+
sudo service nginx start
35+
+aws s3 cp s3://${aws_s3_bucket.web_bucket.id}/website/index.html /home/ec2-user/index.html
36+
+aws s3 cp s3://${aws_s3_bucket.web_bucket.id}/website/fruits.png /home/ec2-user/fruits.png
37+
sudo rm /usr/share/nginx/html/index.html
38+
+sudo cp /home/ec2-user/index.html /usr/share/nginx/html/index.html
39+
+sudo cp /home/ec2-user/fruits.png /usr/share/nginx/html/fruits.png
40+
-echo '<html><head><title>Lemon Land Server</title></head><body style=\"background-color:#1F778D\"><p style=\"text-align: center;\"><span style=\"color:#FFFFFF;\"><span style=\"font-size:28px;\">Welcome to &#127819; land</span></span></p></body></html>' | sudo tee /usr/share/nginx/html/index.html
41+
EOF
42+
43+
tags = local.common_tags
44+
45+
}
46+
47+
resource "aws_instance" "nginx2" {
48+
ami = nonsensitive(data.aws_ssm_parameter.ami.value)
49+
instance_type = var.aws_instance_type
50+
subnet_id = aws_subnet.subnet2.id
51+
vpc_security_group_ids = [aws_security_group.nginx-sg.id]
52+
iam_instance_profile = aws_iam_instance_profile.nginx_profile.name
53+
depends_on = [
54+
aws_iam_role_policy.allow_s3_all
55+
]
56+
57+
user_data = <<EOF
58+
#! /bin/bash
59+
sudo amazon-linux-extras install -y nginx1
60+
sudo service nginx start
61+
+aws s3 cp s3://${aws_s3_bucket.web_bucket.id}/website/index.html /home/ec2-user/index.html
62+
+aws s3 cp s3://${aws_s3_bucket.web_bucket.id}/website/fruits.png /home/ec2-user/fruits.png
63+
sudo rm /usr/share/nginx/html/index.html
64+
+sudo cp /home/ec2-user/index.html /usr/share/nginx/html/index.html
65+
+sudo cp /home/ec2-user/fruits.png /usr/share/nginx/html/fruits.png
66+
-echo '<html><head><title>Lemon Land Server</title></head><body style=\"background-color:#1F778D\"><p style=\"text-align: center;\"><span style=\"color:#FFFFFF;\"><span style=\"font-size:28px;\">Welcome to &#127819; land</span></span></p></body></html>' | sudo tee /usr/share/nginx/html/index.html
67+
EOF
68+
69+
tags = local.common_tags
70+
71+
}
72+
73+
```
74+
1475

1576
## Clean Up
1677

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Desplegando la nueva configuración
2+
3+
## Pre requisitos
4+
5+
> Si has destruidfo el entorno recrealo
6+
7+
```bash
8+
cd lab/lc_web_app/
9+
terraform plan -out d3.tfplan
10+
terraform apply "d3.tfplan"
11+
```
12+
13+
## Pasos
14+
15+
### Paso 1.
16+
17+
Nos aseguramos de que nuestros ficheros están debidamente formateados.
18+
19+
```bash
20+
terraform fmt
21+
```
22+
23+
### Paso 2.
24+
25+
Ahora tenemos que ejecutar `terraform init`, cada vez que tenemos un nuevo provider, debemos ejecutar este comando para que Terraform pueda descargar los binarios.
26+
27+
```bash
28+
terraform init
29+
```
30+
31+
We get something similar to this:
32+
33+
```bash
34+
Initializing the backend...
35+
36+
Initializing provider plugins...
37+
- Reusing previous version of hashicorp/aws from the dependency lock file
38+
- Finding hashicorp/random versions matching "~> 3.0"...
39+
- Installing hashicorp/random v3.1.0...
40+
- Installed hashicorp/random v3.1.0 (signed by HashiCorp)
41+
- Using previously-installed hashicorp/aws v3.70.0
42+
43+
Terraform has made some changes to the provider dependency selections recorded
44+
in the .terraform.lock.hcl file. Review those changes and commit them to your
45+
version control system if they represent changes you intended to make.
46+
47+
Terraform has been successfully initialized!
48+
49+
You may now begin working with Terraform. Try running "terraform plan" to see
50+
any changes that are required for your infrastructure. All Terraform commands
51+
should now work.
52+
53+
If you ever set or change modules or backend configuration for Terraform,
54+
rerun this command to reinitialize your working directory. If you forget, other
55+
commands will detect it and remind you to do so if necessary.
56+
```
57+
58+
### Paso 3.
59+
60+
Validamos nuestra configuración
61+
62+
```bash
63+
terraform validate
64+
```
65+
66+
67+
## Clean Up
68+
69+
```bash
70+
terraform destroy
71+
```

05-iac/00-terraform/05-incorporando-nuevos-providers/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,8 @@ Después de que un recurso ha sido creado, a veces necesitamos realizar configur
126126

127127
## Actualizando el Startup Script
128128

129-
[Actualizando el Startup Script - Demo 17](17-demo.md)
129+
[Actualizando el Startup Script - Demo 17](17-demo.md)
130+
131+
## Desplegando la nueva configuración
132+
133+
[Desplegando la nueva configuración - Demo 18](18-demo.md)

0 commit comments

Comments
 (0)