Skip to content

Commit 06ae0d1

Browse files
authored
Merge pull request #10 from lamhaison/develop
[Refactor] - to change format and remove echo when eval the input_peco data function. No need echo commandline [Docs] - updates to documentation for Readme file [Add] - add function aws_resource_list to list all resources on aws [Docs] - updates to documentation of readme file
2 parents 87f0f6c + 1278202 commit 06ae0d1

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# aws-cli-utils
2-
This is the project to collect helpful aws cli commandline with complex options to support your working
2+
This is the project to collect helpful aws cli commandlines with complex options to support your working.
33
## Why I want to write this project.
44
- Sometimes, aws cli is list, get, describes. It is pretty hard to remember.
55
- 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.
6+
- 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.
67

78

89
## Setup dependencies
@@ -80,13 +81,16 @@ mfa_serial = arn:aws:iam::ACCOUNT_NAME_MFA:mfa/ACCOUNT_NAME
8081
## How to use
8182
### AssumeRole
8283
```
83-
Ctrl + @ and press enter and choose the assume role that you want to use.
84+
Hotkey: Ctrl + @ and press enter and choose the assume role that you want to use.
85+
Enter functionname: aws_assume_role_set_name_with_hint
86+
8487
```
8588
### List all functions
8689
```
8790
aws_help
88-
You can search list function and after that you can run which funtion_name to get the detail of bashshell code.
8991
```
92+
You can search list function and after that you can run which `funtion_name` to get the detail of bashshell code.
93+
9094
### Other
9195
```
9296
admin@MacBook-Pro-cua-Admin ~ % aws_assume_role_set_name PROFILE_NAME-dev

common/peco.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ peco_create_menu() {
7373
local input_function=$1
7474
local peco_options=$2
7575
local peco_command="peco ${peco_options}"
76-
local input_value=$(echo "$(eval $input_function)" | eval ${peco_command})
76+
# local input_value=$(echo "$(eval $input_function)" | eval ${peco_command})
77+
local input_value=$(eval ${input_function} | eval ${peco_command})
7778
echo ${input_value:?'Can not get the input from peco menu'}
7879
}
7980

@@ -194,12 +195,12 @@ peco_aws_ec2_list() {
194195
}
195196

196197
peco_aws_ssm_list_parameters() {
197-
commandline=" \
198+
commandline=" \
198199
aws ssm get-parameters-by-path \
199200
--path "/" \
200201
--recursive \
201202
--query 'Parameters[*].Name' \
202203
| jq -r '.[]'
203204
"
204-
peco_commandline_input ${commandline} 'true'
205-
}
205+
peco_commandline_input ${commandline} 'true'
206+
}

services/other.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,22 @@ aws_datapipeline_check_using() {
1313
aws_autoscaling_lauching_configuration_list() {
1414
aws autoscaling describe-launch-configurations --query "*[].LaunchConfigurationName"
1515
}
16+
17+
aws_resource_list() {
18+
19+
aws_run_commandline "\
20+
aws resourcegroupstaggingapi get-resources
21+
"
22+
}
23+
24+
#
25+
# TODO aws_resource_list_by_tag_name to list all resource that have tag Name is
26+
# @param TODO The first parameter is the tag_name value
27+
# @return List resources that match the tag name which you pass to the function.
28+
#
29+
aws_resource_list_by_tag_name() {
30+
aws_run_commandline "\
31+
aws resourcegroupstaggingapi get-resources \
32+
--tag-filters 'Key=Name,Values=${1:?lhs_aws_resource_tag_name is unset or empty}'
33+
"
34+
}

0 commit comments

Comments
 (0)