diff --git a/emacs/.emacs.d/config/init-terraform.el b/emacs/.emacs.d/config/init-terraform.el index 2e489f8..cb8f30f 100644 --- a/emacs/.emacs.d/config/init-terraform.el +++ b/emacs/.emacs.d/config/init-terraform.el @@ -61,6 +61,23 @@ (let ((default-directory dir)) (apply oldfn args)))) + (defvar terraform-default-aws-profile "default" + "The default AWS profile to use when running terraform commands.") + + (defun terraform-console (path) + "Run a Terraform console at `path' in a comint buffer." + (interactive (list (read-directory-name "Path: " (find-terraform-root)))) + (let* ((process-environment (cons (format "AWS_PROFILE=%s" terraform-default-aws-profile) + process-environment)) + (default-directory (expand-file-name path)) + (program "terraform") + (switches (list "console")) + (expected-buf-name (apply #'make-comint program program nil switches))) + (comint-run "terraform" (list "console")) + (with-current-buffer expected-buf-name + (setq-local comint-prompt-read-only t + comint-process-echoes t)))) + (advice-add 'terraform--get-resource-provider-namespace :around #'terraform-provider-ns-advice)) (defun terraform-jump-to-plan ()