Skip to content

Commit

Permalink
adds copy to clipboard for imported terraform resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Gohlke committed Feb 15, 2024
1 parent dfcacd3 commit cef0bc8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ complete -C "$(command -v terraform)" terraform

alias tf_destroy='terraform destroy'
alias tf_init='terraform init'
alias tf_import='terraform import'
alias tf_output='terraform output'
alias tf_providers='terraform providers'

Expand Down Expand Up @@ -66,6 +65,18 @@ function tf_apply {
terraform fmt
}

function tf_import {
local resource=$1
local aws_address=$2

if terraform import "${resource}" "${aws_address}"; then
gum spin \
--show-output \
--title "Loading imported '${resource}' ..." \
terraform state show "${resource}" | tee >(to_clipboard)
fi
}

function tf_pin_provider_versions {

local versions="versions.tf"
Expand Down
10 changes: 10 additions & 0 deletions tools/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@

__lazy_install pre-commit
__lazy_install shellcheck

function to_clipboard {
if [[ ${platform} == "darwin" ]]; then
echo "ℹ️ copied to clipboard"
pbcopy < /dev/stdin
else
echo "⚠️ no implemented ... copy urself"
cat
fi
}

0 comments on commit cef0bc8

Please sign in to comment.