-
Notifications
You must be signed in to change notification settings - Fork 0
[PRMP-1445] Create API Gateway Endpoints, Lambdas, and Alarms for UserRestriction Service #610
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
Merged
Merged
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
62a9015
[PRMP-1444] create user restrictions table
steph-torres-nhs 0ea6364
[PRMP-1444] format
steph-torres-nhs 7f99fe6
[PRMP-1444] fix typo
steph-torres-nhs 380a9a9
[PRMP-1444] add status and creator to restrictions table
steph-torres-nhs 70744db
[PRMP-1444] format
steph-torres-nhs 8e67a9a
[PRMP-1444] add last updated attribute
steph-torres-nhs c5d6666
[PRMP-1444] removed unindexed attributes
steph-torres-nhs 469b5ed
[PRMP-1445] add user restriction gateways
steph-torres-nhs daadf27
[PRPM-1445] add api dependencies
steph-torres-nhs 7f22188
[PRMP-1445] add files
steph-torres-nhs d391d22
[PRMP-1445] add delete user restriction lambda infra
steph-torres-nhs 8da779e
[PRMP-1445] add search user restrictions lambda infra
steph-torres-nhs 015e35e
[PRMP-1445] create search user info lambda infra
steph-torres-nhs 7c2bbd0
[PRMP-1445] remove cycle
steph-torres-nhs ea2a6f7
[PRMP-1445] add missing id
steph-torres-nhs 570ca68
[PRMP-1445] fix typos
steph-torres-nhs c3195e8
[PRMP-1445] fix typo, remove used gateway
steph-torres-nhs fe57e41
Merge branch 'main' into PRMP-1445
steph-torres-nhs ca966a6
Merge branch 'main' into PRMP-1444
steph-torres-nhs c8f4d86
[PRMP-1444] changed ods code attribute to custodian
steph-torres-nhs 3778a57
[PRMP-1444] amend attributes and indexes
steph-torres-nhs dc9dba8
Merge branch 'PRMP-1444' into PRMP-1445
steph-torres-nhs 5f34934
[PRMP-1444] add custodian index order by created
steph-torres-nhs ce644ce
[PRMP-1444] remove unnecessary attributes and indexes
steph-torres-nhs 883ac96
Merge branch 'PRMP-1444' into PRMP-1445
steph-torres-nhs ef133d1
[PRMP-1445] adjust permissions
steph-torres-nhs 95e4c98
[PRMP-1444] address PR comments
steph-torres-nhs a6a501d
Merge branch 'PRMP-1444' into PRMP-1445
steph-torres-nhs ac0e641
Merge branch 'main' into PRMP-1445
steph-torres-nhs bac845c
Merge branch 'main' into PRMP-1445
steph-torres-nhs 22ad842
[PRMP-1445] reorder dependencies
steph-torres-nhs f8012a6
Merge branch 'PRMP-1445' of https://github.com/nhsconnect/national-do…
steph-torres-nhs 09b3b12
Merge branch 'main' into PRMP-1445
steph-torres-nhs c400655
[PRMP-1445] update names
steph-torres-nhs 3f3e881
Merge branch 'PRMP-1445' of https://github.com/nhsconnect/national-do…
steph-torres-nhs 665cdf9
Merge branch 'main' into PRMP-1445
steph-torres-nhs 0f7002d
Merge branch 'main' into PRMP-1445
steph-torres-nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| module "user_restrictions_gateway" { | ||
| source = "./modules/gateway" | ||
| api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id | ||
| http_methods = ["GET", "POST"] | ||
| authorization = "CUSTOM" | ||
| gateway_path = "UserRestriction" | ||
| authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id | ||
| require_credentials = true | ||
| origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'" | ||
| } | ||
|
|
||
| module "user_restriction_id_gateway" { | ||
| source = "./modules/gateway" | ||
| api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| parent_id = module.user_restrictions_gateway.gateway_resource_id | ||
| http_methods = ["DELETE"] | ||
| gateway_path = "{id}" | ||
| authorization = "CUSTOM" | ||
| authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id | ||
| require_credentials = true | ||
| origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'" | ||
|
|
||
| request_parameters = { | ||
| "method.request.path.id" = true | ||
| } | ||
| } | ||
|
|
||
| module "user_restrictions_user_search_gateway" { | ||
| source = "./modules/gateway" | ||
| api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| parent_id = module.user_restrictions_gateway.gateway_resource_id | ||
| http_methods = ["GET"] | ||
| gateway_path = "SearchUser" | ||
| authorization = "CUSTOM" | ||
| authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id | ||
| require_credentials = true | ||
| origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'" | ||
| } |
This file contains hidden or 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,66 @@ | ||
| module "delete_user_restriction_lambda" { | ||
| source = "./modules/lambda" | ||
| name = "DeleteUserRestriction" | ||
| handler = "handlers.delete_user_restriction_handler.lambda_handler" | ||
| iam_role_policy_documents = [ | ||
| module.ndr-app-config.app_config_policy, | ||
| aws_iam_policy.ssm_access_policy.policy, | ||
| module.user_restriction_table.dynamodb_write_policy_document | ||
| ] | ||
| kms_deletion_window = var.kms_deletion_window | ||
| rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| resource_id = module.user_restriction_id_gateway.gateway_resource_id | ||
| http_methods = ["DELETE"] | ||
| api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn | ||
| lambda_environment_variables = { | ||
| APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id | ||
| APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id | ||
| APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id | ||
| WORKSPACE = terraform.workspace | ||
| RESTRICTIONS_TABLE_NAME = module.user_restriction_table.table_name | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_api_gateway_rest_api.ndr_doc_store_api, | ||
| module.user_restriction_id_gateway | ||
| ] | ||
| } | ||
|
|
||
| module "delete_user_restriction_lambda_alarms" { | ||
| source = "./modules/lambda_alarms" | ||
| lambda_function_name = module.delete_user_restriction_lambda.function_name | ||
| lambda_timeout = module.delete_user_restriction_lambda.timeout | ||
| lambda_name = module.delete_user_restriction_lambda.function_name | ||
| namespace = "AWS/Lambda" | ||
| alarm_actions = [module.delete_user_restriction_lambda_alarm_topic.arn] | ||
| ok_actions = [module.delete_user_restriction_lambda_alarm_topic.arn] | ||
| } | ||
|
|
||
| module "delete_user_restriction_lambda_alarm_topic" { | ||
| source = "./modules/sns" | ||
| sns_encryption_key_id = module.sns_encryption_key.id | ||
| topic_name = "delete-user-restriction-lambda-alarm-topic" | ||
| topic_protocol = "email" | ||
| is_topic_endpoint_list = true | ||
| topic_endpoint_list = local.is_sandbox ? [] : nonsensitive(split(",", data.aws_ssm_parameter.cloud_security_notification_email_list.value)) | ||
| delivery_policy = jsonencode({ | ||
| "Version" : "2012-10-17", | ||
| "Statement" : [ | ||
| { | ||
| "Effect" : "Allow", | ||
| "Principal" : { | ||
| "Service" : "cloudwatch.amazonaws.com" | ||
| }, | ||
| "Action" : [ | ||
| "SNS:Publish", | ||
| ], | ||
| "Condition" : { | ||
| "ArnLike" : { | ||
| "aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*" | ||
| } | ||
| } | ||
| "Resource" : "*" | ||
| } | ||
| ] | ||
| }) | ||
| } |
This file contains hidden or 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,66 @@ | ||
| module "post_user_restriction_lambda" { | ||
| source = "./modules/lambda" | ||
| name = "CreateUserRestriction" | ||
| handler = "handlers.create_user_restriction_handler.lambda_handler" | ||
| iam_role_policy_documents = [ | ||
| module.ndr-app-config.app_config_policy, | ||
| aws_iam_policy.ssm_access_policy.policy, | ||
| module.user_restriction_table.dynamodb_write_policy_document | ||
| ] | ||
| kms_deletion_window = var.kms_deletion_window | ||
| rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| resource_id = module.user_restrictions_gateway.gateway_resource_id | ||
| http_methods = ["POST"] | ||
| api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn | ||
| lambda_environment_variables = { | ||
| APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id | ||
| APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id | ||
| APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id | ||
| WORKSPACE = terraform.workspace | ||
| RESTRICTIONS_TABLE_NAME = module.user_restriction_table.table_name | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_api_gateway_rest_api.ndr_doc_store_api, | ||
| module.user_restrictions_gateway | ||
| ] | ||
| } | ||
|
|
||
| module "post_user_restriction_lambda_alarms" { | ||
| source = "./modules/lambda_alarms" | ||
| lambda_function_name = module.post_user_restriction_lambda.function_name | ||
| lambda_timeout = module.post_user_restriction_lambda.timeout | ||
| lambda_name = module.post_user_restriction_lambda.function_name | ||
| namespace = "AWS/Lambda" | ||
| alarm_actions = [module.post_user_restriction_lambda_alarm_topic.arn] | ||
| ok_actions = [module.post_user_restriction_lambda_alarm_topic.arn] | ||
| } | ||
|
|
||
| module "post_user_restriction_lambda_alarm_topic" { | ||
| source = "./modules/sns" | ||
| sns_encryption_key_id = module.sns_encryption_key.id | ||
| topic_name = "post-user-restriction-lambda-alarm-topic" | ||
| topic_protocol = "email" | ||
| is_topic_endpoint_list = true | ||
| topic_endpoint_list = local.is_sandbox ? [] : nonsensitive(split(",", data.aws_ssm_parameter.cloud_security_notification_email_list.value)) | ||
| delivery_policy = jsonencode({ | ||
| "Version" : "2012-10-17", | ||
| "Statement" : [ | ||
| { | ||
| "Effect" : "Allow", | ||
| "Principal" : { | ||
| "Service" : "cloudwatch.amazonaws.com" | ||
| }, | ||
| "Action" : [ | ||
| "SNS:Publish", | ||
| ], | ||
| "Condition" : { | ||
| "ArnLike" : { | ||
| "aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*" | ||
| } | ||
| } | ||
| "Resource" : "*" | ||
| } | ||
| ] | ||
| }) | ||
| } |
This file contains hidden or 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,64 @@ | ||
| module "search_user_information_lambda" { | ||
| source = "./modules/lambda" | ||
| name = "SearchUserInformation" | ||
| handler = "handlers.search_user_information_handler.lambda_handler" | ||
| iam_role_policy_documents = [ | ||
| module.ndr-app-config.app_config_policy, | ||
| aws_iam_policy.ssm_access_policy.policy, | ||
| ] | ||
| kms_deletion_window = var.kms_deletion_window | ||
| rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id | ||
| resource_id = module.user_restrictions_user_search_gateway.gateway_resource_id | ||
| http_methods = ["GET"] | ||
| api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn | ||
| lambda_environment_variables = { | ||
| APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id | ||
| APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id | ||
| APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id | ||
| WORKSPACE = terraform.workspace | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_api_gateway_rest_api.ndr_doc_store_api, | ||
| module.user_restrictions_user_search_gateway | ||
| ] | ||
| } | ||
|
|
||
| module "search_user_information_lambda_alarms" { | ||
| source = "./modules/lambda_alarms" | ||
| lambda_function_name = module.search_user_information_lambda.function_name | ||
| lambda_timeout = module.search_user_information_lambda.timeout | ||
| lambda_name = module.search_user_information_lambda.function_name | ||
| namespace = "AWS/Lambda" | ||
| alarm_actions = [module.search_user_information_lambda_alarm_topic.arn] | ||
| ok_actions = [module.search_user_information_lambda_alarm_topic.arn] | ||
| } | ||
|
|
||
| module "search_user_information_lambda_alarm_topic" { | ||
| source = "./modules/sns" | ||
| sns_encryption_key_id = module.sns_encryption_key.id | ||
| topic_name = "search-user-information-lambda-alarm-topic" | ||
| topic_protocol = "email" | ||
| is_topic_endpoint_list = true | ||
| topic_endpoint_list = local.is_sandbox ? [] : nonsensitive(split(",", data.aws_ssm_parameter.cloud_security_notification_email_list.value)) | ||
| delivery_policy = jsonencode({ | ||
| "Version" : "2012-10-17", | ||
| "Statement" : [ | ||
| { | ||
| "Effect" : "Allow", | ||
| "Principal" : { | ||
| "Service" : "cloudwatch.amazonaws.com" | ||
| }, | ||
| "Action" : [ | ||
| "SNS:Publish", | ||
| ], | ||
| "Condition" : { | ||
| "ArnLike" : { | ||
| "aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*" | ||
| } | ||
| } | ||
| "Resource" : "*" | ||
| } | ||
| ] | ||
| }) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.