-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuget-to-aws.tf
71 lines (56 loc) · 1.67 KB
/
nuget-to-aws.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
provider "aws" {
access_key = "YOUR_ACCESS_KEY"
secret_key = "YOU_SECRET_KEY"
region = "us-east-1"
}
#EC2 Instance
resource "aws_instance" "nuget_repository" {
ami = "ami-0fc61db8544a617ed"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.allow_http_ssh.name}"]
key_name = aws_key_pair.key_pair_ssh.key_name
user_data = file("./data.txt")
}
#Security Group
resource "aws_default_vpc" "default" {
tags = {
Name = "Default VPC"
}
}
resource "aws_security_group" "allow_http_ssh" {
name = "allow_http_ssh"
vpc_id = aws_default_vpc.default.id
ingress {
description = "http"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "ssh"
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"]
}
}
#SSH key
resource "aws_key_pair" "key_pair_ssh" {
key_name = "key_pair_ssh"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAhBaaEkzlUJ25LNjHxvZdT1wfGMwdLn2KJu+O4bb17YIIlqcImRsapsqW76fKr6pnu2eBmVxGfYDrdWEwEWqWMFQvFfrAfbMKNET8Dht8oJZqCdRm7kO+O3422rNA84/2FYiCEJWgUiUOYEa2D5zCHn9KL61yn3freSlAzE1bcMcm22WH9kMNRTpdCxQhJJF3YdZ9wJCIGsmHVoboDnUj38YGzYeFKmTOT1wRveZBA6WZ8vmHss2Domn/aHln2IpbYllWaoA2MrhVrRcdjznlR3bihRvV6/emVq2KkPQrCXoaMhy7lcGbNh1ismaYrNadZ0czYEx/FuZj4UgwZgD13w== rsa-key-20200401"
}
#Elastic IP address
resource "aws_eip" "nuget_repository" {
instance = aws_instance.nuget_repository.id
vpc = true
}
output "public_ip" {
value = aws_eip.nuget_repository.public_ip
}