Skip to content

Commit 699e8d0

Browse files
CCM-10241 updating backend-api module refs
1 parent e76fd04 commit 699e8d0

File tree

8 files changed

+43
-36
lines changed

8 files changed

+43
-36
lines changed

infrastructure/terraform/modules/backend-api/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ No requirements.
1313
| <a name="input_cloudfront_distribution_arn"></a> [cloudfront\_distribution\_arn](#input\_cloudfront\_distribution\_arn) | ARN of the cloudfront distribution to serve files from | `string` | `null` | no |
1414
| <a name="input_cognito_config"></a> [cognito\_config](#input\_cognito\_config) | Cognito config | <pre>object({<br/> USER_POOL_ID : string,<br/> USER_POOL_CLIENT_ID : string<br/> })</pre> | n/a | yes |
1515
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | n/a | yes |
16-
| <a name="input_csi"></a> [csi](#input\_csi) | CSI from the parent component | `string` | n/a | yes |
1716
| <a name="input_email_domain"></a> [email\_domain](#input\_email\_domain) | Email domain | `string` | n/a | yes |
1817
| <a name="input_enable_backup"></a> [enable\_backup](#input\_enable\_backup) | Enable Backups for the DynamoDB table? | `bool` | `true` | no |
1918
| <a name="input_enable_event_stream"></a> [enable\_event\_stream](#input\_enable\_event\_stream) | Enable DynamoDB streaming to EventBridge | `bool` | `true` | no |
@@ -25,14 +24,14 @@ No requirements.
2524
| <a name="input_log_destination_arn"></a> [log\_destination\_arn](#input\_log\_destination\_arn) | Destination ARN to use for the log subscription filter | `string` | `""` | no |
2625
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
2726
| <a name="input_log_subscription_role_arn"></a> [log\_subscription\_role\_arn](#input\_log\_subscription\_role\_arn) | The ARN of the IAM role to use for the log subscription filter | `string` | `""` | no |
28-
| <a name="input_module"></a> [module](#input\_module) | The variable encapsulating the name of this module | `string` | `"api"` | no |
29-
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used | `string` | n/a | yes |
3027
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
3128
| <a name="input_proof_requested_sender_email_address"></a> [proof\_requested\_sender\_email\_address](#input\_proof\_requested\_sender\_email\_address) | Proof requested sender email address | `string` | n/a | yes |
3229
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
3330
| <a name="input_send_to_firehose"></a> [send\_to\_firehose](#input\_send\_to\_firehose) | Flag indicating whether logs should be sent to firehose | `bool` | n/a | yes |
3431
| <a name="input_sns_topic_arn"></a> [sns\_topic\_arn](#input\_sns\_topic\_arn) | SNS topic ARN | `string` | `null` | no |
32+
| <a name="input_ssm_parameter_sftp_mock_config_name"></a> [ssm\_parameter\_sftp\_mock\_config\_name](#input\_ssm\_parameter\_sftp\_mock\_config\_name) | SSM Parameter name for the SFTP mock config | `string` | `null` | no |
3533
| <a name="input_template_submitted_sender_email_address"></a> [template\_submitted\_sender\_email\_address](#input\_template\_submitted\_sender\_email\_address) | Template submitted sender email address | `string` | n/a | yes |
34+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID to deploy the backend API into | `string` | n/a | yes |
3635
## Modules
3736

3837
| Name | Source | Version |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "aws_security_group" "account_vpc_sg_allow_sftp_egress" {
2+
name = "${data.aws_vpc.account_vpc.tags["Project"]}-${data.aws_vpc.account_vpc.tags["Environment"]}-acct-sftp-egress"
3+
description = "Security group to allow SFTP egress"
4+
vpc_id = data.aws_vpc.account_vpc.id
5+
}
6+
7+
resource "aws_security_group_rule" "allow_sftp_egress" {
8+
type = "egress"
9+
description = "Allow outbound SFTP"
10+
from_port = 22
11+
to_port = 22
12+
protocol = "tcp"
13+
cidr_blocks = ["0.0.0.0/0"]
14+
security_group_id = aws_security_group.account_vpc_sg_allow_sftp_egress.id
15+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
data "aws_ssm_parameter" "sftp_mock_config_acct" {
22
count = local.use_sftp_letter_supplier_mock ? 1 : 0
3-
name = "/nhs-notify-${var.parent_acct_environment}-acct/sftp-mock-config"
3+
name = var.ssm_parameter_sftp_mock_config_name
44
}
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
data "aws_vpc" "account_vpc" {
2-
tags = {
3-
Component = "acct"
4-
}
2+
id = var.vpc_id
53
}
64

75
data "aws_subnets" "account_vpc_private_subnets" {
@@ -14,11 +12,3 @@ data "aws_subnets" "account_vpc_private_subnets" {
1412
Subnet = "Private"
1513
}
1614
}
17-
18-
data "aws_security_group" "account_vpc_sg_allow_sftp_egress" {
19-
vpc_id = data.aws_vpc.account_vpc.id
20-
21-
tags = {
22-
Name = "${data.aws_vpc.account_vpc.tags["Project"]}-${data.aws_vpc.account_vpc.tags["Environment"]}-acct-sftp-egress"
23-
}
24-
}

infrastructure/terraform/modules/backend-api/locals.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
locals {
2-
csi = "${var.csi}-${var.module}"
2+
module = "backend"
3+
4+
csi = replace(
5+
format(
6+
"%s-%s-%s-%s",
7+
var.project,
8+
var.environment,
9+
var.component,
10+
local.module
11+
),
12+
"_",
13+
"",
14+
)
315

416
lambdas_dir = "../../../../lambdas"
517

618
lambdas_source_code_dir = abspath("${path.module}/${local.lambdas_dir}")
719
pdfjs_layer_zip = abspath("${local.lambdas_source_code_dir}/layers/pdfjs/dist/layer/pdfjs-layer.zip")
820
pdfjs_layer_lockfile = abspath("${local.lambdas_source_code_dir}/layers/pdfjs/package-lock.json")
921

10-
client_ssm_path_prefix = "/${var.csi}/clients"
22+
client_ssm_path_prefix = "/${local.csi}/clients"
1123
client_ssm_path_pattern = "arn:aws:ssm:${var.region}:${var.aws_account_id}:parameter${local.client_ssm_path_prefix}/*"
1224

1325
openapi_spec = templatefile("${path.module}/spec.tmpl.json", {

infrastructure/terraform/modules/backend-api/module_lambda_sftp_poll.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module "lambda_sftp_poll" {
3939

4040
vpc_config = {
4141
subnet_ids = data.aws_subnets.account_vpc_private_subnets.ids
42-
security_group_ids = [data.aws_security_group.account_vpc_sg_allow_sftp_egress.id]
42+
security_group_ids = [aws_security_group.account_vpc_sg_allow_sftp_egress.id]
4343
}
4444

4545
send_to_firehose = var.send_to_firehose

infrastructure/terraform/modules/backend-api/module_lambda_sftp_request_proof.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module "lambda_sftp_request_proof" {
4343

4444
vpc_config = {
4545
subnet_ids = data.aws_subnets.account_vpc_private_subnets.ids
46-
security_group_ids = [data.aws_security_group.account_vpc_sg_allow_sftp_egress.id]
46+
security_group_ids = [aws_security_group.account_vpc_sg_allow_sftp_egress.id]
4747
}
4848

4949
send_to_firehose = var.send_to_firehose

infrastructure/terraform/modules/backend-api/variables.tf

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,21 @@ variable "group" {
3232
description = "The group variables are being inherited from (often synonmous with account short-name)"
3333
}
3434

35-
##
36-
# tfscaffold variables specific to this component
37-
##
38-
39-
variable "module" {
40-
type = string
41-
description = "The variable encapsulating the name of this module"
42-
default = "api"
43-
}
44-
4535
##
4636
# Variables specific to this component
4737
##
4838

49-
variable "csi" {
50-
type = string
51-
description = "CSI from the parent component"
52-
}
53-
5439
variable "log_retention_in_days" {
5540
type = number
5641
description = "The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite"
5742
default = 0
5843
}
5944

45+
variable "vpc_id" {
46+
type = string
47+
description = "The VPC ID to deploy the backend API into"
48+
}
49+
6050
variable "cognito_config" {
6151
type = object({
6252
USER_POOL_ID : string,
@@ -91,9 +81,10 @@ variable "letter_suppliers" {
9181
description = "Letter suppliers enabled in the environment"
9282
}
9383

94-
variable "parent_acct_environment" {
84+
variable "ssm_parameter_sftp_mock_config_name" {
9585
type = string
96-
description = "Name of the environment responsible for the acct resources used"
86+
description = "SSM Parameter name for the SFTP mock config"
87+
default = null
9788
}
9889

9990
variable "cloudfront_distribution_arn" {

0 commit comments

Comments
 (0)