Difference between revisions of "Key name"

From wikieduonline
Jump to navigation Jump to search
Line 2: Line 2:
 
  key_name
 
  key_name
 
* 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
 +
 +
<pre>
 +
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]"
 +
}
 +
</pre>
  
 
== Related ==
 
== Related ==

Revision as of 19:35, 31 January 2023

key_name
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

See also

Advertising: