Created
April 3, 2023 04:23
-
-
Save devops-school/b80beae09629dadd6dd993eca9fbde12 to your computer and use it in GitHub Desktop.
Revisions
-
devops-school created this gist
Apr 3, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # Create a security group resource "aws_security_group" "web" { name_prefix = "web-sg" ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } tags = { Name = "Web SG" } } # Create a key pair resource "aws_key_pair" "key" { key_name = "my-key" public_key = file("~/.ssh/id_rsa.pub") } # Launch an EC2 instance resource "aws_instance" "web" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" key_name = aws_key_pair.key.key_name vpc_security_group_ids = [aws_security_group.web.id] tags = { Name = "Web Instance" } }