Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRL-846 Use the auth store policy for lambdas #684

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion terraform/account-wide-infrastructure/dev/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ variable "dev_api_domain_name" {
}

variable "devsandbox_api_domain_name" {
description = "The internal DNS name of the API Gateway for the dev environment"
description = "The internal DNS name of the API Gateway for the dev sandbox environment"
default = "dev-sandbox.api.record-locator.dev.national.nhs.uk"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ resource "aws_iam_policy" "read-s3-authorization-store" {
]
Effect = "Allow"
Resource = [
aws_s3_bucket.authorization-store.arn
aws_s3_bucket.authorization-store.arn,
"${aws_s3_bucket.authorization-store.arn}/*",
]
},
]
Expand Down
5 changes: 5 additions & 0 deletions terraform/infrastructure/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ data "aws_s3_bucket" "authorization-store" {
bucket = "${local.shared_prefix}-authorization-store"
}

data "aws_iam_policy" "auth-store-read-policy" {
count = var.use_shared_resources ? 1 : 0
name = "${local.shared_prefix}-read-s3-authorization-store"
}

data "aws_dynamodb_table" "pointers-table" {
count = var.use_shared_resources ? 1 : 0
name = "${local.shared_prefix}-pointers-table"
Expand Down
39 changes: 26 additions & 13 deletions terraform/infrastructure/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module "consumer__readDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -44,7 +45,8 @@ module "consumer__countDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -71,7 +73,8 @@ module "consumer__searchDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -98,7 +101,8 @@ module "consumer__searchPostDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -126,7 +130,8 @@ module "producer__createDocumentReference" {
additional_policies = [
local.pointers_table_write_policy_arn,
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -154,7 +159,8 @@ module "producer__deleteDocumentReference" {
additional_policies = [
local.pointers_table_write_policy_arn,
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -181,7 +187,8 @@ module "producer__readDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -208,7 +215,8 @@ module "producer__searchDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand All @@ -235,7 +243,8 @@ module "producer__searchPostDocumentReference" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -263,7 +272,8 @@ module "producer__updateDocumentReference" {
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_table_write_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -291,7 +301,8 @@ module "producer__upsertDocumentReference" {
additional_policies = [
local.pointers_table_write_policy_arn,
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -319,7 +330,8 @@ module "consumer__status" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down Expand Up @@ -348,7 +360,8 @@ module "producer__status" {
}
additional_policies = [
local.pointers_table_read_policy_arn,
local.pointers_kms_read_write_arn
local.pointers_kms_read_write_arn,
local.auth_store_read_policy_arn
]
firehose_subscriptions = [
module.firehose__processor.firehose_subscription
Expand Down
4 changes: 2 additions & 2 deletions terraform/infrastructure/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ locals {

aws_account_id = data.aws_caller_identity.current.account_id

auth_store_id = var.use_shared_resources ? data.aws_s3_bucket.authorization-store[0].id : module.ephemeral-s3-permission-store[0].bucket_id
auth_store_arn = var.use_shared_resources ? data.aws_s3_bucket.authorization-store[0].arn : module.ephemeral-s3-permission-store[0].bucket_arn
auth_store_id = var.use_shared_resources ? data.aws_s3_bucket.authorization-store[0].id : module.ephemeral-s3-permission-store[0].bucket_id
auth_store_read_policy_arn = var.use_shared_resources ? data.aws_iam_policy.auth-store-read-policy[0].arn : module.ephemeral-s3-permission-store[0].bucket_read_policy_arn

pointers_table_name = var.use_shared_resources ? data.aws_dynamodb_table.pointers-table[0].name : module.ephemeral-pointers-table[0].table_name
pointers_table_read_policy_arn = var.use_shared_resources ? data.aws_iam_policy.pointers-table-read[0].arn : module.ephemeral-pointers-table[0].read_policy_arn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ resource "aws_iam_policy" "read-s3-authorization-store" {
]
Effect = "Allow"
Resource = [
aws_s3_bucket.authorization-store.arn
aws_s3_bucket.authorization-store.arn,
"${aws_s3_bucket.authorization-store.arn}/*",
]
},
]
Expand Down
35 changes: 0 additions & 35 deletions terraform/infrastructure/s3.tf

This file was deleted.