From b44893d9ebe24f4426a48895b02d9e7a80d1b87d Mon Sep 17 00:00:00 2001 From: "daniel.carrillo" Date: Thu, 24 Oct 2019 14:56:20 +0200 Subject: [PATCH] [aws] Add aws_kms_decrypt and aws_ssm_session functions --- modules/aws/init.zsh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/aws/init.zsh b/modules/aws/init.zsh index 6dc2209..c8a0566 100644 --- a/modules/aws/init.zsh +++ b/modules/aws/init.zsh @@ -71,3 +71,24 @@ function aws_ami { aws ec2 describe-images --profile $profile --output ${_aws_output} \ --owner self --query 'Images[*].{id:ImageId,name:Name,virt:VirtualizationType,st:State}' } + +function aws_kms_decrypt { + local profile=$(_get_aws_profile) + + if [[ -z $1 ]]; then + echo "String is missing" + return 1 + fi + aws kms decrypt --ciphertext-blob fileb://<(base64 -d <<<$1) --output text --query Plaintext | base64 -d +} + +function aws_ssm_session { + local profile=$(_get_aws_profile) + + if [[ -z $1 ]]; then + echo "Target is missing" + return 1 + fi + aws ssm start-session --target $1 +} +