Data Source: aws_key_pair

Use this data source to get information about a specific EC2 Key Pair.

Example Usage

The following example shows how to get a EC2 Key Pair including the public key material from its name.

data "aws_key_pair" "example" {
  key_name           = "test"
  include_public_key = true

  filter {
    name   = "tag:Component"
    values = ["web"]
  }
}

output "fingerprint" {
  value = data.aws_key_pair.example.fingerprint
}

output "name" {
  value = data.aws_key_pair.example.key_name
}

output "id" {
  value = data.aws_key_pair.example.id
}

Argument Reference

The arguments of this data source act as filters for querying the available Key Pairs. The given filters must match exactly one Key Pair whose data will be exported as attributes.

filter Configuration Block

The filter configuration block supports the following arguments:

Attribute Reference

This data source exports the following attributes in addition to the arguments above:

Timeouts

Configuration options: