7

Probably something which i don’t understand for quiet some time.

Executed plan and then apply. Created few resources and failed since the snapshot was not found.

aws_lambda_function.LambdaShipRdsLog: Creation complete
aws_rds_cluster_parameter_group.default: Creation complete
aws_db_parameter_group.default: Creation complete
aws_s3_bucket.RdsLogShipment: Creation complete
Error applying plan:

1 error(s) occurred:

* aws_rds_cluster.default: Error creating RDS Cluster: DBClusterSnapshotNotFoundFault: DBClusterSnapshot not found: xy
    status code: 404, request id: 123

So, i fixed the issue and trigger the plan and apply once again , but end up getting the resource exists error.

3 error(s) occurred:

* aws_db_parameter_group.default: Error creating DB Parameter Group: DBParameterGroupAlreadyExists: Parameter group xyz already exists
    status code: 400, request id: 123
* aws_lambda_function.LambdaShipRdsLog: Error creating Lambda function: ResourceConflictException: Function already exist: xyz
    status code: 409, request id: 123
* aws_rds_cluster_parameter_group.default: Error creating DB Cluster Parameter Group: DBParameterGroupAlreadyExists: Parameter group xyz already exists
    status code: 400, request id: 123

As per my understanding, any resource that are being created will be updated in the state file and the next time when i execute terraform plan for the config, it knows that the resource already exists and it will skip it, but that doesn’t looks like the case. Can someone explain what I am missing? Thanks.

3
  • Can you paste your terraform code and full log? Worst case: run terraform destroy and then terraform plan. Commented Jan 29, 2018 at 20:57
  • well, its very huge config file. Let me know, if you don't understand my question. Thanks. Commented Jan 29, 2018 at 21:58
  • destroy worked fine, and i am going to trigger again. Just want to clear on my understanding. Commented Jan 29, 2018 at 22:08

1 Answer 1

1

Most likely what's happening without seeing the Terraform files and the plan/apply directly is that you have either a manually created resource with the same name or terraform created a resource and it was deleted by hand. When you delete things by hand sometimes it creates dependency problems.

Sign up to request clarification or add additional context in comments.

3 Comments

That makes sense, thank you. BUT HOW DO WE FIX IT??? How do we tell terraform that if something we request it to build already exists, just keep going?
@MartinThurn hopefully you worked this out by now, but for anyone else looking at this question: you need to import existing resources into the Terraform state, as described here: terraform.io/docs/import/index.html
I had this happen to me without any manual intervention. Just tried to apply the plan multiple times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.