This repository contains a new Landoified vanilla Drupal 10 site that will be deployed to and AWS EC2 instance using GitHub Actions and AWS CodeDeploy for CI/CD.
- AWS account with roles and permissions setup for CodeDeploy, Cloudformation, and GitHub Actions
- EC2 or local instance of the Drupal Application
- EC2 or local instance of Sonarqube
- Cloudformation roles and permissions
- CodeDeploy and GitHub Actions roles and permissions
aws cloudformation create-stack \ --stack-name "codedeploy-stack" \ --disable-rollback \ --region us-gov-west-1 \ --capabilities CAPABILITY_NAMED_IAM \ --template-body file://.aws/cloudformation-templates/codedeploy/codedeploy_setup_CF.yaml \ --parameters file://.aws/cloudformation-templates/codedeploy/parameters.json
- Deploying SonarQube
- Deploy on AWS using cloudformation
aws cloudformation create-stack \ --stack-name "sonarqube-stack" \ --disable-rollback \ --region us-gov-west-1 \ --capabilities CAPABILITY_NAMED_IAM \ --template-body file://.aws/cloudformation-templates/sonarqube/sonarqube_single_instance_CF_stack.yml \ --parameters file://.aws/cloudformation-templates/sonarqube/parameters.json
- Deploy Locally with Docker Compose
cd .aws/cloudformation-templates/sonarqube docker compose up -d
- Deploy on AWS using cloudformation
- Once your instance is up and running, Log in to SonarQube using System Administrator credentials. Set a new admin password when prompted.
- If you deployed to AWS use the EC2 Public IPv4 address to login.
- If you deployed locally use http://localhost to login.
- Default System Administrator credentials:
- login: admin
- password: admin
[!IMPORTANT] Be sure to save your new admin password somewhere safe!
- Complete GitHub Integration following SonarQubes documentation.
[!IMPORTANT] Be sure to save the GitHub Client secret and Private key somewhere safe
- To allow users to log in to SonarQube with GitHub credentials follow SonarQube's Connecting your GitHub App to SonarQube documentation.
- You should now be ready to start analyzing projects.
- For basic setup and configuration see Analyzing projects with GitHub Actions
- Deploy Drupal 10 site
- Deploy on AWS using cloudformation
aws cloudformation create-stack \ --stack-name "drupal-github-aws-ci-cd-testing-dev" \ --disable-rollback \ --region us-gov-west-1 \ --capabilities CAPABILITY_NAMED_IAM \ --template-body file://.aws/cloudformation-templates/drupal/drupal10_single_instance_CF_stack.yml \ --parameters file://.aws/cloudformation-templates/drupal/parameters.json
- Deploy Locally with Docker Compose
cd .aws/cloudformation-templates/sonarqube docker compose up -d
- Deploy on AWS using cloudformation
- Install lando
- Start the drupal stack for a specific environment
-
OPTION 1 Simple Startup
# run the start.sh script with the environment (local, dev, stage, prod) as an argument ./start.sh dev
-
OPTION 2: Manual Startup Steps
Click to Expand
-
Run composer install
lando composer install
-
Create
settings.php
fromdefault.settings.php
and add the following at the bottom.cp web/sites/default/default.settings.php web/sites/default/settings.php
$databases['default']['default'] = array ( 'database' => 'drupal10', 'username' => 'drupal10', 'password' => 'drupal10', 'prefix' => '', 'host' => 'database', 'port' => '', 'isolation_level' => 'READ COMMITTED', 'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql', 'driver' => 'mysql', 'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/', ); $settings['config_sync_directory'] = '../config/sync/default'; $split_filename_prefix = 'config_split.config_split'; /** Set environment splits. */ $split_envs = [ 'local', 'dev', 'stage', 'prod' ]; // Disable all split by default. foreach ($split_envs as $split_env) { $config['$split_filename_prefix.$split_env']['status'] = FALSE; } # manually set environment #putenv('ENVIRONMENT=local'); $split = getenv('ENVIRONMENT'); // Enable the environment split only if it exists. if ($split != FALSE) { $config['$split_filename_prefix.$split']['status'] = TRUE; } else { $split = 'local'; $config['$split_filename_prefix.$split']['status'] = TRUE; }
-
Set the environment you want to use in
defaults.env
echo "ENVIRONMENT=local" > ./defaults.env
-
Start it up and make sure the environment you want is correct
lando start # check env variable is set correctly in the appserver lando ssh -s appserver -c env | grep ENVIRONMENT
-
Set
hash_salt
insettings.php
# generate a random base64 encoded string for hash_salt value HASH_SALT=$(lando drush eval "print_r(Drupal\Component\Utility\Crypt::randomBytesBase64(55))") # print the generated hash_salt echo "Hash Salt: $HASH_SALT" # set hash_salt in settings.php sed -i "s/^\$settings\['hash_salt'\].*$/\$settings\['hash_salt'\] = '$HASH_SALT';/" web/sites/default/settings.php # check settings.php has the generated hash_salt value grep hash_salt web/sites/default/settings.php
-
Install the site using existing configs
# Install drupal using existing configs lando drush site:install -y \ --account-name=admin \ --account-pass=admin \ --existing-config # Update database, import configs, and clear cache lando deploy
-
-
- Navigate to http://drupal-github-aws-ci-cd-testing_2.lndo.site/admin/config/development/configuration/config-split/add
- In the user interface enter values for the following fields
- Label: some_new_environment
- Folder: ../config/sync/some_new_environment
- Weight: 1
- Select the Modules or Items you want to be different from the default configuration
- click save
- See the Modify config for an environment section to enable the config split and make any additional changes needed.
- Make sure you have the environment you want to modify set
# check env variable is set correctly in the appserver lando ssh -s appserver -c env | grep ENVIRONMENT # change the environment if needed and rebuild echo "ENVIRONMENT=local" > ./defaults.env lando rebuild
- Make the configuration changes you need to make
- Export the configuration changes
lando cex
- commit the changes and push