Skip to content

Commit

Permalink
Se agrega ejemplo index utsem
Browse files Browse the repository at this point in the history
  • Loading branch information
usergilberto committed Nov 25, 2020
1 parent fc186ab commit 5aa5f7e
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
provider "aws" {
region = "us-west-2"
}

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"]
}
}

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"
}

}
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"
}
}
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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"
}


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"
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
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" {}

0 comments on commit 5aa5f7e

Please sign in to comment.