File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ resource "aws_instance" "web" {
2
+ ami = var. aws_ami
3
+ instance_type = var. instance_type
4
+ key_name = aws_key_pair. key . key_name
5
+ subnet_id = aws_subnet. my_subnet . id
6
+ // security_groups = aws_security_group.my_security_group.name
7
+ vpc_security_group_ids = [aws_security_group . my_security_group . id ]
8
+ associate_public_ip_address = true
9
+
10
+ tags = {
11
+ Name = " Amaury"
12
+ managed_by = " terraform"
13
+ }
14
+ }
15
+
16
+ resource "aws_security_group" "my_security_group" {
17
+ name = " security_group_terraform"
18
+ vpc_id = aws_vpc. my_vpc . id
19
+
20
+ ingress {
21
+ // description = "SSH from VPC"
22
+ from_port = 22
23
+ to_port = 22
24
+ protocol = " tcp"
25
+ cidr_blocks = [" 0.0.0.0/0" ]
26
+ }
27
+
28
+ egress {
29
+ from_port = 0
30
+ to_port = 0
31
+ protocol = " -1"
32
+ cidr_blocks = [" 0.0.0.0/0" ]
33
+ }
34
+ }
35
+
36
+ resource "aws_key_pair" "key" {
37
+ key_name = " aws-key"
38
+ public_key = file (" ./aws-key.pub" )
39
+
40
+ tags = {
41
+ Name = " my-key-aws"
42
+ managed_by = " terraform"
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments