diff --git a/README.md b/README.md index 6e00de9..b30f793 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,13 +81,16 @@ 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 ``` 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 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' +} 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}' + " +}