Skip to content

Commit

Permalink
Merge pull request #59 from aws-samples/moodle4.4
Browse files Browse the repository at this point in the history
Update to Moodle 4.4
  • Loading branch information
vrioux authored Apr 23, 2024
2 parents f5cdd70 + 528d80b commit a2aee47
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 49 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Hosting Moodle™ on AWS

### Version 2.0.1
### Version 2.0.2

## Overview

This repository provides set of CloudFormation nested templates that deploy a highly available, elastic, and scalable [Moodle™ 4.3+](https://docs.moodle.org) environment on AWS. Moodle™ offers a learning platform that provides educators, administrators and learners a single robust, secure and integrated system for personalized learning environment.
This repository provides set of CloudFormation nested templates that deploy a highly available, elastic, and scalable [Moodle™ 4.4](https://docs.moodle.org) environment on AWS. Moodle™ offers a learning platform that provides educators, administrators and learners a single robust, secure and integrated system for personalized learning environment.

These nested templates can be used to deploy Moodle™ on AWS using [Amazon Virtual Private Cloud (Amazon VPC)](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html), [Amazon Elastic Compute Cloud (Amazon EC2)](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html), [Auto Scaling](http://docs.aws.amazon.com/autoscaling/latest/userguide/WhatIsAutoScaling.html), [Elastic Load Balancing (Application Load Balancer)](http://docs.aws.amazon.com/elasticbalancing/latest/application/introduction.html), [Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html), [Amazon ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/WhatIs.html), [Amazon Elastic File System (Amazon EFS)](http://docs.aws.amazon.com/efs/latest/ug/whatisefs.html), [Amazon CloudFront](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html), [Amazon Route 53](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html), [Amazon Certificate Manager (Amazon ACM)](http://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) with [AWS CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) in yaml format.
These nested templates can be used to deploy Moodle™ on AWS using [Amazon Virtual Private Cloud (Amazon VPC)](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html), [Amazon Elastic Compute Cloud (Amazon EC2)](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html), [Auto Scaling](http://docs.aws.amazon.com/autoscaling/latest/userguide/WhatIsAutoScaling.html), [Elastic Load Balancing (Application Load Balancer)](http://docs.aws.amazon.com/elasticbalancing/latest/application/introduction.html), [Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html), [Amazon ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/WhatIs.html), [Amazon Elastic File System (Amazon EFS)](http://docs.aws.amazon.com/efs/latest/ug/whatisefs.html), [Amazon CloudFront](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html), [Amazon Route 53](http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html), [Amazon Certificate Manager (Amazon ACM)](http://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) with [AWS CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) in YAML format.

This architecture is expansive enough to meet the needs of large institutions / organizations. Smaller organizations can choose to run a subset of the template to meet their needs. These templates can also be run individually and may be modified.

This template currently uses [Moodle™ 4.3+](https://download.moodle.org/download.php/stable403/moodle-latest-403.tgz) stable version downloaded directly from [download.moodle.org](https://download.moodle.org/releases/latest/). Details for downloading are available in the [templates/03-pipelinehelper.yaml](templates/03-pipelinehelper.yaml) template file.
This template currently uses [Moodle™ 4.4](https://download.moodle.org/download.php/stable404/moodle-4.4.tgz) stable version downloaded directly from [download.moodle.org](https://download.moodle.org/releases/latest/). Details for downloading are available in the [templates/03-pipelinehelper.yaml](templates/03-pipelinehelper.yaml) template file.

## Deployment guide

Expand Down Expand Up @@ -55,7 +55,7 @@ You can launch this CloudFormation template in different AWS Regions. Below are
| ap-southeast-1 |AP (Singapore)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) |
| ap-southeast-2 |AP (Sydney)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) |
| ap-south-1 |India (Mumbai)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) |
| ca-central-1 |Canada (Central))| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ca-central-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) |
| ca-central-1 |Canada (Central)| [![cloudformation-launch-stack](images/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=ca-central-1#/stacks/new?stackName=Moodle&templateURL=https://s3.amazonaws.com/aws-refarch/moodle/al2023/templates/00-main.yaml) |

## Architecture

Expand Down Expand Up @@ -94,7 +94,7 @@ With [elastic](https://docs.aws.amazon.com/efs/latest/ug/performance.html#elasti
*Moodle™ recommends the `dirroot` be set as read only for the apache process in a clustered environment [[Reference]](https://docs.moodle.org/400/en/Server_cluster#.24CFG-.3Edirroot). You should not install plugins to a server cluster from the admin page. `Moodle™ recommends manually installing plugins on each server during planned maintenance`. To follow the infrastructure-as-code methodology, installation/upgrade of plugins can be managed using AWS CodePipeline scripts. See the `.pipeline` folder inside your AWS CodeCommit Moodle™ repository.

### AWS CodePipeline
This CloudFormation templates use AWS Services to create a CI/CD pipeline to help manage your Moodle™ environment. AWS CodeCommit will host a git repository for your Moodle™ environment. It initially pulls the source from [download.moodle.org.](https://download.moodle.org/download.php/stable403/moodle-4.0.3.tgz). It also adds files required to automate the deployment pipeline. You can explore these files under the `.pipeline` folder.
This CloudFormation templates use AWS Services to create a CI/CD pipeline to help manage your Moodle™ environment. AWS CodeCommit will host a git repository for your Moodle™ environment. It initially pulls the source from [download.moodle.org.](https://download.moodle.org/download.php/stable404/moodle-4.4.tgz). It also adds files required to automate the deployment pipeline. You can explore these files under the `.pipeline` folder.
This template also creates an AWS CodePipeline configuration that build artifacts to deploy on EC2 with autoscaling groups using AWS CodeBuild and AWS CodeDeploy. It can optionally support a BLUE_GREEN deployment.

*You can customize the overall pipeline for your Moodle™ setup.*
Expand Down
6 changes: 6 additions & 0 deletions templates/00-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ Parameters:
Description: Email address for notification
Type: String
Default: [email protected]
MoodleDirectDownloadURL:
Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz"
Description: Specifies the TGZ Moodle direct download URL
Type: String

Conditions:
DeployWithoutSessionCache:
Expand Down Expand Up @@ -947,6 +951,8 @@ Resources:
!Ref WebAsgMax
WebAsgMin:
!Ref WebAsgMin
MoodleDirectDownloadURL:
!Ref MoodleDirectDownloadURL
TemplateURL: !Sub '${DeploymentLocation}/03-pipelinehelper.yaml'

sessioncache:
Expand Down
6 changes: 5 additions & 1 deletion templates/03-pipelinehelper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ Parameters:
Default: 2
Description: Specifies the minimum number of EC2 instances in the Web Autoscaling Group.
Type: String
MoodleDirectDownloadURL:
Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz"
Description: Specifies the TGZ Moodle direct download URL
Type: String

Conditions:
NumberOfSubnets1:
Expand Down Expand Up @@ -533,7 +537,7 @@ Resources:
mkdir /tmp/moodle/.pipeline
# Get Latest Moodle stable version
wget -O /tmp/moodle.tgz https://download.moodle.org/download.php/direct/stable403/moodle-latest-403.tgz
wget -O /tmp/moodle.tgz ${MoodleDirectDownloadURL}
tar -xvzf /tmp/moodle.tgz --strip-components=1 -C /tmp/moodle/
wget -O /tmp/moodle/lib/aws.phar https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.phar
cd /tmp/moodle
Expand Down
86 changes: 44 additions & 42 deletions templates/04-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,43 @@ Resources:
AWS::CloudFormation::Init:
configSets:
deploy_webserver:
- install_logs
- install_packages
- install_cloudwatchlogs
- install_codedeploy
- install_webserver
- start_webserver
- start_services
- add_crontab
install_logs:
install_packages:
packages:
yum:
amazon-cloudwatch-agent: []
ruby3.2: []
httpd: []
php8.1: []
php8.1-gd: []
php8.1-soap: []
php8.1-intl: []
php8.1-mbstring: []
php8.1-xml: []
php8.1-opcache: []
php8.1-fpm: []
php8.1-pgsql: []
php8.1-mysqlnd: []
cronie: []
php8.1-devel: []
php-pear: []
libzip: []
libzip-devel: []
libsodium-devel: []
libzstd-devel: []
redis6-devel: []
lz4-devel: []
libmemcached-awesome-tools: []
libmemcached-awesome-devel: []
zlib-devel: []
cyrus-sasl-devel: []
libevent-devel: []
install_cloudwatchlogs:
files:
/etc/awslogs/awslogs.conf:
content: !Sub |
Expand Down Expand Up @@ -393,35 +424,17 @@ Resources:
owner: root
group: root
commands:
01_create_state_directory:
create_state_directory:
command: mkdir -p /var/awslogs/state
02_install_cloudwatch_agent:
command: dnf install -y amazon-cloudwatch-agent
install_aws_ini:
commands:
install_aws_ini:
command: ./download_aws_ini.sh
cwd: /tmp
ignoreErrors: true
install_codedeploy:
files:
/tmp/install_codedeploy.sh:
content:
!Sub |
#!/bin/bash -xe
dnf install -y ruby
cd /home/ec2-user
wget https://aws-codedeploy-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/latest/install
chmod +x ./install
./install auto
mode: 000500
owner: root
group: root
/home/ec2-user/install:
source: !Join ["", ["https://aws-codedeploy-", !Ref "AWS::Region", ".s3.", !Ref "AWS::Region", ".amazonaws.com/latest/install" ] ]
mode: "000755"
commands:
install_codedeploy:
command: ./install_codedeploy.sh
cwd: /tmp
ignoreErrors: false
command: "./install auto"
cwd: "/home/ec2-user/"
install_webserver:
files:
/tmp/status.txt:
Expand All @@ -433,20 +446,12 @@ Resources:
/tmp/create_site_conf.sh:
content: !Sub |
#!/bin/bash -xe
dnf install -y php8.1 php-gd php-soap php-intl php-mbstring php-xml php-opcache php-fpm php-pgsql php-mysqlnd
# Enable crontab on Amazon Linux 2023
dnf install -y cronie
systemctl enable crond
systemctl start crond
# Below to be able to compile zip.so for the PHP Zip library that's not in the available packages...
dnf install -y php8.1-devel php-pear libzip libzip-devel
pecl install zip
echo "extension=zip.so;" > /etc/php.d/50-zip.ini
# Install Sodium
dnf install -y libsodium-devel
pecl install -f libsodium
echo "extension=sodium.so;" > /etc/php.d/50-sodium.ini
Expand All @@ -457,12 +462,10 @@ Resources:
echo 'extension=igbinary.so' > /etc/php.d/30-igbinary.ini
/usr/bin/yes 'no' | pecl install msgpack
echo 'extension=msgpack.so' > /etc/php.d/30-msgpack.ini
dnf install -q -y libzstd-devel
/usr/bin/yes 'no' | pecl install zstd
echo 'extension=zstd.so' > /etc/php.d/40-zstd.ini
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-lzf-better-compression="no"' lzf
echo 'extension=lzf.so' > /etc/php.d/40-lzf.ini
dnf install -q -y redis6-devel lz4-devel
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-lzf="yes" enable-redis-zstd="yes" enable-redis-msgpack="yes" enable-redis-lz4="yes" with-liblz4="yes"' redis
echo 'extension=redis.so' > /etc/php.d/41-redis.ini
Expand Down Expand Up @@ -509,8 +512,6 @@ Resources:
#mv amazon-elasticache-cluster-client.so /usr/lib64/php/modules/
#echo 'extension=amazon-elasticache-cluster-client.so;' > /etc/php.d/50-elasticache.ini
# Install Memcached client - note that ElastiCache client is failing on AL2023
dnf install libmemcached libmemcached-devel -y -q
dnf install -y zlib-devel cyrus-sasl-devel libevent-devel
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-memcached-igbinary="yes" enable-memcached-msgpack="yes" enable-memcached-json="yes" enable-memcached-protocol="yes" enable-memcached-sasl="yes" enable-memcached-session="yes"' memcached
echo 'extension=memcached.so' > /etc/php.d/41-memcached.ini
Expand Down Expand Up @@ -550,13 +551,15 @@ Resources:
create_site_conf:
command: ./create_site_conf.sh
cwd: /tmp
ignoreErrors: false
start_webserver:
start_services:
services:
sysvinit:
httpd:
enabled: true
ensureRunning: true
crond:
enabled: true
ensureRunning: true
add_crontab:
files:
/tmp/add_crontab.sh:
Expand All @@ -570,7 +573,6 @@ Resources:
add_crontab:
command: ./add_crontab.sh
cwd: /tmp
ignoreErrors: false
Properties:
LaunchTemplateData:
BlockDeviceMappings:
Expand Down

0 comments on commit a2aee47

Please sign in to comment.