-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRC-446 : Create preprod environment for hmpps-personal-relationships…
…-api
- Loading branch information
1 parent
81b070f
commit ec21ff3
Showing
14 changed files
with
501 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ud-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/00-namespace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: "hmpps-personal-relationships-preprod" | ||
labels: | ||
cloud-platform.justice.gov.uk/is-production: "false" | ||
cloud-platform.justice.gov.uk/environment-name: "preprod" | ||
pod-security.kubernetes.io/enforce: restricted | ||
annotations: | ||
cloud-platform.justice.gov.uk/business-unit: "HMPPS" | ||
cloud-platform.justice.gov.uk/slack-channel: "public_move-and-improve" | ||
cloud-platform.justice.gov.uk/application: "HMPPS personal-relationships" | ||
cloud-platform.justice.gov.uk/owner: "Move and Improve: [email protected]" | ||
cloud-platform.justice.gov.uk/source-code: "https://github.com/ministryofjustice/hmpps-personal-relationships-api" | ||
cloud-platform.justice.gov.uk/team-name: "farsight-devs" | ||
cloud-platform.justice.gov.uk/review-after: "" |
19 changes: 19 additions & 0 deletions
19
...e.cloud-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/01-rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: hmpps-personal-relationships-preprod-admin | ||
namespace: hmpps-personal-relationships-preprod | ||
subjects: | ||
- kind: Group | ||
name: "github:dps-tech" | ||
apiGroup: rbac.authorization.k8s.io | ||
- kind: Group | ||
name: "github:hmpps-sre" | ||
apiGroup: rbac.authorization.k8s.io | ||
- kind: Group | ||
name: "github:hmpps-move-and-improve" | ||
apiGroup: rbac.authorization.k8s.io | ||
roleRef: | ||
kind: ClusterRole | ||
name: admin | ||
apiGroup: rbac.authorization.k8s.io |
14 changes: 14 additions & 0 deletions
14
...d-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/02-limitrange.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: LimitRange | ||
metadata: | ||
name: limitrange | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
limits: | ||
- default: | ||
cpu: 1000m | ||
memory: 1000Mi | ||
defaultRequest: | ||
cpu: 10m | ||
memory: 100Mi | ||
type: Container |
8 changes: 8 additions & 0 deletions
8
...latform.service.justice.gov.uk/hmpps-personal-relationships-preprod/03-resourcequota.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: ResourceQuota | ||
metadata: | ||
name: namespace-quota | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
hard: | ||
pods: "50" |
27 changes: 27 additions & 0 deletions
27
...latform.service.justice.gov.uk/hmpps-personal-relationships-preprod/04-networkpolicy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: default | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
- podSelector: {} | ||
--- | ||
kind: NetworkPolicy | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: allow-ingress-controllers | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
podSelector: {} | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
component: ingress-controllers |
26 changes: 26 additions & 0 deletions
26
...-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/06-certificate.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: hmpps-personal-relationships-api-cert | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
secretName: hmpps-personal-relationships-api-cert | ||
issuerRef: | ||
name: letsencrypt-production | ||
kind: ClusterIssuer | ||
dnsNames: | ||
- personal-relationships-api-preprod.hmpps.service.justice.gov.uk | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: hmpps-personal-relationships-ui-cert | ||
namespace: hmpps-personal-relationships-preprod | ||
spec: | ||
secretName: hmpps-personal-relationships-ui-cert | ||
issuerRef: | ||
name: letsencrypt-production | ||
kind: ClusterIssuer | ||
dnsNames: | ||
- personal-relationships-preprod.hmpps.service.justice.gov.uk |
14 changes: 14 additions & 0 deletions
14
...vice.justice.gov.uk/hmpps-personal-relationships-preprod/resources/domain-events-topic.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
resource "kubernetes_secret" "hmpps_personal_relationships_domain_events_topic" { | ||
metadata { | ||
name = "hmpps-domain-events-topic" | ||
namespace = var.namespace | ||
} | ||
|
||
data = { | ||
topic_arn = data.aws_ssm_parameter.hmpps-domain-events-topic-arn.value | ||
} | ||
} | ||
|
||
data "aws_ssm_parameter" "hmpps-domain-events-topic-arn" { | ||
name = "/hmpps-domain-events-preprod/topic-arn" | ||
} |
39 changes: 39 additions & 0 deletions
39
...form.service.justice.gov.uk/hmpps-personal-relationships-preprod/resources/elasticache.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################################################################################ | ||
# HMPPs Typescript Template Application Elasticache | ||
################################################################################ | ||
|
||
module "elasticache_redis" { | ||
source = "github.com/ministryofjustice/cloud-platform-terraform-elasticache-cluster?ref=7.1.0" | ||
vpc_name = var.vpc_name | ||
team_name = var.team_name | ||
business_unit = var.business_unit | ||
application = var.application | ||
is_production = var.is_production | ||
namespace = var.namespace | ||
environment_name = var.environment | ||
infrastructure_support = var.infrastructure_support | ||
|
||
number_cache_clusters = var.number_cache_clusters | ||
# sized for micro in dev, preprod, suggest small for production | ||
node_type = "cache.t4g.micro" | ||
engine_version = "7.0" | ||
parameter_group_name = "default.redis7" | ||
|
||
providers = { | ||
aws = aws.london | ||
} | ||
} | ||
|
||
resource "kubernetes_secret" "elasticache_redis" { | ||
metadata { | ||
name = "elasticache-redis" | ||
namespace = var.namespace | ||
} | ||
|
||
data = { | ||
primary_endpoint_address = module.elasticache_redis.primary_endpoint_address | ||
auth_token = module.elasticache_redis.auth_token | ||
member_clusters = jsonencode(module.elasticache_redis.member_clusters) | ||
replication_group_id = module.elasticache_redis.replication_group_id | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...ud-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/resources/irsa.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Add the names of the SQS queues & SNS topics which the app needs permissions to access. | ||
# The value of each item should be the namespace where the queue or topic was created. | ||
# This information is used to collect the IAM policies which are used by the IRSA module. | ||
locals { | ||
# The names of the queues used and the namespace which created them | ||
sqs_queues = { | ||
"Digital-Prison-Services-preprod-hmpps_audit_queue" = "hmpps-audit-preprod", | ||
} | ||
|
||
# The names of the SNS topics used and the namespace which created them | ||
sns_topics = { | ||
"cloud-platform-Digital-Prison-Services-15b2b4a6af7714848baeaf5f41c85fcd" = "hmpps-domain-events-preprod" | ||
} | ||
|
||
sqs_policies = { for item in data.aws_ssm_parameter.irsa_policy_arns_sqs : item.name => item.value } | ||
sns_policies = { for item in data.aws_ssm_parameter.irsa_policy_arns_sns : item.name => item.value } | ||
} | ||
|
||
module "irsa" { | ||
source = "github.com/ministryofjustice/cloud-platform-terraform-irsa?ref=2.0.0" # use the latest release | ||
|
||
# EKS configuration | ||
eks_cluster_name = var.eks_cluster_name | ||
|
||
# IRSA configuration | ||
service_account_name = "hmpps-personal-relationships-api" | ||
role_policy_arns = merge(local.sqs_policies, local.sns_policies) | ||
|
||
# Tags | ||
business_unit = var.business_unit | ||
application = var.application | ||
is_production = var.is_production | ||
team_name = var.team_name | ||
namespace = var.namespace # this is also used to attach your service account to your namespace | ||
environment_name = var.environment | ||
infrastructure_support = var.infrastructure_support | ||
} | ||
|
||
data "aws_ssm_parameter" "irsa_policy_arns_sqs" { | ||
for_each = local.sqs_queues | ||
name = "/${each.value}/sqs/${each.key}/irsa-policy-arn" | ||
} | ||
|
||
data "aws_ssm_parameter" "irsa_policy_arns_sns" { | ||
for_each = local.sns_topics | ||
name = "/${each.value}/sns/${each.key}/irsa-policy-arn" | ||
} | ||
|
||
resource "kubernetes_secret" "irsa" { | ||
metadata { | ||
name = "irsa-output" | ||
namespace = var.namespace | ||
} | ||
data = { | ||
role = module.irsa.role_name | ||
serviceaccount = module.irsa.service_account.name | ||
rolearn = module.irsa.role_arn | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
...ud-platform.service.justice.gov.uk/hmpps-personal-relationships-preprod/resources/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
terraform { | ||
backend "s3" { | ||
} | ||
} | ||
|
||
provider "aws" { | ||
alias = "london" | ||
region = "eu-west-2" | ||
|
||
default_tags { | ||
tags = { | ||
source-code = "github.com/ministryofjustice/cloud-platform-environments" | ||
slack-channel = var.slack_channel | ||
GithubTeam = "hmpps-move-and-improve" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
alias = "ireland" | ||
region = "eu-west-1" | ||
|
||
default_tags { | ||
tags = { | ||
source-code = "github.com/ministryofjustice/cloud-platform-environments" | ||
slack-channel = var.slack_channel | ||
GithubTeam = "hmpps-move-and-improve" | ||
} | ||
} | ||
} | ||
|
||
provider "github" { | ||
token = var.github_token | ||
owner = var.github_owner | ||
} | ||
|
||
provider "kubernetes" {} | ||
|
||
locals { | ||
default_tags = { | ||
business_unit = var.business_unit | ||
application = var.application | ||
is_production = var.is_production | ||
team_name = var.team_name | ||
environment_name = var.environment | ||
infrastructure_support = var.infrastructure_support | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...m.service.justice.gov.uk/hmpps-personal-relationships-preprod/resources/rds-postgresql.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Make sure that you use the latest version of the module by changing the | ||
* `ref=` value in the `source` attribute to the latest version listed on the | ||
* releases page of this repository. | ||
* | ||
*/ | ||
module "rds" { | ||
source = "github.com/ministryofjustice/cloud-platform-terraform-rds-instance?ref=7.3.1" | ||
|
||
# VPC configuration | ||
vpc_name = var.vpc_name | ||
|
||
# RDS configuration | ||
allow_minor_version_upgrade = true | ||
allow_major_version_upgrade = false | ||
performance_insights_enabled = false | ||
db_max_allocated_storage = "500" | ||
enable_rds_auto_start_stop = true # Uncomment to turn off your database overnight between 10PM and 6AM UTC / 11PM and 7AM BST. | ||
# db_password_rotated_date = "2023-04-17" # Uncomment to rotate your database password. | ||
|
||
# PostgreSQL specifics | ||
db_engine = "postgres" | ||
db_engine_version = "16" | ||
rds_family = "postgres16" | ||
db_instance_class = "db.t4g.small" | ||
|
||
# Tags | ||
application = var.application | ||
business_unit = var.business_unit | ||
environment_name = var.environment | ||
infrastructure_support = var.infrastructure_support | ||
is_production = var.is_production | ||
namespace = var.namespace | ||
team_name = var.team_name | ||
} | ||
|
||
resource "kubernetes_secret" "rds" { | ||
metadata { | ||
name = "rds-postgresql-instance-output" | ||
namespace = var.namespace | ||
} | ||
|
||
data = { | ||
rds_instance_endpoint = module.rds.rds_instance_endpoint | ||
database_name = module.rds.database_name | ||
database_username = module.rds.database_username | ||
database_password = module.rds.database_password | ||
rds_instance_address = module.rds.rds_instance_address | ||
} | ||
} | ||
|
||
resource "kubernetes_config_map" "rds" { | ||
metadata { | ||
name = "rds-postgresql-instance-output" | ||
namespace = var.namespace | ||
} | ||
|
||
data = { | ||
database_name = module.rds.database_name | ||
db_identifier = module.rds.db_identifier | ||
} | ||
} | ||
|
Oops, something went wrong.