【问题标题】:Unable to launch aws instance using terraform无法使用 terraform 启动 aws 实例
【发布时间】:2021-03-26 06:01:27
【问题描述】:

在运行 terraform 脚本时,它显示以下错误

Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'oregonkeypair' does not exist
    status code: 400, request id: 921dcb14-796f-4d80-9d41-295dd2fffde7

  on instances.tf line 5, in resource "aws_instance" "rest":
   5: resource "aws_instance" "rest" {



Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'oregonkeypair' does not exist
    status code: 400, request id: f35fc4f3-994c-4e32-9120-03ef02de952f

  on instances.tf line 19, in resource "aws_instance" "connect":
  19: resource "aws_instance" "connect" {



Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'oregonkeypair' does not exist
    status code: 400, request id: 5127a96f-e64b-4a34-bea8-cb848b8b82f8

  on instances.tf line 33, in resource "aws_instance" "ksql":
  33: resource "aws_instance" "ksql" {



Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'oregonkeypair' does not exist
    status code: 400, request id: 72dd21a3-62b6-4e65-bf17-c68dafd885fa

  on instances.tf line 46, in resource "aws_instance" "control_center":
  46: resource "aws_instance" "control_center" {



Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'oregonkeypair' does not exist
    status code: 400, request id: 06d12048-f2ee-44a9-9bc4-0b69619040c6

  on instances.tf line 60, in resource "aws_instance" "schema":
  60: resource "aws_instance" "schema" {

错误:启动源实例时出错:InvalidKeyPair.NotFound:密钥对“oregonkeypair”不存在 状态码:400,请求ID:9c49141d-7b47-490f-96d8-364399567244

But the same key is in the same folder and also provided chmod 400 permission 

【问题讨论】:

    标签: amazon-web-services terraform


    【解决方案1】:

    您是否按照documentation 中的说明将密钥定义为单独的资源。

    key_name - (可选)用于 实例;可以使用 aws_key_pair 资源进行管理。

    据我了解,您需要在模板中定义它,请参阅documentation

    例子:

    resource "aws_key_pair" "deployer" {
       key_name   = "deployer-key"
       public_key = "ssh-rsa AAAAB3NzaC1y...and-so-on...1 email@example.com"
    }
    

    【讨论】:

      【解决方案2】:

      此密钥对 oregonkeypair 应该已经存在于 AWS 中,或者使用 @Ben 提到的 terraform 创建一个

      一种快速的解决方法是在 AWS 控制台中手动创建一个 https://console.aws.amazon.com/ec2/v2/home

      【讨论】:

        猜你喜欢
        • 2021-11-15
        • 2021-12-26
        • 1970-01-01
        • 2023-03-31
        • 2020-04-23
        • 2020-11-22
        • 2020-03-02
        • 2021-06-19
        • 2020-10-09
        相关资源
        最近更新 更多