Editing Terraform: AWS instance example with aws ami lookup and key name
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | |||
− | + | provider "aws" { | |
− | region = " | + | region = "us-west-2" |
profile = "YourProfile" | profile = "YourProfile" | ||
} | } | ||
− | + | data "aws_ami" "ubuntu" { | |
most_recent = true | most_recent = true | ||
filter { | filter { | ||
name = "name" | name = "name" | ||
− | values = ["ubuntu/images/hvm-ssd/ubuntu- | + | values = ["ubuntu/images/hvm-ssd/ubuntu-hirsute-21.04-amd64-server-*"] |
} | } | ||
Line 23: | Line 22: | ||
} | } | ||
− | + | resource "aws_instance" "myUbuntuMicroInstance" { | |
ami = data.aws_ami.ubuntu.id | ami = data.aws_ami.ubuntu.id | ||
− | instance_type = " | + | instance_type = "t3.micro" |
− | |||
− | |||
[[key_name]] = "YourKeyName" | [[key_name]] = "YourKeyName" | ||
Line 33: | Line 30: | ||
Name = "MyInstanceName" | Name = "MyInstanceName" | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
== Errors == | == Errors == | ||
− | + | * [[Terraform apply]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Related == | == Related == | ||
* <code>[[aws ec2 describe-key-pairs]]</code> | * <code>[[aws ec2 describe-key-pairs]]</code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == | ||
* {{terraform apply}} | * {{terraform apply}} | ||
− | |||
[[Category:Terraform]] | [[Category:Terraform]] |
Advertising: