Created
January 22, 2020 15:06
-
-
Save prashanth-sams/f0c6186aae96d73cf0d492efb5aa1d4a to your computer and use it in GitHub Desktop.
Basic terraform script to create a EC2 instance
This file contains 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
provider "aws" { | |
version = "~> 2.0" | |
region = "us-west-2" | |
shared_credentials_file = "~/.aws/credentials" | |
profile = "prashanth" | |
} | |
data "aws_ami" "amazon-linux-2" { | |
most_recent = true | |
owners = ["amazon"] | |
filter { | |
name = "name" | |
values = ["amzn2-ami-hvm*"] | |
} | |
filter { | |
name = "architecture" | |
values = ["x86_64"] | |
} | |
} | |
resource "aws_instance" "test" { | |
ami = "${data.aws_ami.amazon-linux-2.id}" | |
associate_public_ip_address = true | |
instance_type = "t2.micro" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment