gpt4 book ai didi

terraform - 运行 terraform apply 时出现键错误

转载 作者:行者123 更新时间:2023-12-04 11:19:21 24 4
gpt4 key购买 nike

运行 terraform apply 时,出现键错误。我只是在学习地形。我似乎无法在网上找到有关如何解决此问题的解决方案:

   machine:terraform$ terraform apply
aws_instance.nginix: Creating...
ami: "" => "ami-d1180894"
associate_public_ip_address: "" => "<computed>"
availability_zone: "" => "<computed>"
ebs_block_device.#: "" => "<computed>"
ephemeral_block_device.#: "" => "<computed>"
instance_state: "" => "<computed>"
instance_type: "" => "t2.nano"
ipv6_address_count: "" => "<computed>"
ipv6_addresses.#: "" => "<computed>"
key_name: "" => "terraform-keys2"
network_interface.#: "" => "<computed>"
network_interface_id: "" => "<computed>"
placement_group: "" => "<computed>"
primary_network_interface_id: "" => "<computed>"
private_dns: "" => "<computed>"
private_ip: "" => "<computed>"
public_dns: "" => "<computed>"
public_ip: "" => "<computed>"
root_block_device.#: "" => "<computed>"
security_groups.#: "" => "<computed>"
source_dest_check: "" => "true"
subnet_id: "" => "<computed>"
tenancy: "" => "<computed>"
volume_tags.%: "" => "<computed>"
vpc_security_group_ids.#: "" => "<computed>"
Error applying plan:

1 error(s) occurred:

* aws_instance.nginix: 1 error(s) occurred:

* aws_instance.nginix: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'terraform-keys2' does not exist
status code: 400, request id: 993cc401-4c7a-4e4b-9630-71bc4b5729b0

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

我尝试转到 AWS 控制台并创建 key 对,但这似乎没有帮助

最佳答案

在您的机器上,使用以下命令创建 key 对 ssh-keygen -f terraform-keys2
那么你的配置应该有资源 aws_key_pair如下在aws中

resource "aws_key_pair" "terraform-keys2" {
key_name = "terraform-keys2"
public_key = "terraform-keys2.pub"
}

关于terraform - 运行 terraform apply 时出现键错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46099329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com