George McKinney Adventures in Software Development

September 4, 2023

Create Lambda Layer on AWS CloudShell

Filed under: AWS,CloudShell — georgemck @ 10:51 pm

This is a mess. I will edit it later


This is the command history to build a Lambda Layer in Python. I had to add a C compiler, Compile Python 3.9 with a specific requests module, and then upload to S3 and Add the Layer to Lambda function before I could use it but after all that, it worked.


[cloudshell-user@ip-10-2-31-49 packaging]$ history 100



1 sudo yum -y update
2 python -V
3 wget
4 tar xvf Python-3.9.16.tgz
5 cd Python-3.9.16/
6 ./configure –enable-optimizations
7 sudo make altinstall
8 ls
9 ./configure –enable-optimizations
10 sudo yum groupinstall “Development Tools”
11 gcc –version
12 ./configure –enable-optimizations
13 sudo make altinstall
14 python -V
15 ls /usr/local/bin/
16 ls /usr/local/bin/python3.9
17 /usr/local/bin/python3.9 -V
18 alias python=’/usr/local/bin/python3.9′
19 python -V
20 gcc –version
21 pwd
22 cd ..
23 cd ~
24 ls
25 mkdir packaging
26 cd packaging/
27 python3.9 -m venv layer_package
28 source layer_package/bin/activate
29 pip install requests
30 pip install –trusted-host –trusted-host –trusted-host requests
31 pip config set global.trusted-host “” – – –
32 pip install requests
33 pip install –trusted-host linkchecker
34 pip -V
35 pip install –trusted-host requests
36 pip install –trusted-host –trusted-host –trusted-host requests
37 yum install openssl-devel
38 sudo yum install openssl-devel
39 cd /usr/src
40 deactivate
41 sudo yum install openssl-devel
42 ls
43 cd ~
44 ls
45 cd Python-3.9.16
46 ls
47 ./configure –enable-optimizations
48 ls /usr/local/bin/
49 ls /usr/local/bin/python3.9
50 rm -r /usr/local/bin/python3.9
51 sudo rm -r /usr/local/bin/python3.9
52 ls /usr/local/bin/python3.9
53 sudo make altinstall
54 python -V
55 cd ~/packaging/
56 python3.9 -m venv layer_package
57 source layer_package/bin/activate
58 pip install requests
59 deactivate
60 ls
61 mkdir python
62 cp -r layer_package/lib/python3.9/site-packages/* python/
63 zip -r python
64 ls
65 aws s3 ls
66 aws s3 mb csa-va-lambda-layers-python-requests
67 aws s3 mb s3://csa-va-lambda-layers-python-requests
68 aws s3 ls
69 ls
70 aws s3 cp s3://csa-va-lambda-layers-python-requests
71 ls
72 ls python/
73 ls python/urllib3
74 sudo rm -r python/urllib3
75 ls python/requests
76 sudo rm -r python/requests
77 pip install requests==2.28.2 -t ./python –no-user
78 pip3 install requests==2.28.2 -t ./python –no-user
79 ls python/
80 zip -r python
81 ls
82 aws s3 cp s3://csa-va-lambda-layers-python-requests

Install gcc on AWS CloudShell

Filed under: AWS,CloudShell — georgemck @ 9:53 pm

Recently, I had the need to compile Python 3.9 on AWS CloudShell which was necessary to create a Lambda Layer for the requests module.

This required add a C compiler to CloudShell. The steps are:

Step 1: Update packages.

  sudo yum update

Step 2: Install GCC

  sudo yum groupinstall “Development Tools”

Step 3: Check version

  gcc –version


[cloudshell-user@ip-10-2-31-49]$ gcc –version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-15)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

August 6, 2023

AWS CloudShell Heroku Install Process

Filed under: AWS — georgemck @ 4:48 pm

Visit the Heroku Developer center at for guidance on their CLI installation.

1. Review the AWS CLI environment

[cloudshell-user@ip-10-4-68-115 ~]$     aws –version

aws-cli/2.13.4 Python/3.11.4 Linux/4.14.255-314-253.539.amzn2.x86_64 exec-env/CloudShell exe/x86_64.amzn.2 prompt/off


2. Download the heroku linux tar ball

[cloudshell-user@ip-10-4-68-115 ~]$     wget

–2023-08-07 05:11:58–
Resolving (…,,, …
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 46927903 (45M) [application/gzip]
Saving to: ‘heroku-linux-x64.tar.gz’

100%[===========>] 46,927,903 233MB/s in 0.2s

2023-08-07 05:11:59 (233 MB/s) – ‘heroku-linux-x64.tar.gz’ saved [46927903/46927903]


3. Extract the contents.

[cloudshell-user@ip-10-4-68-115 ~]$     tar –ungzip -xf heroku-linux-x64.tar.gz


4. Clean up by deleting the tar file.

[cloudshell-user@ip-10-4-68-115 ~]$     rm heroku-linux-x64.tar.gz


6. Configure the PATH variable to include Heroku.

[cloudshell-user@ip-10-4-68-115 ~]$     echo “export PATH=\$PATH:~/heroku/bin” >> ~/.bashrc

[cloudshell-user@ip-10-4-68-115 ~]$     source ~/.bashrc


November 8, 2022

Sending Mail from AWS Lightsail using WP MAIL SMTP by Shared Hosting (Mochahost!)

Filed under: AWS,Lightsail,Mochahost,PHP,WordPress — georgemck @ 9:21 pm

AWS Lightsail enables Amazon Web Services customers to host “simple web applications, use pre-configured development stacks like LAMP, Nginx, MEAN, and Node.js.” This includes WordPress-powered websites. Lightsail creates a Debian-based virtual server to host these applications allowing SSH connections. Unfortunately, unlike traditional shared hosting services,  mail functionality is not included. This prevents WordPress from sending emails normally including for password resets. Fortunately, there is an easy to use plugin (WP MAIL SMTP) that provides a number of options for sending email including  SendLayer,, Sendinblue, Mailgun, SendGrid, Postmark, SparkPost, Gmail, Microsoft, Amazon SES, Zoho, and All Other SMTP providers.

Since web services do not need to be provided by the same server address or even the same company. It is possible to split web application hosting from mail server hosting via customizing the DNS zone settings (That topic is not addressed here). The goal of this post is to point out the settings necessary to enable the Lightsail application to use mail settings from one of the “All Other SMTP” providers, specifically Mochahost.

First off, you must create an email account on Mochahost. By doing so, you will immediately know the username and password. The configuration for setting up a mail client are available. However, instead of using the website’s domain it is necessary to use the mail server domain in this case, The port will be 587. Encryption will be TLS. Finally, authentication with username and password are required.

Here is an example of the WP MAIL SMTP plugin settings:



Now, send a test email:


And check your email:


All these companies provide great servers and, when you need to scale, you will be in good hands.



January 12, 2022

Securing an AWS Account with Multi-Factor Authentication

Filed under: AWS,CIS,CIS 192 — georgemck @ 3:49 pm

July 20, 2021

Upgrading to PHP 7.2 on Amazon Linux

Filed under: AWS,CIS 192,PHP — georgemck @ 10:24 pm

#Upgrading to PHP 7.2 on Amazon Linux

#check current version of PHP
php -v

#stop APACHE and PHP services
sudo service httpd stop

#uninstall APACHE and PHP
sudo yum remove httpd* php*

#Get latest updates
sudo yum update -y

#install PHP 7.2
sudo yum install php72

#install MySQL driver for PHP 7.2
sudo yum install php72-mysqlnd

#Start APACHE web server
sudo service httpd start

sudo yum clean all

June 7, 2021

A delivery loop was detected

Filed under: Uncategorized — georgemck @ 12:10 pm


One day my email stopped working… Turns out the Google Workspaces had been suspended… So, I had to address that post haste!





delivery loop email  undeliverable


Error Icon

Message not delivered

Your message couldn’t be delivered to because the remote server is misconfigured. See technical details below for more information.
The response was:
A delivery loop was detected which causes this email to be undeliverable.







May 18, 2021

WordPress Canonical URL, Permalink Redirect, ERR_TOO_MANY_REDIRECTS

Filed under: Apache,WordPress — georgemck @ 3:22 pm

WordPress uses .htaccess to automatically attempt to correct URLs that are misunderstood. This behavior can lead to errors such as ERR_TOO_MANY_REDIRECTS and prevent intended funcationality such as using an index.html as a landing page for the domain. It is possible to Disable WordPress Canonical URL or Permalink Auto Redirect to fix these problems.


This code snippet can be placed at the top of the theme’s functions.php file:

remove_filter('template_redirect', 'redirect_canonical'); 

April 20, 2021

Alexa Fact Skill Content

Filed under: Alexa,Amazon,AWS — georgemck @ 5:41 pm


const GET_FACT_MESSAGE = ‘Here\’s your information: ‘;
const HELP_MESSAGE = ‘You can say tell me a fact, or, tell me about something… What can I help you with?’;
const HELP_REPROMPT = ‘What can I help you with?’;
const STOP_MESSAGE = ‘Goodbye!’;

const data = [
‘Fact Number One.’,
‘Fact Number Two.’

const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === ‘LaunchRequest’
|| (request.type === ‘IntentRequest’
&& === ‘GetNewFactIntent’);
handle(handlerInput) {
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_FACT_MESSAGE + randomFact;

return handlerInput.responseBuilder
.withSimpleCard(SKILL_NAME, randomFact)

March 10, 2021

AWS CLI Builder

Filed under: AWS — georgemck @ 6:19 pm

Tool for constructing AWS CLI commands

Created by

Older Posts »

Powered by WordPress