Last active
May 25, 2021 13:14
-
-
Save EmmanuelOuzan/86517dd3c792bf7ecc366cf132aec9d0 to your computer and use it in GitHub Desktop.
Creation of aws resources with terrafrom !
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 characters
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.27" | |
} | |
} | |
required_version = ">= 0.14.9" | |
} | |
provider "aws" { | |
profile = "default" | |
region = "us-east-1" | |
} | |
resource "aws_security_group" "opens8080" { | |
name = "allow_8080" | |
description = "Allow 8080 access the machine " | |
ingress { | |
from_port = 8080 | |
to_port = 8080 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
ipv6_cidr_blocks = ["::/0"] | |
} | |
tags = { | |
Name = "TerraformRockes" | |
} | |
} | |
resource "aws_instance" "instance" { | |
ami = "ami-09e67e426f25ce0d7" | |
instance_type = "t2.micro" | |
tags = { | |
Name = "Created_By_Terraform!" | |
} | |
} | |
resource "aws_network_interface_sg_attachment" "sg_attachment" { | |
security_group_id = aws_security_group.opens8080.id | |
network_interface_id = aws_instance.instance.primary_network_interface_id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment