Skip to content

Commit

Permalink
Se agrega proyecto ec2-eip-with-keypair-rsa-public-output
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarsan01 committed Oct 15, 2019
1 parent cc8ecd3 commit f918b97
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/eip.tf
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 = "terraform-test-eip"
}

}

10 changes: 10 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/instancia.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "aws_instance" "web" {

ami = "ami-082b5a644766e0e6f"
instance_type = "t2.micro"
key_name = "${aws_key_pair.keypair.key_name}"

vpc_security_group_ids = [ "${aws_security_group.allow_ssh_anywhere.id}" ]

}

8 changes: 8 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/keypair-public.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Se declara el keypair para la conexión a la instancia.

resource "aws_key_pair" "keypair" {
key_name = "terrafor-test-keypair"

public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDyy3ZmliPL87q47i9/Gjp1QXYt6NaeumfZOG5N0yKm7vmLM1rfR6V5c6vGX16kpf6bk7DgD6BY4yoMitJuMI3caLtG9ETH1RtLxpr9hsq8GtmcVihBVc6mMScC+e0eSC0544ZT/fCnRc9zGoYQV1qyhwoiljStBX4EziAc2k1POHVe7hGQZocCeA8nqdy3QJb6R7qcEMwLgyWvCPJV3pHNHP61OTOu0I6jiHII1buhFNcbzCJzWN5CHknF+QtoDIONmlIFvKQVKDLX5IhUX6Q3F+HnosrLpS6laRaKcMqgkqB3C+jdeJpobkVCwZfrVcXp3lSlhaUK2bLGABardtwv gilbarsan@HP-Pavilion-17-Notebook"
}

26 changes: 26 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


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 "ssh_connection_eip_public"{
value = "ssh -l ec2-user ${aws_eip.web_eip.public_ip}"
}
3 changes: 3 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "us-west-2"
}
24 changes: 24 additions & 0 deletions ec2-eip-with-keypair-rsa-public-output/sg.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#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 = "allow_ssh_anywhere"
description = "Allow all inbound traffic ssh"
vpc_id = "vpc-f8ba509c"

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

0 comments on commit f918b97

Please sign in to comment.