Skip to content

Commit

Permalink
Sharing production DPR data (#6586)
Browse files Browse the repository at this point in the history
* Sharing production DPR data

* 🤖 Update .github/dependabot.yml

---------

Co-authored-by: Ministry of Justice Data Platform Robot <[email protected]>
  • Loading branch information
julialawrence and moj-data-platform-robot authored Jan 23, 2025
1 parent 453526f commit b5ea11c
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ updates:
- "terraform/aws/analytical-platform-data-production/ingestion-egress"
- "terraform/aws/analytical-platform-data-production/joiners-movers-leavers"
- "terraform/aws/analytical-platform-data-production/lakeformation-external-data/digital-prisons-reporting-preproduction"
- "terraform/aws/analytical-platform-data-production/lakeformation-external-data/digital-prisons-reporting-production"
- "terraform/aws/analytical-platform-data-production/openmetadata"
- "terraform/aws/analytical-platform-data-production/powerbi-gateway"
- "terraform/aws/analytical-platform-data-production/rds-s3-exports"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
##################################################
# AWS
##################################################

data "aws_caller_identity" "session" {
provider = aws.session
}

data "aws_iam_session_context" "session" {
provider = aws.session

arn = data.aws_caller_identity.session.arn
}

### Account Information

data "aws_secretsmanager_secret" "account_ids" {
provider = aws.session
name = "analytical-platform/platform-account-ids"
}

data "aws_secretsmanager_secret_version" "account_ids_version" {
provider = aws.session
secret_id = data.aws_secretsmanager_secret.account_ids.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
locals {
data_locations = [
{
data_location = "arn:aws:s3:::dpr-structured-historical-production"
hybrid_access = true
register = true
share = true

}
]

databases = [
{
name = "curated_prisons_history"
share_all_tables = true
share_all_tables_permissions = ["DESCRIBE", "SELECT"]

}
]

account_ids = jsondecode(data.aws_secretsmanager_secret_version.account_ids_version.secret_string)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Module: lake_formation_analytical_platform_data_prod
module "lake_formation_analytical_platform_data_prod" {
source = "github.com/ministryofjustice/terraform-aws-analytical-platform-lakeformation?ref=6fab8677e457c2e276fa1feec8ee83bbccc1220a"


providers = {
aws.source = aws.digital_prisons_reporting_prod_eu_west_2
aws.destination = aws
}

data_locations = local.data_locations
databases_to_share = local.databases
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
terraform {
backend "s3" {
acl = "private"
bucket = "global-tf-state-aqsvzyd5u9"
encrypt = true
key = "aws/analytical-platform-data-production/lakeformation-external-data/digital-prisons-reporting-production/terraform.tfstate"
region = "eu-west-2"
dynamodb_table = "global-tf-state-aqsvzyd5u9-locks"
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "5.82.2"
}
}

required_version = "~> 1.5"
}

provider "aws" {
alias = "session"
region = "eu-west-2"
}

provider "aws" {
alias = "digital_prisons_reporting_prod_eu_west_2"
region = "eu-west-2"
assume_role {
role_arn = "arn:aws:iam::${local.account_ids["digital-prisons-reporting-production"]}:role/analytical-platform-data-production-share-role"
}
default_tags {
tags = var.tags
}
}

provider "aws" {
region = "eu-west-1"
assume_role {
role_arn = "arn:aws:iam::${local.account_ids["analytical-platform-data-production"]}:role/GlobalGitHubActionAdmin"
}
default_tags {
tags = var.tags
}
}


provider "aws" {
alias = "analytical_platform_management_production"
region = "eu-west-1"
assume_role {
role_arn = can(regex("AdministratorAccess", data.aws_iam_session_context.session.issuer_arn)) ? null : "arn:aws:iam::${local.account_ids["analytical-platform-management-production"]}:role/GlobalGitHubActionAdmin"
}
default_tags {
tags = var.tags
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##################################################
# General
##################################################

tags = {
business-unit = "Platforms"
application = "lakeformation-external-data/digital-prisons-reporting-production"
component = "lakeformation-external-data/digital-prisons-reporting-production"
environment = "production"
is-production = "true"
owner = "data-platform:[email protected]"
infrastructure-support = "data-platform:[email protected]"
source-code = "github.com/ministryofjustice/data-platform/terraform/aws/analytical-platform-data-production/lakeformation-external-data/digital-prisons-reporting-production"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##################################################
# General
##################################################

variable "tags" {
type = map(string)
description = "Map of tags to apply to resources"
}

0 comments on commit b5ea11c

Please sign in to comment.