Difference between revisions of "Key name"
Jump to navigation
Jump to search
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{lc}} | {{lc}} | ||
− | + | :<code>key_name</code> | |
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#key_name | * https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#key_name | ||
− | + | == Example == | |
resource "aws_instance" "myUbuntuMicroInstance" { | resource "aws_instance" "myUbuntuMicroInstance" { | ||
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" | 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]" | ||
Line 23: | Line 23: | ||
* <code>[[aws_key_pair]]</code> resource | * <code>[[aws_key_pair]]</code> resource | ||
* <code>[[InvalidKeyPair.NotFound]]</code> | * <code>[[InvalidKeyPair.NotFound]]</code> | ||
− | + | * <code>[[Error: Invalid reference]]</code> | |
* <code>[[user_data]]</code> | * <code>[[user_data]]</code> | ||
* [[Terraform: AWS instance example with aws ami lookup and key name]] | * [[Terraform: AWS instance example with aws ami lookup and key name]] | ||
Line 29: | Line 29: | ||
== See also == | == See also == | ||
* {{aws_instance}} | * {{aws_instance}} | ||
− | |||
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 07:12, 15 March 2023
key_name
Example[edit]
resource "aws_instance" "myUbuntuMicroInstance" { ami = data.aws_ami.ubuntu.id instance_type = "t3.micro" key_name = "YourKeyName" tags = { Name = "MyInstanceName" } } resource "aws_key_pair" "YourKeyName" { key_name = "YourKeyName" public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" }
Related[edit]
aws_instance
resourceaws_key_pair
resourceInvalidKeyPair.NotFound
Error: Invalid reference
user_data
- Terraform: AWS instance example with aws ami lookup and key name
See also[edit]
Advertising: