2016-11-10 76 views
0

我正在尝试使用Terraform创建AWS EC2实例。保存状态失败:打开terraform.tfstate:权限被拒绝

$ terraform apply

我得到执行上述命令后的输出如下。

aws_instance.example: Creating... 
    ami:       "" => "ami-2d39803a" 
    associate_public_ip_address: "" => "<computed>" 
    availability_zone:   "" => "<computed>" 
    ebs_block_device.#:   "" => "<computed>" 
    ephemeral_block_device.#: "" => "<computed>" 
    instance_state:    "" => "<computed>" 
    instance_type:    "" => "t2.micro" 
    key_name:     "" => "<computed>" 
    network_interface_id:  "" => "<computed>" 
    placement_group:    "" => "<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>" 
    vpc_security_group_ids.#: "" => "<computed>" 
aws_instance.example: Still creating... (10s elapsed) 
aws_instance.example: Still creating... (20s elapsed) 
aws_instance.example: Still creating... (30s elapsed) 
aws_instance.example: Creation complete 
Failed to save state: open terraform.tfstate: permission denied 

虽然EC2实例被创建,但我的基础设施的状态不会被保存,你可以在控制台输出的最后一行注意。

回答

1

在拼命寻找解决方案后,我偶然检查了放置我的terraform文件的目录的访问权限。

主目录的权限被设置为只读。我做了适当的修改,现在terraform apply工作得很好。

相关问题