From 22872d19cd20a99c740b03f3eb21db62675ab4bf Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 20 Mar 2023 18:06:47 +0700 Subject: [PATCH 1/4] [Refactor] - to change format and remove echo when eval the input_peco data function. No need echo commandline --- common/peco.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/peco.sh b/common/peco.sh index 6707910..7496def 100644 --- a/common/peco.sh +++ b/common/peco.sh @@ -73,7 +73,8 @@ peco_create_menu() { local input_function=$1 local peco_options=$2 local peco_command="peco ${peco_options}" - local input_value=$(echo "$(eval $input_function)" | eval ${peco_command}) + # local input_value=$(echo "$(eval $input_function)" | eval ${peco_command}) + local input_value=$(eval ${input_function} | eval ${peco_command}) echo ${input_value:?'Can not get the input from peco menu'} } @@ -194,12 +195,12 @@ peco_aws_ec2_list() { } peco_aws_ssm_list_parameters() { - commandline=" \ + commandline=" \ aws ssm get-parameters-by-path \ --path "/" \ --recursive \ --query 'Parameters[*].Name' \ | jq -r '.[]' " - peco_commandline_input ${commandline} 'true' -} \ No newline at end of file + peco_commandline_input ${commandline} 'true' +} From b3e70c55d0ed30c2f1e222a40816eb5f9ff8c857 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 21 Mar 2023 15:00:15 +0700 Subject: [PATCH 2/4] [Docs] - updates to documentation for Readme file --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6e00de9..4c75996 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # aws-cli-utils -This is the project to collect helpful aws cli commandline with complex options to support your working +This is the project to collect helpful aws cli commandlines with complex options to support your working. ## Why I want to write this project. - Sometimes, aws cli is list, get, describes. It is pretty hard to remember. - Sometimes, you want to add more options on purpose and you want to have a place to collect and reuse it in the future. That is the reason I defined that structure to help me collect helpful commandlines and share on the github. +- You have a lot of assume role profile, you can search it by peco and assume it one time by caching feature instead of filling in MFA every time. You can re-use assume-role in the other tab of iterm. ## Setup dependencies @@ -80,9 +81,11 @@ mfa_serial = arn:aws:iam::ACCOUNT_NAME_MFA:mfa/ACCOUNT_NAME ## How to use ### AssumeRole ``` -Ctrl + @ and press enter and choose the assume role that you want to use. +Hotkey: Ctrl + @ and press enter and choose the assume role that you want to use. +Enter functionname: aws_assume_role_set_name_with_hint + ``` -### List all functions +### List all functions (You can search your function) ``` aws_help You can search list function and after that you can run which funtion_name to get the detail of bashshell code. From 45dce233031da05e0b74210096e20498cd82fae0 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 21 Mar 2023 15:07:29 +0700 Subject: [PATCH 3/4] [Add] - add function aws_resource_list to list all resources on aws --- services/other.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/services/other.sh b/services/other.sh index 7643c8f..3cf5bd8 100644 --- a/services/other.sh +++ b/services/other.sh @@ -13,3 +13,22 @@ aws_datapipeline_check_using() { aws_autoscaling_lauching_configuration_list() { aws autoscaling describe-launch-configurations --query "*[].LaunchConfigurationName" } + +aws_resource_list() { + + aws_run_commandline "\ + aws resourcegroupstaggingapi get-resources + " +} + +# +# TODO aws_resource_list_by_tag_name to list all resource that have tag Name is +# @param TODO The first parameter is the tag_name value +# @return List resources that match the tag name which you pass to the function. +# +aws_resource_list_by_tag_name() { + aws_run_commandline "\ + aws resourcegroupstaggingapi get-resources \ + --tag-filters 'Key=Name,Values=${1:?lhs_aws_resource_tag_name is unset or empty}' + " +} From 12782020117441d8d26e33ba6fa5c57d8ef5831c Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 21 Mar 2023 15:13:42 +0700 Subject: [PATCH 4/4] [Docs] - updates to documentation of readme file --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c75996..b30f793 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is the project to collect helpful aws cli commandlines with complex options ## Why I want to write this project. - Sometimes, aws cli is list, get, describes. It is pretty hard to remember. - Sometimes, you want to add more options on purpose and you want to have a place to collect and reuse it in the future. That is the reason I defined that structure to help me collect helpful commandlines and share on the github. -- You have a lot of assume role profile, you can search it by peco and assume it one time by caching feature instead of filling in MFA every time. You can re-use assume-role in the other tab of iterm. +- You have a lot of assume role profile, you can search it by peco and assume it one time by caching feature instead of filling in MFA every time. You can re-use assume-role in the other tab of Iterm. ## Setup dependencies @@ -85,11 +85,12 @@ Hotkey: Ctrl + @ and press enter and choose the assume role that you want to use Enter functionname: aws_assume_role_set_name_with_hint ``` -### List all functions (You can search your function) +### List all functions ``` aws_help -You can search list function and after that you can run which funtion_name to get the detail of bashshell code. ``` +You can search list function and after that you can run which `funtion_name` to get the detail of bashshell code. + ### Other ``` admin@MacBook-Pro-cua-Admin ~ % aws_assume_role_set_name PROFILE_NAME-dev