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 12: | Line 12: | ||
filter { | filter { | ||
name = "name" | name = "name" | ||
− | values = ["ubuntu/images/hvm-ssd/ubuntu-[[ | + | values = ["ubuntu/images/hvm-ssd/ubuntu-[[hirsute]]-21.04-amd64-server-*"] |
} | } | ||
Line 26: | Line 26: | ||
ami = data.aws_ami.ubuntu.id | ami = data.aws_ami.ubuntu.id | ||
instance_type = "[[t3.micro]]" | instance_type = "[[t3.micro]]" | ||
− | |||
− | |||
[[key_name]] = "YourKeyName" | [[key_name]] = "YourKeyName" | ||
tags = { | tags = { | ||
Name = "MyInstanceName" | Name = "MyInstanceName" | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
resource "[[aws_key_pair]]" "YourKeyName" { | resource "[[aws_key_pair]]" "YourKeyName" { | ||
− | + | key_name = "YourKeyName" | |
[[public_key]] = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | [[public_key]] = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
} | } | ||
− | |||
− | |||
− | + | == Errors: Key par does not exist == | |
│ Error: Error launching source instance: InvalidKeyPair.NotFound: The [[key pair]] 'YourKeyName' does not exist | │ Error: Error launching source instance: InvalidKeyPair.NotFound: The [[key pair]] 'YourKeyName' does not exist | ||
│ status code: 400, request id: 717f23c7-f87f-4056-a8f4-a82ad2095534 | │ status code: 400, request id: 717f23c7-f87f-4056-a8f4-a82ad2095534 | ||
Line 75: | Line 53: | ||
* <code>[[aws ec2 run-instances]]</code> | * <code>[[aws ec2 run-instances]]</code> | ||
* <code>[[~/.ssh/config]]</code> | * <code>[[~/.ssh/config]]</code> | ||
− | |||
− | |||
== Activities == | == Activities == |
Advertising: