Skip to main content

Useful scripts

In the Modernisation Platform repository, we have some useful scripts to:

  • help to automate parts of our day-to-day tasks whilst working on the Modernisation Platform
  • map common functions to work in CI/CD

Git scripts

The scripts prefixed git- are for running common git commands as part of CI/CD.

Filename Description Used in CI/CD?
git-setup.sh Configures git with the modernisation-platform-ci GitHub user example
git-commit.sh Checks out a branch named date-${epoch-time} and commits files changed in the provided path example
git-pull-request.sh Creates a pull request back to main from the current checked out branch example
update-pr-comments.sh Add a comment to a pull request example
generate-dependatbot-file.sh Keeps dependabot.yml up to date with module dependencies example

Terraform scripts

The scripts prefixed terraform- are for running common terraform commands as part of CI/CD.

General use

Filename Description Used in CI/CD?
terraform-init.sh Runs terraform init in the provided path with appropriate flags set for CI/CD example
terraform-plan.sh Runs terraform plan in the provided path with appropriate flags set for CI/CD, and redacts the output (see redact-output.sh) example
terraform-apply.sh Runs terraform apply in the provided path with appropriate flags set for CI/CD, and redacts the output (see redact-output.sh) example

Specific use

Filename Description Used in CI/CD?
redact-output.sh Runs sed to redact values from terraform plan and terraform apply example

Other Scripts

Environment Provisioning

Filename Description Used in CI/CD?
provision-terraform-workspaces.sh Runs terraform workspace new ${application-name}-${environment} in the provided directory example
loop-through-terraform-workspaces.sh Runs terraform plan or apply across all remote terraform workspaces in the provided directory example
provision-environment-directories.sh Copies templates/*.tf files to an environment directory when a new environment is created example
provision-member-directories.sh Copies templates/*.tf files to the member environment repository when a new environment is created example
member-account-ram-association.sh Creates networking RAM associations when new networking is created example

Internal scripts

Filename Description Used in CI/CD?
internal/upgrade-terraform-providers.sh This script looks for any directory that holds a *.tf file, unless it’s a .terraform directory or is the templates/ directory, and runs terraform init -upgrade within them. It’s useful for bulk-updating all of the Terraform providers and modules in one go
internal/find-terraform-workspace.sh This script finds terraform workspaces for an environment when it needs to be deleted
This page was last reviewed on 23 August 2024. It needs to be reviewed again on 23 February 2025 by the page owner #modernisation-platform .
This page was set to be reviewed before 23 February 2025 by the page owner #modernisation-platform. This might mean the content is out of date.