【发布时间】:2019-08-09 22:02:28
【问题描述】:
刚接触 Terraform,现在正在学习。我使用有效的 terraform 代码创建了一个 aws 实例(我有测试环境)。我使用“terraform destroy”清除了同一个实例,它成功了。现在,当我尝试创建新实例时,“terraform plan”显示要添加 2 个资源而不是 1 个。下面是我的计划输出。
C:\terraform>terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ aws_instance.example
id: <computed>
ami: "ami-051f75c651d856381"
arn: <computed>
associate_public_ip_address: <computed>
availability_zone: <computed>
cpu_core_count: <computed>
cpu_threads_per_core: <computed>
ebs_block_device.#: <computed>
ephemeral_block_device.#: <computed>
get_password_data: "false"
host_id: <computed>
instance_state: <computed>
instance_type: "t2.micro"
ipv6_address_count: <computed>
ipv6_addresses.#: <computed>
key_name: <computed>
network_interface.#: <computed>
network_interface_id: <computed>
password_data: <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>
+ aws_key_pair.deployer
id: <computed>
fingerprint: <computed>
key_name: "key-pair"
public_key: "XXX"
Plan: 2 to add, 0 to change, 0 to destroy.
【问题讨论】:
-
请编辑您的问题并分享您的 Terraform 计划输出。谢谢!
-
嗨,我是 Terraform 的新手,现在正在学习。我使用有效的 terraform 代码创建了一个 aws 实例(我有测试环境)。我使用“terraform destroy”清除了同一个实例,它成功了。现在,当我尝试创建新实例时,“terraform plan”显示要添加 2 个资源而不是 1 个。下面是我的计划输出。
-
计划:2增加,0改变,0破坏。
-
我通过在 aws_instance.tf 文件的末尾添加 key_name="xy-pair" 来修复它,并从 terraform 目录中删除了 aws_key_pair.tf 文件,现在它运行良好。帮助我了解这里的 aws_key_pair 角色。
标签: amazon-web-services terraform terraform-provider-aws