No Description

main.tf 516B

12345678910111213141516171819202122232425
  1. resource "aws_instance" "example" {
  2. ami = "ami-95f8d2f3"
  3. instance_type = "t2.micro"
  4. tags {
  5. Name = "terraform-hello-world"
  6. }
  7. }
  8. # Variable declaration example
  9. variable "server_port" {
  10. description = "The port the server will use for HTTP requests"
  11. }
  12. # Setting up security group
  13. resource "aws_security_group" "instance" {
  14. name = "terraform-hello-world-instance"
  15. ingress {
  16. from_port = ${var.server_port}
  17. to_port = ${var.server_port}
  18. protocol = "tcp"
  19. cidr_blocks = ["0.0.0.0/0"]
  20. }
  21. }