tflock
tflock copied to clipboard
print lock id
not really a go programmer, what do you think about this idea? please ignore the .nix it's just how i'm testing it
Hi, @illegalprime. Thank you for your proposal, but I hesitant to merge this because the implementation accesses a private field by using reflection. It's fragile and hard to maintain the feature. However it seems that there is no way to do this with public methods.
As a workaround, you can parse an error message of terraform plan. Of course it's also fragile. 😇
$ tflock
$ LOCK_ID=$(terraform plan -input=false -no-color 2>&1 | gsed -rn 's/^\s*ID\:\s+(\w+)\s*/\1/p')
$ echo $LOCK_ID
c496859b-21db-dffb-f489-cb452586935f
$ terraform force-unlock -force $LOCK_ID