Failed to save state: open terraform.tfstate: permission denied

0 votes

I am new to this technology. I have been trying to create AWS EC2 instances using Terraform.

$ terraform apply

I got the following output after executing the above command.

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

Although, the EC2 instance gets created, but the state of my infrastructure is not saved as you can note in the last line in the console output.

Can anyone help me with this?

Thanks

Jul 10, 2018 in DevOps on Cloud by shubham
• 6,870 points
60 views

1 answer to this question.

0 votes
Here is what you can do. Just check the permissions of the directory in which terraform have been placed.

Just do the changes according to your requirements in permission mode of home directory and terraform will work fine.

I hope the above information will be helpful to you.
answered Jul 10, 2018 by shubham
• 6,870 points

Related Questions In DevOps on Cloud

0 votes
1 answer

Unable to save state: open terraform.tfstate: permission denied

Check the access permission of the directory ...READ MORE

answered Jul 13, 2018 in DevOps on Cloud by Atul
• 10,240 points
165 views
0 votes
1 answer

Is it possible to open a bug in VSTS if release deployment fails?

You can do this by adding another ...READ MORE

answered Apr 24, 2018 in DevOps on Cloud by DareDev
• 6,810 points
54 views
0 votes
1 answer
+4 votes
2 answers

unable to get subdomain of URL in NGINX

You just need to add .+ after ...READ MORE

answered Oct 11, 2018 in DevOps on Cloud by lina
• 8,100 points
521 views
+13 votes
2 answers
0 votes
1 answer
+2 votes
3 answers

How do I deploy Scala PlayFramework Project to IBM Bluemix

It seems that they are more than ...READ MORE

answered Oct 18, 2018 in DevOps on Cloud by lina
• 8,100 points
97 views
0 votes
1 answer

How to manage Application version for VM&#39;s in Azure Autoscaling group

First of all, You have to launch ...READ MORE

answered Apr 23, 2018 in DevOps on Cloud by shubham
• 6,870 points
55 views