Skip to content

Commit c7ef60e

Browse files
committed
[Refactor] - to refactor function name
1 parent a10efbf commit c7ef60e

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

services/ec2.sh

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,38 @@ aws_ec2_list() {
2525
}
2626

2727
aws_ec2_get() {
28-
instance_id=$1
29-
echo Get the information of the ec2 ${instance_id:?"The instace_id is unset or empty"}
30-
aws_run_commandline "aws ec2 describe-instances --instance-ids $instance_id"
28+
aws_run_commandline "\
29+
aws ec2 describe-instances \
30+
--instance-ids ${1:?"The aws_ec2_instance_id is unset or empty"}
31+
"
3132
}
3233

3334
aws_ec2_reboot() {
34-
instance_id=$1
35-
echo Reboot the ec2 instance ${instance_id:?"The instace_id is unset or empty"}
36-
aws_run_commandline "aws ec2 reboot-instances --instance-ids $instance_id"
35+
aws_run_commandline "\
36+
aws ec2 reboot-instances \
37+
--instance-ids ${1:?"The aws_ec2_instance_id is unset or empty"}
38+
"
3739
}
3840

3941
aws_ec2_stop() {
40-
instance_id=$1
41-
echo Stop the ec2 instance ${instance_id:?"The instace_id is unset or empty"}
42-
aws_run_commandline "aws ec2 stop-instances --instance-ids $instance_id"
42+
aws_run_commandline "\
43+
aws ec2 stop-instances \
44+
--instance-ids ${1:?"The aws_ec2_instance_id is unset or empty"}
45+
"
4346
}
4447

4548
aws_ec2_start() {
46-
instance_id=$1
47-
echo start the ec2 instance ${instance_id:?"The instace_id is unset or empty"}
48-
aws_run_commandline "aws ec2 start-instances --instance-ids $instance_id"
49+
aws_run_commandline "\
50+
aws ec2 start-instances \
51+
--instance-ids ${1:?"The aws_ec2_instance_id is unset or empty"}
52+
"
53+
}
54+
55+
aws_ec2_rm_instruction() {
56+
aws_commandline_logging "\
57+
aws ec2 terminate-instances \
58+
--instance-ids ${1:="\$aws_ec2_instance_ids"}
59+
"
4960
}
5061

5162
# Ec2 image
@@ -65,16 +76,16 @@ aws_ec2_list_aws_default_images() {
6576
"
6677
}
6778
aws_ec2_create_image() {
68-
instance_id=$1
69-
echo To create a image from the ec2 instance ${instance_id:?"The instace_id is unset or empty"}
79+
local aws_ec2_instance_id=$1
80+
echo To create a image from the ec2 instance ${aws_ec2_instance_id:?"The instace_id is unset or empty"}
7081
aws_ec2_instance_name=$(aws ec2 describe-instances \
71-
--instance-ids $instance_id \
82+
--instance-ids $aws_ec2_instance_id \
7283
--query 'Reservations[*].Instances[*].{Tags:Tags[?Key == `Name`] | [0].Value}' \
7384
--output text)
7485

7586
aws ec2 create-image \
7687
--no-reboot \
77-
--instance-id $instance_id \
88+
--instance-id $aws_ec2_instance_id \
7889
--name ${aws_ec2_instance_name}-$(date '+%Y-%m-%d-%H-%M-%S') \
7990
--description ${aws_ec2_instance_name}-$(date '+%Y-%m-%d-%H-%M-%S') \
8091
--query "ImageId" --output text

services/s3.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ aws_s3_create() {
7676

7777
}
7878

79-
aws_s3_rm() {
79+
aws_s3_rm_instruction() {
8080
aws_s3_bucket_name=$1
8181
echo "We didn't run the commandline, we just suggest the commandline"
8282
echo "If you want ot process it please run the commandline \
@@ -91,7 +91,7 @@ aws_s3_rm() {
9191
}
9292

9393
aws_s3_rm_with_hint() {
94-
aws_s3_rm $(peco_create_menu 'peco_aws_s3_list')
94+
aws_s3_rm_instruction $(peco_create_menu 'peco_aws_s3_list')
9595
}
9696

9797
aws_s3_get_bucket_policy() {

0 commit comments

Comments
 (0)