Skip to content

Commit d53f26d

Browse files
committed
[add] - to add the function to make consistent when making a name for aws resource
1 parent 8a81e31 commit d53f26d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

common/peco.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ peco_assume_role_name() {
55
cat ~/.aws/config | grep -e "^\[profile.*\]$" | peco
66
}
77

8+
peco_format_name_convention_pre_defined() {
9+
peco_input=$1
10+
echo "${peco_input}" | tr "\t" "\n" | tr -s " " "\n" | tr -s '\n'
11+
}
12+
813
peco_format_aws_output_text() {
914
peco_input=$1
1015
echo "${peco_input}" | tr "\t" "\n"
@@ -14,6 +19,12 @@ peco_aws_acm_list() {
1419
aws_acm_list | peco
1520
}
1621

22+
peco_name_convention_input() {
23+
text_input=$1
24+
format_text=$(peco_format_name_convention_pre_defined $text_input)
25+
echo $format_text
26+
}
27+
1728
peco_aws_input() {
1829
aws_cli_commandline="${1} --output text"
1930
result_cached=$2

services/name-convention.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
aws_name_convention_get_prefix_name() {
2+
echo "${ASSUME_ROLE}"
3+
}
4+
5+
aws_name_convention_get_short_env_name() {
6+
echo "dev stg prd"
7+
}
8+
9+
aws_name_convention_get_long_env_name() {
10+
echo "development staging production"
11+
}
12+
13+
aws_name_convention_get_s3_bucket_name() {
14+
aws_s3_bucket_name=$1
15+
echo "The bucket name should will be like that \
16+
[ ${ASSUME_ROLE}-${aws_s3_bucket_name:?"aws_s3_bucket_name is unset or empty"} ]" | tr -s ''
17+
}
18+
19+
aws_name_convention_get_s3_bucket_name_with_hint() {
20+
21+
aws_name_convention_resource_types="static \
22+
vod terraform cf-logs \
23+
alb-logs webapp-react admin-react"
24+
25+
echo "List resource type ${aws_name_convention_resource_types}"
26+
27+
aws_name_convention_get_s3_bucket_name \
28+
$(echo "$(peco_name_convention_input $aws_name_convention_resource_types)" | peco)
29+
30+
}

0 commit comments

Comments
 (0)