Reputation: 1
Below is the problem I'm trying to solve -
We have a Web application called 'deployment console' which we will use to manage our environments on AWS.
The deployment console will receive requests to create/maintain either staging/prod environments using terraform.
The console can/will receive requests in parallel.
So my question is how can run terraform in parallel to create/maintain environments based on the requests, without screwing up the state files of the respective environments
My terraform folder structure is as follows
Upvotes: 0
Views: 568
Reputation: 56877
If you want to avoid risking state file corruption through parallel runs then you should use state file locking.
Because you seem to be using AWS you should probably be already storing your state in S3 and from there it's just a case of adding a DynamoDB lock table:
terraform {
backend "s3" {
bucket = "mybucket"
key = "path/to/my/key"
region = "us-east-1"
dynamodb_table = "mylocktable
}
}
Upvotes: 1