2016-11-10 102 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工作得很好。

相關問題