Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/deploy_to_aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- Pre-prod
- Staging
- Production
- RBA
default: Development
deploy-plan-only:
description: 'Plan only'
Expand All @@ -38,7 +39,7 @@ on:
jobs:
init-and-plan:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
id: get_env_name
Expand Down Expand Up @@ -87,7 +88,7 @@ jobs:
apply:
needs: init-and-plan
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand Down Expand Up @@ -125,7 +126,7 @@ jobs:
build_and_push_react_app:
needs: apply
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand Down Expand Up @@ -191,7 +192,7 @@ jobs:
build_and_push_docker_image:
needs: build_and_push_react_app
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand Down Expand Up @@ -285,7 +286,7 @@ jobs:
create_kafka_topic:
needs: build_and_push_docker_image
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand All @@ -307,7 +308,7 @@ jobs:
stop_logstash:
needs: create_kafka_topic
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand All @@ -331,7 +332,7 @@ jobs:
restore_database:
needs: stop_logstash
runs-on: self-hosted
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand All @@ -342,7 +343,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore database for ${{ vars.ENV_NAME }}
if: ${{ (vars.ENV_NAME != 'Production' && vars.ENV_NAME != 'Staging' && vars.ENV_NAME != 'Development') && inputs.restore-db == true}}
if: ${{ (vars.ENV_NAME == 'Preprod' || vars.ENV_NAME == 'Test') && inputs.restore-db == true}}
run: |
cd ./src/anon-tools
mkdir -p ./keys
Expand Down Expand Up @@ -377,7 +378,7 @@ jobs:
update_services:
needs: restore_database
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand All @@ -403,7 +404,7 @@ jobs:
post_deploy:
needs: update_services
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand All @@ -424,7 +425,7 @@ jobs:
clear_opensearch:
needs: post_deploy
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand Down Expand Up @@ -484,7 +485,7 @@ jobs:
start_logstash:
needs: clear_opensearch
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || 'None' }}
environment: ${{ inputs.deploy-env || (github.ref_name == 'main' && 'Development') || (startsWith(github.ref_name, 'releases/') && 'Pre-prod') || (startsWith(github.ref_name, 'production-') && 'Production') || (startsWith(github.ref_name, 'sandbox-') && 'Staging') || (startsWith(github.ref_name, 'rba-') && 'RBA') || 'None' }}
if: ${{ inputs.deploy-plan-only == false }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
options:
- sandbox
- production
- rba
default: sandbox
clear-opensearch:
description: 'Clear the custom OpenSearch indexes and templates'
Expand Down Expand Up @@ -45,6 +46,9 @@ jobs:
if [[ ${{ github.event.inputs.deploy-env }} = "production" ]];
then
ENV="Production"
elif [[ ${{ github.event.inputs.deploy-env }} = "rba" ]];
then
ENV="RBA"
else
ENV="Staging"
fi
Expand Down
70 changes: 70 additions & 0 deletions deployment/environments/terraform-rba.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
project = "OpenSupplyHub"
environment = "Rba"

aws_region = "eu-west-1"
aws_availability_zones = ["eu-west-1a", "eu-west-1b"]

r53_private_hosted_zone = "osh.internal"
r53_public_hosted_zone = "opensupplyhub.org"

cloudfront_price_class = "PriceClass_All"

bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "256"
rds_engine_version = "16"
rds_parameter_group_family = "postgres16"
rds_instance_type = "db.m6in.4xlarge"
rds_database_identifier = "opensupplyhub-enc-rba"
rds_database_name = "opensupplyhub"
rds_multi_az = false
rds_storage_encrypted = true

app_ecs_desired_count = "4"
app_ecs_deployment_min_percent = "100"
app_ecs_deployment_max_percent = "400"
app_ecs_grace_period_seconds = "420"
app_fargate_cpu = "1024"
app_fargate_memory = "2048"

app_ecs_max_cpu_threshold = 85
app_ecs_min_cpu_threshold = 15
app_ecs_scale_target_max_capacity = 4
app_ecs_scale_target_min_capacity = 2
app_ecs_cooldown_scale_down = 300
app_ecs_cooldown_scale_up = 180

cli_fargate_cpu = "1024"
cli_fargate_memory = "8192"

batch_default_ce_spot_fleet_bid_percentage = 60
batch_ami_id = "ami-002e2fef4b94f8fd0"

batch_default_ce_min_vcpus = 0
batch_default_ce_max_vcpus = 128
batch_default_job_memory = 8192

batch_default_ce_instance_types = ["c5", "m5"]

gunicorn_worker_timeout = "360"

ec_memcached_identifier = "opensupplyhub-rba"

rds_final_snapshot_identifier = "opensupplyhub-rds-rba"
topic_dedup_basic_name = "basic-name"
dedupe_hub_live = true
dedupe_hub_name = "deduplicate"
dedupe_hub_version = 1
app_cc_ecs_desired_count = 0
app_dd_fargate_cpu = 4096
app_dd_fargate_memory = 16384
app_dd_ecs_desired_count = 1
django_log_level="DEBUG"

opensearch_instance_type = "m6g.large.search"

app_logstash_fargate_cpu = 256
app_logstash_fargate_memory = 2048

export_csv_enabled = false
1 change: 1 addition & 0 deletions deployment/terraform/batch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ resource "aws_cloudwatch_event_rule" "export_csv_schedule" {
name = "rule${local.short}ExportCsvSchedule"
description = "Runs the export_csv job on a schedule"
schedule_expression = var.export_csv_schedule_expression
is_enabled = var.export_csv_enabled
}

resource "aws_cloudwatch_event_target" "export_csv" {
Expand Down
6 changes: 6 additions & 0 deletions deployment/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,12 @@ variable "anonymized_database_password" {
sensitive = true
}

variable "export_csv_enabled" {
description = "Toggle to enable or disable the export csv scheduled job"
type = bool
default = true
}

variable "export_csv_schedule_expression" {
type = string
default = "cron(0 0 1 * ? *)"
Expand Down
5 changes: 4 additions & 1 deletion doc/release/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
* [OSDEV-1960](https://opensupplyhub.atlassian.net/browse/OSDEV-1960) - Disabled deletion protection and final snapshot creation for the RDS instance when it is deleted in the pre-prod environment.
* [OSDEV-1746](https://opensupplyhub.atlassian.net/browse/OSDEV-1746) - Implemented auto-scaling to dynamically adjust the Django instance count based on load metrics for cost-efficient resource utilization and high availability.
* The subdomain `a.os-hub.net` was removed from the CORS_ALLOWED_ORIGIN_REGEXES list in the Django application. This change was made because the subdomain was deleted from AWS Route 53 and is no longer in use.
* [OSDEV-1947](https://opensupplyhub.atlassian.net/browse/OSDEV-1947) - The following changes have been made:
* Introduced infrastructure changes to support deployment of the RBA environment. Included it in the CD pipelines in the same way as Production and Staging, which means the RBA environment can now be deployed via Git tags just like Production and Staging.
* Created the `export_csv_enabled` infrastructure switch to disable the Amazon EventBridge scheduler for the CSV export job in the RBA environment, as exporting the database to CSV is not needed in that environment.

### Bugfix
* *Describe bugfix here.*
* [OSDEV-1947](https://opensupplyhub.atlassian.net/browse/OSDEV-1947) - Fixed a bug related to an incorrect environment check in the FE app, which attempted to identify the local environment by comparing it with `development`. However, the environment had been renamed to `local` some time ago and was no longer passed as `development` from the BE during local development.

### What's new
* [OSDEV-1953](https://opensupplyhub.atlassian.net/browse/OSDEV-1953) - Implemented UI logic to display parent company OS ID fields as links on the production location profile page, directing to the corresponding production location pages in a new tab.
Expand Down
27 changes: 24 additions & 3 deletions src/django/oar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
DEBUG = (ENVIRONMENT == 'Local')

VALID_ENVIRONMENTS = ('Production', 'Staging', 'Development', 'Test',
'Preprod', 'Local')
'Preprod', 'Rba', 'Local')
if ENVIRONMENT not in VALID_ENVIRONMENTS:
raise ImproperlyConfigured(
'Invalid ENVIRONMENT provided, must be one of {}'
Expand Down Expand Up @@ -427,6 +427,24 @@
},
'AWS_REGION': 'eu-west-1',
},
'rba': {
'TASK_DEFINITION_NAME': 'OpenSupplyHubRbaAppCLI',
'CONTAINER_NAME': 'django',
'CLUSTER_NAME': 'ecsOpenSupplyHubRbaCluster',
'LAUNCH_TYPE': 'FARGATE',
'PLATFORM_VERSION': '1.4.0',
'SECURITY_GROUP_TAGS': {
'Name': 'sgAppEcsService',
'Environment': 'Rba',
'Project': 'OpenSupplyHub'
},
'SUBNET_TAGS': {
'Name': 'PrivateSubnet',
'Environment': 'Rba',
'Project': 'OpenSupplyHub'
},
'AWS_REGION': 'eu-west-1',
},
'test': {
'TASK_DEFINITION_NAME': 'OpenSupplyHubTestAppCLI',
'CONTAINER_NAME': 'django',
Expand Down Expand Up @@ -513,8 +531,11 @@
'Invalid OAR_CLIENT_KEY provided, must be set')

# Hubspot settings
HUBSPOT_API_KEY = os.getenv('HUBSPOT_API_KEY')
HUBSPOT_SUBSCRIPTION_ID = os.getenv('HUBSPOT_SUBSCRIPTION_ID')
raw_hubspot_key = os.getenv('HUBSPOT_API_KEY')
HUBSPOT_API_KEY = raw_hubspot_key if raw_hubspot_key else None

raw_hubspot_id = os.getenv('HUBSPOT_SUBSCRIPTION_ID')
HUBSPOT_SUBSCRIPTION_ID = raw_hubspot_id if raw_hubspot_id else None

# CORS
# Regex defining which endpoints enable CORS
Expand Down
3 changes: 2 additions & 1 deletion src/django/web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def environment(request):
}

# Add Environment variable, lowered for easier comparison
# One of `development`, `testing`, `staging`, `production`
# One of `development`, `test`, `preprod`, `rba`,
# `local`, `staging`, `production`
environment['ENVIRONMENT'] = settings.ENVIRONMENT.lower()

environment['OAR_CLIENT_KEY'] = settings.OAR_CLIENT_KEY
Expand Down
2 changes: 1 addition & 1 deletion src/react/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<script>
if (window.ENVIRONMENT &&
window.ENVIRONMENT.REACT_APP_ROLLBAR_CLIENT_SIDE_ACCESS_TOKEN &&
window.ENVIRONMENT.ENVIRONMENT !== 'development') {
window.ENVIRONMENT.ENVIRONMENT !== 'local') {
var _rollbarConfig = {
accessToken: window.ENVIRONMENT.REACT_APP_ROLLBAR_CLIENT_SIDE_ACCESS_TOKEN,
captureUncaught: true,
Expand Down
2 changes: 1 addition & 1 deletion src/react/src/util/util.ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const maybeGetReactAppGoogleAnalyticsKey = () => {
const gaKey = env(REACT_APP_GOOGLE_ANALYTICS_KEY);
const environment = env('ENVIRONMENT');

if (!environment || environment === 'development') {
if (!environment || environment === 'local') {
return null;
}

Expand Down