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

0 votes

I am creating 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

Since, the EC2 instance is getting created but how do I save the state of my infrastructure as is showing permission denied in the last line.

Jul 13, 2018 in DevOps on Cloud by shubham
• 6,480 points
125 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
Check the access permission of the directory in which you have placed your terraform files.

Just give it the appropriate permissions which are required and you are ready to go.

I hope it would resolve your query.
answered Jul 13, 2018 by Atul
• 10,190 points

Related Questions In DevOps on Cloud

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
447 views
+2 votes
2 answers
0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
+3 votes
2 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.