importStack method
Imports deployment state into an existing stack.
Implementation
Future<void> importStack(String stackName, Map<String, dynamic> state) async {
final tempDir = await Directory.systemTemp.createTemp('automation-import-');
final filePath = p.join(tempDir.path, 'stack-state.json');
try {
final encoder = const JsonEncoder.withIndent(' ');
await File(
filePath,
).writeAsString(encoder.convert(state), encoding: utf8);
await runPulumiCommand(<String>[
'stack',
'import',
'--file',
filePath,
'--stack',
stackName,
]);
} finally {
final file = File(filePath);
if (await file.exists()) {
await file.delete();
}
if (await tempDir.exists()) {
await tempDir.delete(recursive: true);
}
}
}