Skip to content

Commit a2aee47

Browse files
authored
Merge pull request #59 from aws-samples/moodle4.4
Update to Moodle 4.4
2 parents f5cdd70 + 528d80b commit a2aee47

File tree

4 files changed

+61
-49
lines changed

4 files changed

+61
-49
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Hosting Moodle™ on AWS
22

3-
### Version 2.0.1
3+
### Version 2.0.2
44

55
## Overview
66

7-
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.
7+
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.
88

9-
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.
9+
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.
1010

1111
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.
1212

13-
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.
13+
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.
1414

1515
## Deployment guide
1616

@@ -55,7 +55,7 @@ You can launch this CloudFormation template in different AWS Regions. Below are
5555
| 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) |
5656
| 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) |
5757
| 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) |
58-
| 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) |
58+
| 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) |
5959

6060
## Architecture
6161

@@ -94,7 +94,7 @@ With [elastic](https://docs.aws.amazon.com/efs/latest/ug/performance.html#elasti
9494
*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.
9595

9696
### AWS CodePipeline
97-
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.
97+
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.
9898
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.
9999

100100
*You can customize the overall pipeline for your Moodle™ setup.*

templates/00-main.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ Parameters:
660660
Description: Email address for notification
661661
Type: String
662662
Default: hello@yourdomain.com
663+
MoodleDirectDownloadURL:
664+
Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz"
665+
Description: Specifies the TGZ Moodle direct download URL
666+
Type: String
663667

664668
Conditions:
665669
DeployWithoutSessionCache:
@@ -947,6 +951,8 @@ Resources:
947951
!Ref WebAsgMax
948952
WebAsgMin:
949953
!Ref WebAsgMin
954+
MoodleDirectDownloadURL:
955+
!Ref MoodleDirectDownloadURL
950956
TemplateURL: !Sub '${DeploymentLocation}/03-pipelinehelper.yaml'
951957

952958
sessioncache:

templates/03-pipelinehelper.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ Parameters:
144144
Default: 2
145145
Description: Specifies the minimum number of EC2 instances in the Web Autoscaling Group.
146146
Type: String
147+
MoodleDirectDownloadURL:
148+
Default: "https://download.moodle.org/download.php/direct/stable404/moodle-4.4.tgz"
149+
Description: Specifies the TGZ Moodle direct download URL
150+
Type: String
147151

148152
Conditions:
149153
NumberOfSubnets1:
@@ -533,7 +537,7 @@ Resources:
533537
mkdir /tmp/moodle/.pipeline
534538
535539
# Get Latest Moodle stable version
536-
wget -O /tmp/moodle.tgz https://download.moodle.org/download.php/direct/stable403/moodle-latest-403.tgz
540+
wget -O /tmp/moodle.tgz ${MoodleDirectDownloadURL}
537541
tar -xvzf /tmp/moodle.tgz --strip-components=1 -C /tmp/moodle/
538542
wget -O /tmp/moodle/lib/aws.phar https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.phar
539543
cd /tmp/moodle

templates/04-web.yaml

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,43 @@ Resources:
333333
AWS::CloudFormation::Init:
334334
configSets:
335335
deploy_webserver:
336-
- install_logs
336+
- install_packages
337+
- install_cloudwatchlogs
337338
- install_codedeploy
338339
- install_webserver
339-
- start_webserver
340+
- start_services
340341
- add_crontab
341-
install_logs:
342+
install_packages:
343+
packages:
344+
yum:
345+
amazon-cloudwatch-agent: []
346+
ruby3.2: []
347+
httpd: []
348+
php8.1: []
349+
php8.1-gd: []
350+
php8.1-soap: []
351+
php8.1-intl: []
352+
php8.1-mbstring: []
353+
php8.1-xml: []
354+
php8.1-opcache: []
355+
php8.1-fpm: []
356+
php8.1-pgsql: []
357+
php8.1-mysqlnd: []
358+
cronie: []
359+
php8.1-devel: []
360+
php-pear: []
361+
libzip: []
362+
libzip-devel: []
363+
libsodium-devel: []
364+
libzstd-devel: []
365+
redis6-devel: []
366+
lz4-devel: []
367+
libmemcached-awesome-tools: []
368+
libmemcached-awesome-devel: []
369+
zlib-devel: []
370+
cyrus-sasl-devel: []
371+
libevent-devel: []
372+
install_cloudwatchlogs:
342373
files:
343374
/etc/awslogs/awslogs.conf:
344375
content: !Sub |
@@ -393,35 +424,17 @@ Resources:
393424
owner: root
394425
group: root
395426
commands:
396-
01_create_state_directory:
427+
create_state_directory:
397428
command: mkdir -p /var/awslogs/state
398-
02_install_cloudwatch_agent:
399-
command: dnf install -y amazon-cloudwatch-agent
400-
install_aws_ini:
401-
commands:
402-
install_aws_ini:
403-
command: ./download_aws_ini.sh
404-
cwd: /tmp
405-
ignoreErrors: true
406429
install_codedeploy:
407430
files:
408-
/tmp/install_codedeploy.sh:
409-
content:
410-
!Sub |
411-
#!/bin/bash -xe
412-
dnf install -y ruby
413-
cd /home/ec2-user
414-
wget https://aws-codedeploy-${AWS::Region}.s3.${AWS::Region}.amazonaws.com/latest/install
415-
chmod +x ./install
416-
./install auto
417-
mode: 000500
418-
owner: root
419-
group: root
431+
/home/ec2-user/install:
432+
source: !Join ["", ["https://aws-codedeploy-", !Ref "AWS::Region", ".s3.", !Ref "AWS::Region", ".amazonaws.com/latest/install" ] ]
433+
mode: "000755"
420434
commands:
421435
install_codedeploy:
422-
command: ./install_codedeploy.sh
423-
cwd: /tmp
424-
ignoreErrors: false
436+
command: "./install auto"
437+
cwd: "/home/ec2-user/"
425438
install_webserver:
426439
files:
427440
/tmp/status.txt:
@@ -433,20 +446,12 @@ Resources:
433446
/tmp/create_site_conf.sh:
434447
content: !Sub |
435448
#!/bin/bash -xe
436-
dnf install -y php8.1 php-gd php-soap php-intl php-mbstring php-xml php-opcache php-fpm php-pgsql php-mysqlnd
437-
438-
# Enable crontab on Amazon Linux 2023
439-
dnf install -y cronie
440-
systemctl enable crond
441-
systemctl start crond
442449
443450
# Below to be able to compile zip.so for the PHP Zip library that's not in the available packages...
444-
dnf install -y php8.1-devel php-pear libzip libzip-devel
445451
pecl install zip
446452
echo "extension=zip.so;" > /etc/php.d/50-zip.ini
447453
448454
# Install Sodium
449-
dnf install -y libsodium-devel
450455
pecl install -f libsodium
451456
echo "extension=sodium.so;" > /etc/php.d/50-sodium.ini
452457
@@ -457,12 +462,10 @@ Resources:
457462
echo 'extension=igbinary.so' > /etc/php.d/30-igbinary.ini
458463
/usr/bin/yes 'no' | pecl install msgpack
459464
echo 'extension=msgpack.so' > /etc/php.d/30-msgpack.ini
460-
dnf install -q -y libzstd-devel
461465
/usr/bin/yes 'no' | pecl install zstd
462466
echo 'extension=zstd.so' > /etc/php.d/40-zstd.ini
463467
/usr/bin/yes 'no' | pecl install --configureoptions 'enable-lzf-better-compression="no"' lzf
464468
echo 'extension=lzf.so' > /etc/php.d/40-lzf.ini
465-
dnf install -q -y redis6-devel lz4-devel
466469
/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
467470
echo 'extension=redis.so' > /etc/php.d/41-redis.ini
468471
@@ -509,8 +512,6 @@ Resources:
509512
#mv amazon-elasticache-cluster-client.so /usr/lib64/php/modules/
510513
#echo 'extension=amazon-elasticache-cluster-client.so;' > /etc/php.d/50-elasticache.ini
511514
# Install Memcached client - note that ElastiCache client is failing on AL2023
512-
dnf install libmemcached libmemcached-devel -y -q
513-
dnf install -y zlib-devel cyrus-sasl-devel libevent-devel
514515
/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
515516
echo 'extension=memcached.so' > /etc/php.d/41-memcached.ini
516517
@@ -550,13 +551,15 @@ Resources:
550551
create_site_conf:
551552
command: ./create_site_conf.sh
552553
cwd: /tmp
553-
ignoreErrors: false
554-
start_webserver:
554+
start_services:
555555
services:
556556
sysvinit:
557557
httpd:
558558
enabled: true
559559
ensureRunning: true
560+
crond:
561+
enabled: true
562+
ensureRunning: true
560563
add_crontab:
561564
files:
562565
/tmp/add_crontab.sh:
@@ -570,7 +573,6 @@ Resources:
570573
add_crontab:
571574
command: ./add_crontab.sh
572575
cwd: /tmp
573-
ignoreErrors: false
574576
Properties:
575577
LaunchTemplateData:
576578
BlockDeviceMappings:

0 commit comments

Comments
 (0)