Last active
September 13, 2022 20:48
-
-
Save rickardp/af27a8f25fe7b8d80fda4d46cc55fab9 to your computer and use it in GitHub Desktop.
when your tf state is f*cked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
s=sys.stdin.read() | |
m = re.compile(r"Error: A resource with the ID \"([^\"]+)\"") | |
n = re.compile(r" with (.+)$") | |
x = False | |
val = None | |
for l in s.split("\n"): | |
f = m.match(l) | |
if f: | |
val = f.groups()[0].strip() | |
g = n.match(l) | |
if g and val is not None: | |
print(("terraform import '%s' '%s'" %(g.groups()[0].strip().strip(',').strip(), val)).replace('/providers/microsoft.insights/diagnosticSettings/','|')) | |
val = None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment