I've a lambda function which uses container image(Docker) and the main function is written in bash
. I am facing issue in my conditional logic:
if [[ $cur_cert == *"ca-cert"* ]]; then
echo "CA-CERT"
elif [[ $cur_cert == *"ssl-cert"* && $cur_cert == *"public"* ]]; then
echo "SSL-CERT-PUBLIC"
elif [[ $cur_cert == *"ssl-cert"* && $cur_cert == *"private"* ]]; then
echo "SSL-CERT-PRIVATE"
fi
This script is working perfectly fine on my local system. But on lambda it is not executing the code block under if/else even if the conditions are matching.
I'm using ubuntu as the base image for my Docker container. (FROM ubuntu
)
Using a POSIX shell grammar rather than Bash dialect, ensures better compatibility with other shell interpreters:
case $cur_cert in
*ca-cert*) printf %s\\n CA-CERT ;;
*ssl-cert*) case $cur_cert in
*public*) printf %s\\n SSL-CERT-PUBLIC ;;
*private*) printf %s\\n SSL-CERT-PRIVATE ;;
esac ;;
esac