Skip to content

Commit c677cf7

Browse files
authored
Merge pull request #21 from lamhaison/develop
Install application by brew
2 parents 14cda48 + 752c1ed commit c677cf7

File tree

6 files changed

+99
-15
lines changed

6 files changed

+99
-15
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is the project to collect helpful aws cli commandlines with complex options
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.
66
- 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.
77

8-
8+
# Setup manually
99
## Setup dependencies
1010
Notes: This document is for macos environment.
1111

@@ -46,7 +46,9 @@ echo "random_string" > ~/.password_assume_role_encrypted
4646
```
4747

4848

49-
## Settings when open terminal (I am using iterm)
49+
## Setup the aws-cli-utils
50+
51+
### Setup from source code
5052
```
5153
sudo mkdir -p /opt/lamhaison-tools
5254
chown $(whoami) /opt/lamhaison-tools
@@ -73,6 +75,27 @@ echo "source /opt/lamhaison-tools/aws-cli-utils/main.sh" >> ~/.zshrc
7375
7476
```
7577

78+
### Setup from homebrew
79+
#### Install
80+
```
81+
brew tap lamhaison/aws-cli-utils
82+
brew install --verbose --debug aws-cli-utils
83+
```
84+
## Load when start an Iterm terminal
85+
Add these lines to ~/.bashrc or ~/.zshrc or ~/.bash_profile
86+
```
87+
source "$(which aws-cli-utils.sh)" "/opt/homebrew/Cellar/aws-cli-utils/$(brew info aws-cli-utils | head -1 | awk -F "stable " '{print $2}')" "${HOME}" "True"
88+
89+
```
90+
91+
### Re-install the latest version
92+
```
93+
brew uninstall --verbose --debug aws-cli-utils
94+
brew untap lamhaison/aws-cli-utils
95+
brew tap lamhaison/aws-cli-utils
96+
brew install --verbose --debug aws-cli-utils
97+
```
98+
7699
## Setting AWS credentials
77100
### The file ~/.aws/config
78101
```

aws-cli-utils.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Documentation: https://docs.brew.sh/Formula-Cookbook
2+
# https://rubydoc.brew.sh/Formula
3+
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
4+
class V180 < Formula
5+
desc "aws-cli-utils"
6+
homepage "https://github.com/lamhaison/aws-cli-utils"
7+
url "https://github.com/lamhaison/aws-cli-utils/archive/refs/tags/v1.8.0.tar.gz"
8+
sha256 "bef5b298d17dbfad86bdebeb08384dd848dae165beb2f9e0538c1f3508852963"
9+
license "Apache-2.0"
10+
11+
# depends_on "cmake" => :build
12+
13+
depends_on "jq"
14+
depends_on "peco"
15+
16+
def install
17+
# ENV.deparallelize # if your formula fails when building in parallel
18+
# Remove unrecognized options if warned by configure
19+
# https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method
20+
# system "./configure", *std_configure_args, "--disable-silent-rules"
21+
# system "cmake", "-S", ".", "-B", "build", *std_cmake_args
22+
23+
prefix.install "README.md"
24+
prefix.install "LICENSE"
25+
end
26+
27+
test do
28+
# `test do` will create, run in and delete a temporary directory.
29+
#
30+
# This test will fail and we won't accept that! For Homebrew/homebrew-core
31+
# this will need to be a test that verifies the functionality of the
32+
# software. Run the test with `brew test v1.8.0`. Options passed
33+
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
34+
#
35+
# The installed folder is not in the path, so use the entire path to any
36+
# executables being tested: `system "#{bin}/program", "do", "something"`.
37+
system "false"
38+
end
39+
end

common/logging.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22

3-
aws_assume_role_check_log() {
3+
aws_assume_role_get_log() {
44
local log_file_path=${aws_cli_logs}/${ASSUME_ROLE}.log
55
echo "Read the log ${log_file_path}"
66
view +$ -c 'set number' ${log_file_path}
77
}
88

9-
aws_assume_role_check_log_uploaded() {
9+
aws_assume_role_get_log_uploaded() {
1010
local log_file_path=${aws_cli_logs}/${ASSUME_ROLE}-uploaded.log
1111
echo "Read the log ${log_file_path}"
1212
view +$ -c 'set number' ${log_file_path}

main.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# @script main.sh
55
# @description TODO : to load function for aws-cli-utils
66
# $1: Where is looking for sh files and source the list
7-
# $2: Do you want to set the bind key?
7+
# $2: Where do you want to save logs?
8+
# $3: Do you want to set the bind key?
89

910
AWS_CLI_SOURCE_SCRIPTS=$1
1011

@@ -19,14 +20,26 @@ else
1920
export AWS_CLI_SOURCE_SCRIPTS=${AWS_CLI_SOURCE_SCRIPTS}
2021
fi
2122

23+
AWS_CLI_DATA=$2
24+
if [[ -z "${AWS_CLI_DATA}" ]]; then
25+
LOCAL_AWS_CLI_DATA=$(dirname -- "$0")
26+
if [[ "${LOCAL_AWS_CLI_DATA}" = "." ]]; then
27+
DEFAULT_AWS_CLI_DATA='/opt/lamhaison-tools/aws-cli-utils'
28+
fi
29+
30+
export AWS_CLI_DATA="${LOCAL_AWS_CLI_DATA:-${DEFAULT_AWS_CLI_DATA}}"
31+
else
32+
export AWS_CLI_DATA=${AWS_CLI_DATA}
33+
fi
34+
2235
export assume_role_password_encrypted="$(cat ~/.password_assume_role_encrypted)"
2336
export tmp_credentials="/tmp/aws_temporary_credentials"
2437

25-
export aws_cli_results="${AWS_CLI_SOURCE_SCRIPTS}/aws_cli_results"
26-
export aws_cli_logs="${AWS_CLI_SOURCE_SCRIPTS}/aws_cli_results/logs"
27-
export aws_cli_images="${AWS_CLI_SOURCE_SCRIPTS}/aws_cli_results/images"
28-
export aws_cli_input_tmp="${AWS_CLI_SOURCE_SCRIPTS}/aws_cli_results/inputs"
29-
export aws_cli_input_folder="${AWS_CLI_SOURCE_SCRIPTS}/aws_cli_inputs"
38+
export aws_cli_results="${AWS_CLI_DATA}/aws_cli_results"
39+
export aws_cli_logs="${AWS_CLI_DATA}/aws_cli_results/logs"
40+
export aws_cli_images="${AWS_CLI_DATA}/aws_cli_results/images"
41+
export aws_cli_input_tmp="${AWS_CLI_DATA}/aws_cli_results/inputs"
42+
export aws_cli_input_folder="${AWS_CLI_DATA}/aws_cli_inputs"
3043
export aws_cli_list_commands_folder="${aws_cli_input_folder}/aws_services_commands"
3144
export aws_tmp_input="/tmp/aws_tmp_input_23647494949484.txt"
3245
export aws_cli_document_root_url="https://awscli.amazonaws.com/v2/documentation/api/latest/reference"
@@ -58,7 +71,10 @@ alias get-account-alias='aws iam list-account-aliases'
5871
alias get-account-id='echo AccountId $(aws sts get-caller-identity --query "Account" --output text)'
5972

6073
# Import sub-commandlines.
61-
for script in $(find ${AWS_CLI_SOURCE_SCRIPTS} -type f -name '*.sh' | grep -v main.sh | grep -v main.sh | grep -v test.sh | grep -v temp.sh); do
74+
for script in $(
75+
find ${AWS_CLI_SOURCE_SCRIPTS} -type f -name '*.sh' |
76+
grep -v main.sh | grep -v main.sh | grep -v test.sh | grep -v temp.sh | grep -v aws-cli-utils.sh
77+
); do
6278
source $script
6379
done
6480

@@ -71,7 +87,7 @@ if [ "true" = "${aws_cli_load_current_assume_role}" ] && [ -s "${aws_cli_current
7187
aws_assume_role_load_current_assume_role_for_new_tab
7288
fi
7389

74-
LHS_BIND_KEY=${2:-'True'}
90+
LHS_BIND_KEY=${3:-'True'}
7591

7692
if [[ "${LHS_BIND_KEY}" = "True" ]]; then
7793
# Add hot-keys

makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install:
2+
echo "Todo later"
3+
4+

services/logs.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ aws_logs_list() {
77

88
aws_logs_tail() {
99
aws_log_group_name=$1
10+
local aws_logs_sinces=${2:-$aws_log_tail_since}
1011
echo Get log of the group name ${aws_log_group_name:?"aws_log_group_name is unset or empty"}
11-
echo "Running commandline [ aws logs tail --follow $aws_log_group_name --since ${aws_log_tail_since} ]"
12-
aws logs tail --follow $aws_log_group_name --since ${aws_log_tail_since}
12+
local aws_cmd="aws logs tail --follow $aws_log_group_name --since ${aws_logs_sinces}"
13+
lhs_commandline_logging "${aws_cmd}"
14+
eval ${aws_cmd}
1315
}
1416

1517
aws_logs_tail_with_hint() {
1618
echo "Your log group name >"
1719
aws_log_group_name=$(peco_create_menu 'peco_aws_logs_list')
1820

19-
aws_logs_tail $aws_log_group_name
21+
aws_logs_tail $aws_log_group_name $1
2022
}

0 commit comments

Comments
 (0)