Skip to content

Commit

Permalink
Merge pull request #739 from ministryofjustice/onr/DSOS-2681/distribu…
Browse files Browse the repository at this point in the history
…te-base-amis-to-onr

distribute base amis to oasys-national-reporting envs
  • Loading branch information
robertsweetman authored Mar 26, 2024
2 parents 8bec5bd + 38e7d4d commit efd1892
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 43 deletions.
11 changes: 11 additions & 0 deletions commonimages/base/locals_shared.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ locals {
is-production = var.BRANCH_NAME == "main" ? "true" : "false"
source-code = "https://github.com/ministryofjustice/modernisation-platform-ami-builds/tree/main/commonimages/base/${var.ami_base_name}"
}

accounts_to_distribute_ami = try(
var.accounts_to_distribute_ami_by_branch[var.BRANCH_NAME],
var.accounts_to_distribute_ami_by_branch["default"],
[var.account_to_distribute_ami]
)

launch_permission_account_names = try(
var.launch_permission_accounts_by_branch[var.BRANCH_NAME],
var.launch_permission_accounts_by_branch["default"]
)
}
4 changes: 2 additions & 2 deletions commonimages/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module "imagebuilder" {
component_template_args = local.component_template_args
user_data = var.user_data
infrastructure_configuration = var.infrastructure_configuration
account_to_distribute_ami = var.account_to_distribute_ami
launch_permission_account_names = var.launch_permission_account_names
accounts_to_distribute_ami = local.accounts_to_distribute_ami
launch_permission_account_names = local.launch_permission_account_names
launch_template_exists = var.launch_template_exists
image_pipeline = var.image_pipeline
systems_manager_agent = var.systems_manager_agent
Expand Down
2 changes: 2 additions & 0 deletions commonimages/base/ol_8_5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ This directory holds represents definition and configuration required to build a

NOTE: Parent 8.5 AMI no longer exists so pipeline is broken
FIXME: https://dsdmoj.atlassian.net/browse/DSOS-2558

As of March 2024 the lowest Oracle Linux version is 8.6 i.e. OL8.6-x86_64-HVM-2022-05-19
7 changes: 7 additions & 0 deletions commonimages/base/rhel_8_5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Overview
This directory holds represents definition and configuration required to build an Oracle Linux 8.5 base AMI.

NOTE: Parent 8.5 AMI no longer exists so pipeline is broken
FIXME: https://dsdmoj.atlassian.net/browse/DSOS-2558

As of March 2024 the lowest Rhel 8 Linux version is 8.6
File renamed without changes.
Empty file.
102 changes: 64 additions & 38 deletions commonimages/base/shared.auto.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,67 @@ image_pipeline = {
}
}

account_to_distribute_ami = "core-shared-services-production"

launch_permission_account_names = [
"core-shared-services-production",
"corporate-staff-rostering-development",
"corporate-staff-rostering-preproduction",
"corporate-staff-rostering-production",
"corporate-staff-rostering-test",
"hmpps-oem-development",
"hmpps-oem-preproduction",
"hmpps-oem-production",
"hmpps-oem-test",
"hmpps-domain-services-development",
"hmpps-domain-services-test",
"hmpps-domain-services-preproduction",
"hmpps-domain-services-production",
"nomis-combined-reporting-development",
"nomis-combined-reporting-preproduction",
"nomis-combined-reporting-production",
"nomis-combined-reporting-test",
"nomis-data-hub-development",
"nomis-data-hub-preproduction",
"nomis-data-hub-production",
"nomis-data-hub-test",
"nomis-development",
"nomis-preproduction",
"nomis-production",
"nomis-test",
"oasys-development",
"oasys-preproduction",
"oasys-production",
"oasys-test",
"planetfm-development",
"planetfm-preproduction",
"planetfm-production",
"planetfm-test",
"delius-core-development"
]
accounts_to_distribute_ami_by_branch = {
# push to main branch
main = [
"core-shared-services-production",
"oasys-national-reporting-development",
"oasys-national-reporting-preproduction",
"oasys-national-reporting-production",
"oasys-national-reporting-test"
]

default = [
"core-shared-services-production"
]

}

launch_permission_accounts_by_branch = {

main = [
"core-shared-services-production",
"corporate-staff-rostering-development",
"corporate-staff-rostering-preproduction",
"corporate-staff-rostering-production",
"corporate-staff-rostering-test",
"hmpps-oem-development",
"hmpps-oem-preproduction",
"hmpps-oem-production",
"hmpps-oem-test",
"hmpps-domain-services-development",
"hmpps-domain-services-test",
"hmpps-domain-services-preproduction",
"hmpps-domain-services-production",
"nomis-combined-reporting-development",
"nomis-combined-reporting-preproduction",
"nomis-combined-reporting-production",
"nomis-combined-reporting-test",
"nomis-data-hub-development",
"nomis-data-hub-preproduction",
"nomis-data-hub-production",
"nomis-data-hub-test",
"nomis-development",
"nomis-preproduction",
"nomis-production",
"nomis-test",
"oasys-development",
"oasys-preproduction",
"oasys-production",
"oasys-test",
"oasys-national-reporting-development",
"oasys-national-reporting-preproduction",
"oasys-national-reporting-production",
"oasys-national-reporting-test",
"planetfm-development",
"planetfm-preproduction",
"planetfm-production",
"planetfm-test",
"delius-core-development"
]

default = [
"core-shared-services-production",
]
}

13 changes: 10 additions & 3 deletions commonimages/base/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ variable "ami_name_prefix" {
default = "baseimage"
}

variable "accounts_to_distribute_ami_by_branch" {
type = map(any)
description = "Account that you will distribute the ami to by given github branch"
default = null
}

variable "account_to_distribute_ami" {
type = string
description = "Account that you will distribute the ami to"
default = null
}

variable "tags" {
Expand Down Expand Up @@ -117,7 +124,7 @@ variable "components_custom" {
description = "The custom components used to build the ami"
}

variable "launch_permission_account_names" {
type = list(string)
description = "The list of accounts to give launch permissions to"
variable "launch_permission_accounts_by_branch" {
type = map(any)
description = "The list of accounts to give launch permissions to by branch"
}

0 comments on commit efd1892

Please sign in to comment.