Skip to content

Commit

Permalink
Workflow: created files in .
Browse files Browse the repository at this point in the history
  • Loading branch information
modernisation-platform-ci committed Mar 20, 2024
1 parent 06aee47 commit 6800dd4
Show file tree
Hide file tree
Showing 15 changed files with 495 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
/terraform/environments/nomis-data-hub @ministryofjustice/studio-webops @ministryofjustice/modernisation-platform
/terraform/environments/nomis @ministryofjustice/studio-webops @ministryofjustice/syscon-devs @ministryofjustice/syscon-nomis @ministryofjustice/modernisation-platform
/terraform/environments/oas @ministryofjustice/laa-aws-infrastructure @ministryofjustice/oas-migration @ministryofjustice/modernisation-platform
/terraform/environments/oasys-national-reporting @ministryofjustice/studio-webops @ministryofjustice/modernisation-platform
/terraform/environments/oasys @ministryofjustice/oasys-operator @ministryofjustice/studio-webops @ministryofjustice/modernisation-platform
/terraform/environments/observability-platform @ministryofjustice/observability-platform @ministryofjustice/modernisation-platform
/terraform/environments/performance-hub @ministryofjustice/performance-hub-developers @ministryofjustice/modernisation-platform
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/oasys-national-reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: oasys-national-reporting
on:
push:
branches:
- main
paths:
- 'terraform/environments/oasys-national-reporting/**'
- '.github/workflows/oasys-national-reporting.yml'

pull_request:
branches:
- main
types: [opened, edited, reopened, synchronize]
paths:
- 'terraform/environments/oasys-national-reporting/**'
- '.github/workflows/oasys-national-reporting.yml'

workflow_dispatch:
inputs:
action:
description: 'Set either [deploy|destroy].'
default: 'deploy'
required: true
type: string
options:
- deploy
- destroy

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
strategy:
uses: ./.github/workflows/reusable_terraform_strategy.yml
if: inputs.action != 'destroy'
with:
application: "${{ github.workflow }}"

terraform:
needs: strategy
if: inputs.action != 'destroy'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.strategy.outputs.matrix) }}
uses: ./.github/workflows/reusable_terraform_plan_apply.yml
with:
application: "${{ github.workflow }}"
environment: "${{ matrix.target }}"
action: "${{ matrix.action }}"
secrets:
modernisation_platform_environments: "${{ secrets.MODERNISATION_PLATFORM_ENVIRONMENTS }}"
pipeline_github_token: "${{ secrets.MODERNISATION_PLATFORM_CI_USER_ENVIRONMENTS_REPO_PAT }}"

destroy-development:
if: inputs.action == 'destroy'
uses: ./.github/workflows/reusable_terraform_plan_apply.yml
with:
application: "${{ github.workflow }}"
environment: "development"
action: "plan_apply"
plan_apply_tfargs: "-destroy"
secrets:
modernisation_platform_environments: "${{ secrets.MODERNISATION_PLATFORM_ENVIRONMENTS }}"
pipeline_github_token: "${{ secrets.MODERNISATION_PLATFORM_CI_USER_ENVIRONMENTS_REPO_PAT }}"
76 changes: 76 additions & 0 deletions terraform/environments/oasys-national-reporting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Service Runbook

<!-- This is a template that should be populated by the development team when moving to the modernisation platform, but also reviewed and kept up to date.
To ensure that people looking at your runbook can get the information they need quickly, your runbook should be short but clear. Throughout, only use acronyms if you’re confident that someone who has just been woken up at 3am would understand them. -->

_If you have any questions surrounding this page please post in the `#team-name` channel._

## Mandatory Information

### **Last review date:**

<!-- Adding the last date this page was reviewed, with any accompanying information -->

### **Description:**

<!-- A short (less than 50 word) description of what your service does, and who it’s for.-->

### **Service URLs:**

<!-- The URL(s) of the service’s production environment, and test environments if possible-->

### **Incident response hours:**

<!-- When your service receives support for urgent issues. This should be written in a clear, unambiguous way. For example: 24/7/365, Office hours, usually 9am-6pm on working days, or 7am-10pm, 365 days a year. -->

### **Incident contact details:**

<!-- How people can raise an urgent issue with your service. This must not be the email address or phone number of an individual on your team, it should be a shared email address, phone number, or website that allows someone with an urgent issue to raise it quickly. -->

### **Service team contact:**

<!-- How people with non-urgent issues or questions can get in touch with your team. As with incident contact details, this must not be the email address or phone number of an individual on the team, it should be a shared email address or a ticket tracking system.-->

### **Hosting environment:**

Modernisation Platform

<!-- If your service is hosted on another MOJ team’s infrastructure, link to their runbook. If your service has another arrangement or runs its own infrastructure, you should list the supplier of that infrastructure (ideally linking to your account’s login page) and describe, simply and briefly, how to raise an issue with them. -->

## Optional

### **Other URLs:**

<!-- If you can, provide links to the service’s monitoring dashboard(s), health checks, documentation (ideally describing how to run/work with the service), and main GitHub repository. -->

### **Expected speed and frequency of releases:**

<!-- How often are you able to release changes to your service, and how long do those changes take? -->

### **Automatic alerts:**

<!-- List, briefly, problems (or types of problem) that will automatically alert your team when they occur. -->

### **Impact of an outage:**

<!-- A short description of the risks if your service is down for an extended period of time. -->

### **Out of hours response types:**

<!-- Describe how incidents that page a person on call are responded to. How long are out-of-hours responders expected to spend trying to resolve issues before they stop working, put the service into maintenance mode, and hand the issue to in-hours support? -->

### **Consumers of this service:**

<!-- List which other services (with links to their runbooks) rely on this service. If your service is considered a platform, these may be too numerous to reasonably list. -->

### **Services consumed by this:**

<!-- List which other services (with links to their runbooks) this service relies on. -->

### **Restrictions on access:**

<!-- Describe any conditions which restrict access to the service, such as if it’s IP-restricted or only accessible from a private network.-->

### **How to resolve specific issues:**

<!-- Describe the steps someone might take to resolve a specific issue or incident, often for use when on call. This may be a large amount of information, so may need to be split out into multiple pages, or link to other documents.-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"accounts": {
"development": {
"example_var": "dev-data"
},
"test": {
"example_var": "test-data"
},
"preproduction": {
"example_var": "preproduction-data"
},
"production": {
"example_var": "production-data"
}
}
}
1 change: 1 addition & 0 deletions terraform/environments/oasys-national-reporting/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#### This file can be used to store data specific to the member account ####
1 change: 1 addition & 0 deletions terraform/environments/oasys-national-reporting/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#### This file can be used to store locals specific to the member account ####
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"networking": [
{
"business-unit": "",
"set": "",
"application": "oasys-national-reporting"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Backend
terraform {
# `backend` blocks do not support variables, so the following are hard-coded here:
# - S3 bucket name, which is created in modernisation-platform-account/s3.tf
backend "s3" {
acl = "bucket-owner-full-control"
bucket = "modernisation-platform-terraform-state"
dynamodb_table = "modernisation-platform-terraform-state-lock"
encrypt = true
key = "terraform.tfstate"
region = "eu-west-2"
workspace_key_prefix = "environments/members/oasys-national-reporting" # This will store the object as environments/members/oasys-national-reporting/${workspace}/terraform.tfstate
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "networking" {

type = list(any)

}

variable "collaborator_access" {
type = string
default = "developer"
description = "Collaborators must specify which access level they are using, eg set an environment variable of export TF_VAR_collaborator_access=migration"
}
173 changes: 173 additions & 0 deletions terraform/environments/oasys-national-reporting/platform_data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Current account data
data "aws_region" "current" {}

data "aws_caller_identity" "current" {}

# VPC and subnet data
data "aws_vpc" "shared" {
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}"
}
}

data "aws_subnets" "shared-data" {
filter {
name = "vpc-id"
values = [data.aws_vpc.shared.id]
}
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-data*"
}
}

data "aws_subnets" "shared-private" {
filter {
name = "vpc-id"
values = [data.aws_vpc.shared.id]
}
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-private*"
}
}

data "aws_subnets" "shared-public" {
filter {
name = "vpc-id"
values = [data.aws_vpc.shared.id]
}
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-public*"
}
}

data "aws_subnet" "data_subnets_a" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-data-${data.aws_region.current.name}a"
}
}

data "aws_subnet" "data_subnets_b" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-data-${data.aws_region.current.name}b"
}
}

data "aws_subnet" "data_subnets_c" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-data-${data.aws_region.current.name}c"
}
}

data "aws_subnet" "private_subnets_a" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-private-${data.aws_region.current.name}a"
}
}

data "aws_subnet" "private_subnets_b" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-private-${data.aws_region.current.name}b"
}
}

data "aws_subnet" "private_subnets_c" {
vpc_id = data.aws_vpc.shared.id
tags = {
"Name" = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-private-${data.aws_region.current.name}c"
}
}

data "aws_subnet" "public_subnets_a" {
vpc_id = data.aws_vpc.shared.id
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-public-${data.aws_region.current.name}a"
}
}

data "aws_subnet" "public_subnets_b" {
vpc_id = data.aws_vpc.shared.id
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-public-${data.aws_region.current.name}b"
}
}

data "aws_subnet" "public_subnets_c" {
vpc_id = data.aws_vpc.shared.id
tags = {
Name = "${var.networking[0].business-unit}-${local.environment}-${var.networking[0].set}-public-${data.aws_region.current.name}c"
}
}

# Route53 DNS data
data "aws_route53_zone" "external" {
provider = aws.core-vpc

name = "${var.networking[0].business-unit}-${local.environment}.modernisation-platform.service.justice.gov.uk."
private_zone = false
}

data "aws_route53_zone" "inner" {
provider = aws.core-vpc

name = "${var.networking[0].business-unit}-${local.environment}.modernisation-platform.internal."
private_zone = true
}

data "aws_route53_zone" "network-services" {
provider = aws.core-network-services

name = "modernisation-platform.service.justice.gov.uk."
private_zone = false
}

# Shared KMS keys (per business unit)
data "aws_kms_key" "general_shared" {
key_id = "arn:aws:kms:eu-west-2:${local.environment_management.account_ids["core-shared-services-production"]}:alias/general-${var.networking[0].business-unit}"
}

data "aws_kms_key" "ebs_shared" {
key_id = "arn:aws:kms:eu-west-2:${local.environment_management.account_ids["core-shared-services-production"]}:alias/ebs-${var.networking[0].business-unit}"
}

data "aws_kms_key" "rds_shared" {
key_id = "arn:aws:kms:eu-west-2:${local.environment_management.account_ids["core-shared-services-production"]}:alias/rds-${var.networking[0].business-unit}"
}

# State for core-network-services resource information
data "terraform_remote_state" "core_network_services" {
backend = "s3"
config = {
acl = "bucket-owner-full-control"
bucket = "modernisation-platform-terraform-state"
key = "environments/accounts/core-network-services/core-network-services-production/terraform.tfstate"
region = "eu-west-2"
encrypt = "true"
}
}

data "aws_organizations_organization" "root_account" {}

# Retrieve information about the modernisation platform account
data "aws_caller_identity" "modernisation_platform" {
provider = aws.modernisation-platform
}

# caller account information to instantiate aws.oidc provider
data "aws_caller_identity" "original_session" {
provider = aws.original-session
}

data "aws_iam_session_context" "whoami" {
provider = aws.original-session
arn = data.aws_caller_identity.original_session.arn
}

# Get the environments file from the main repository
data "http" "environments_file" {
url = "https://raw.githubusercontent.com/ministryofjustice/modernisation-platform/main/environments/${local.application_name}.json"
}
Loading

0 comments on commit 6800dd4

Please sign in to comment.