-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc186ab
commit 5aa5f7e
Showing
10 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/01-provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "aws" { | ||
region = "us-west-2" | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/02-sg.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#Generar security group en VPC por default. | ||
# el valor vpc_id = "vpc-f8ba509c" - Es el ID de la VPC por default. | ||
|
||
resource "aws_security_group" "allow_ssh_anywhere" { | ||
name = "${var.project_name}-allow_ssh_anywhere" | ||
description = "Allow all inbound traffic ssh" | ||
vpc_id = "${var.vpc_id}" | ||
|
||
ingress { | ||
# TLS (change to whatever ports you need) | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = [ "0.0.0.0/0" ] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
|
||
resource "aws_security_group" "allow_http_anywhere" { | ||
name = "${var.project_name}-allow_http_anywhere" | ||
description = "Allow all inbound traffic http" | ||
vpc_id = "${var.vpc_id}" | ||
|
||
ingress { | ||
# TLS (change to whatever ports you need) | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = [ "0.0.0.0/0" ] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/03-eip.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
|
||
resource "aws_eip" "web_eip" { | ||
instance = "${aws_instance.web.id}" | ||
|
||
tags = { | ||
Name = "${var.project_name}-eip" | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/04-instancia.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "aws_instance" "web" { | ||
|
||
ami = "${var.ami_id}" | ||
instance_type = "${var.instance_type}" | ||
key_name = "${var.key_name}" | ||
user_data = "${ file("user-data.txt") }" | ||
|
||
vpc_security_group_ids = [ | ||
"${aws_security_group.allow_ssh_anywhere.id}" , | ||
"${aws_security_group.allow_http_anywhere.id}"] | ||
|
||
tags = { | ||
Name = "${var.project_name}-instance" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
Author: Gilberto Barraza | ||
e-mail: [email protected] | ||
|
||
Descargar plugins y binarios de proveedores. | ||
terraform init | ||
|
||
Verificacion de la infraestructura que se va a generar: | ||
terraform plan | ||
|
||
Generar infraesutrcura: | ||
terraform apply | ||
|
||
|
||
Destruir infraestructura: | ||
terraform destroy | ||
|
||
|
||
|
||
ANEXO: | ||
|
||
Generacion de elementos de manera grafica: | ||
terraform graph | dot -Tpng > graph.png |
Binary file added
BIN
+99.2 KB
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/output.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
output "instance_public_eip"{ | ||
value = "${aws_eip.web_eip.public_ip}" | ||
} | ||
|
||
output "instance_public_ip"{ | ||
value = "${aws_instance.web.public_ip}" | ||
} | ||
|
||
|
||
output "security_group_id"{ | ||
value = "${aws_security_group.allow_ssh_anywhere.id}" | ||
} | ||
|
||
output "security_group_name"{ | ||
value = "${aws_security_group.allow_ssh_anywhere.name}" | ||
} | ||
|
||
output "security_group_description"{ | ||
value = "${aws_security_group.allow_ssh_anywhere.description}" | ||
} | ||
|
||
|
||
output "ACCESO_INSTACIA_SSH"{ | ||
value = "ssh -l ec2-user ${aws_eip.web_eip.public_ip} -i ec2-amazon01.pem" | ||
} | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project_name = "terraform-test01" | ||
vpc_id = "vpc-f8ba509c" | ||
ami_id = "ami-082b5a644766e0e6f" | ||
instance_type = "t2.micro" | ||
key_name = "ec2-amazon01" |
7 changes: 7 additions & 0 deletions
7
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/user-data.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
yum update | ||
yum -y install httpd | ||
|
||
cd /var/www/html/ ; wget https://www.utsem-morelos.edu.mx/ | ||
|
||
sudo service httpd start |
5 changes: 5 additions & 0 deletions
5
presentacion-cloud/generar-ec2-aws-with-terraform_with_index/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "project_name" {} | ||
variable "vpc_id" {} | ||
variable "ami_id" {} | ||
variable "instance_type" {} | ||
variable "key_name" {} |