Skip to content

Commit

Permalink
πŸ”€ Merge pull request #3559 from ministryofjustice/oidc-iam
Browse files Browse the repository at this point in the history
πŸ”§ Add cross account role for apps and tools
  • Loading branch information
Jacob Woffenden authored Oct 5, 2023
2 parents 30b4e14 + 750988a commit e800fdd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
17 changes: 17 additions & 0 deletions terraform/environments/data-platform/environment-configurations.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
locals {
environment_configuration = local.environment_configurations[local.environment]
environment_configurations = {
development = {
apps_tools_account_id = local.environment_management.account_ids["data-platform-apps-and-tools-development"]
}
test = {
apps_tools_account_id = local.environment_management.account_ids["data-platform-apps-and-tools-development"]
}
preproduction = {
apps_tools_account_id = local.environment_management.account_ids["data-platform-apps-and-tools-development"]
}
production = {
apps_tools_account_id = local.environment_management.account_ids["data-platform-apps-and-tools-production"]
}
}
}
25 changes: 25 additions & 0 deletions terraform/environments/data-platform/iam-policies.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// TODO Scope this down...

data "aws_iam_policy_document" "openmetadata" {
statement {
sid = "openmetadata"
effect = "Allow"
actions = [
"s3:*",
"athena:*",
"glue:*"
]
resources = ["*"]
}
}

module "openmetadata_iam_policy" {
source = "terraform-aws-modules/iam/aws//modules/iam-policy"
version = "~> 5.0"

name_prefix = "openmetadata"

policy = data.aws_iam_policy_document.openmetadata.json

tags = local.tags
}
18 changes: 18 additions & 0 deletions terraform/environments/data-platform/iam-roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module "openmetadata_iam_role" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role"
version = "~> 5.0"

create_role = true

role_name_prefix = "openmetadata"
role_requires_mfa = false

trusted_role_arns = ["arn:aws:iam::${local.environment_configuration.apps_tools_account_id}:root"]

custom_role_policy_arns = [
"arn:aws:iam::aws:policy/service-role/AWSQuicksightAthenaAccess",
module.openmetadata_iam_policy.arn
]

tags = local.tags
}

0 comments on commit e800fdd

Please sign in to comment.