Skip to content

Commit

Permalink
Merge pull request #6 from OxBRCInformatics/feature/bignewfeature
Browse files Browse the repository at this point in the history
Add custom VM templates to prod - feature/bignewfeature
  • Loading branch information
JaimieWi authored Oct 27, 2023
2 parents 6f3893d + efa197b commit e8cdf5f
Show file tree
Hide file tree
Showing 75 changed files with 3,866 additions and 8 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/clean_validation_envs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
name: Clean Validation Environments

on: # yamllint disable-line rule:truthy
schedule:
# Every 2 hours
- cron: "0 */2 * * *"
workflow_dispatch:
inputs:
environment:
description: The environment to run this workflow in
type: environment
default: Dev
required: true


jobs:
clean:
name: Clean
runs-on: ubuntu-latest
environment: CICD
if: |
github.ref != 'refs/heads/main'
environment: Dev
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy_tre_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ jobs:
- {BUNDLE_TYPE: "workspace_service",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/ohdsi"}
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm"}
BUNDLE_DIR: "./templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm-ouh2"}
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm"}
BUNDLE_DIR: "./templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm-ouh2"}
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-export-reviewvm"}
- {BUNDLE_TYPE: "user_resource",
Expand Down Expand Up @@ -587,10 +587,10 @@ jobs:
matrix:
include:
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm",
BUNDLE_DIR: "./templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm-ouh2",
WORKSPACE_SERVICE_NAME: "tre-service-guacamole"}
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm",
BUNDLE_DIR: "./templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm-ouh2",
WORKSPACE_SERVICE_NAME: "tre-service-guacamole"}
- {BUNDLE_TYPE: "user_resource",
BUNDLE_DIR: "\\${AZURETRE_HOME}/templates/workspace_services/guacamole/user_resources/guacamole-azure-export-reviewvm",
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,8 @@ FodyWeavers.xsd

# Local .terraform directories
**/.terraform/*


letsencrypt/
index.html
validation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Local .terraform directories
**/.terraform/*

# TF backend files
**/*_backend.tf

Dockerfile.tmpl

.env*
terraform/deploy.sh
terraform/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# GUID to identify the workspace
WORKSPACE_ID=__CHANGE_ME__

# Unique identifier of the parent Guacamole service
PARENT_SERVICE_ID=__CHANGE_ME__
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile-upstream:1.4.0
FROM debian:bullseye-slim

# PORTER_INIT

# PORTER_MIXINS

# Use the BUNDLE_DIR build argument to copy files into the bundle
COPY --link . ${BUNDLE_DIR}/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
# Uncomment this line to see each command for debugging
# set -o xtrace



# Delete any existing VM Extensions befroe a VM gets deleted.
# This is needed to work around bug https://github.com/hashicorp/terraform-provider-azurerm/issues/6098

MGMT_RESOURCE_GROUP_NAME=$1
MGMT_STORAGE_ACCOUNT_NAME=$2
TF_STATE_CONTAINER_NAME=$3
ID=$4

pushd terraform

terraform init -input=false -backend=true \
-backend-config="resource_group_name=${MGMT_RESOURCE_GROUP_NAME}" \
-backend-config="storage_account_name=${MGMT_STORAGE_ACCOUNT_NAME}" \
-backend-config="container_name=${TF_STATE_CONTAINER_NAME}" \
-backend-config="key=${ID}"

echo "Running terraform state list"
tf_state_list="$(terraform state list)"
echo "State list result: ${tf_state_list}"

# The [[ $? == 1 ]] part is here because grep will exit with code 1 if there are no matches,
# which will fail the script because of set -o errexit setting.
echo "${tf_state_list}" | { grep "azurerm_virtual_machine_extension." || [[ $? == 1 ]]; } | xargs -r terraform state rm
echo "Script finished"
popd
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"schemaType": "ParameterSet",
"schemaVersion": "1.0.1",
"namespace": "",
"name": "tre-service-guacamole-linuxvm",
"parameters": [
{
"name": "workspace_id",
"source": {
"env": "WORKSPACE_ID"
}
},
{
"name": "parent_service_id",
"source": {
"env": "PARENT_SERVICE_ID"
}
},
{
"name": "tre_id",
"source": {
"env": "TRE_ID"
}
},
{
"name": "tfstate_container_name",
"source": {
"env": "TERRAFORM_STATE_CONTAINER_NAME"
}
},
{
"name": "tfstate_resource_group_name",
"source": {
"env": "MGMT_RESOURCE_GROUP_NAME"
}
},
{
"name": "tfstate_storage_account_name",
"source": {
"env": "MGMT_STORAGE_ACCOUNT_NAME"
}
},
{
"name": "id",
"source": {
"env": "ID"
}
},
{
"name": "os_image",
"source": {
"env": "OS_IMAGE"
}
},
{
"name": "shared_storage_access",
"source": {
"env": "SHARED_STORAGE_ACCESS"
}
},
{
"name": "shared_storage_name",
"source": {
"env": "SHARED_STORAGE_NAME"
}
},
{
"name": "vm_size",
"source": {
"env": "VM_SIZE"
}
},
{
"name": "image_gallery_id",
"source": {
"env": "IMAGE_GALLERY_ID"
}
},
{
"name": "azure_environment",
"source": {
"env": "AZURE_ENVIRONMENT"
}
},
{
"name": "arm_environment",
"source": {
"env": "ARM_ENVIRONMENT"
}
}
]
}
Loading

0 comments on commit e8cdf5f

Please sign in to comment.