provider "aws" { region = var.region } resource "aws_key_pair" "default" { key_name = "cedric-key" public_key = file(var.key_path) } resource "aws_instance" "webserver" { ami = var.ami instance_type = "t2.micro" key_name = aws_key_pair.default.id subnet_id = aws_subnet.public-subnet1.id vpc_security_group_ids = [ aws_security_group.sg.id ] associate_public_ip_address = true source_dest_check = false user_data = file(var.userdata_file) tags = { Name = "cedric-webserver" } }