Skip to content

Conversation

@Akol125
Copy link
Contributor

@Akol125 Akol125 commented Aug 26, 2025

PR Description
• Created IAM role and policy for EventBridge forwarding to CSOC, and added a csoc_account_id variable per environment in infra.
• Added Shield Advanced subscription in shield_subscription.tf.
• Created Shield protections for:
• NAT Gateway EIP
• Route53 Parent zone
• Route53 Child zone
• Added CloudWatch metric alarms (DDoSDetected) for the above resources.
• Created EventBridge rules and targets to forward alarm state changes to the CSOC Event Bus.

There may be additional resources (e.g. ALB, CloudFront) that could also require protection and alarms, not yet included.

Reviews Required

  • Dev
  • Test
  • Tech Author
  • Product Owner

Review Checklist

ℹ️ This section is to be filled in by the reviewer.

  • I have reviewed the changes in this PR and they fill all or part of the acceptance criteria of the ticket, and the code is in a mergeable state.
  • If there were infrastructure, operational, or build changes, I have made sure there is sufficient evidence that the changes will work.
  • I have ensured the changelog has been updated by the submitter, if necessary.

@github-actions
Copy link
Contributor

This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket:

VED-500

@sonarqubecloud
Copy link

@Akol125 Akol125 requested a review from mfjarvis October 3, 2025 11:40
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}

provider "aws" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it this didn't work with the default provider?

Copy link
Contributor Author

@Akol125 Akol125 Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it mentioned in the conference page that some global resources would not work with eu-west-2 such as Route53, cloudfront etc, Hence the reason why I am using us-east-1. Number two in this confluence link -> shield advance docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it's needed for global resources, but maybe we could put the alternative alias provider in main: https://developer.hashicorp.com/terraform/language/block/provider

# Create all resources to Protect
resource "aws_shield_protection" "nat_eip" {
name = "shield_nat_eip"
resource_arn = "arn:aws:ec2:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:eip-allocation/${aws_eip.example.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_eip.example? Should this be aws_eip.nat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,34 @@
resource "aws_iam_role" "eventbridge_forwarder_role" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used? This is the only change in the terraform folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it isn't, it was a stale file, I forgot to remove, as I initially thought the code would go into terraform service level. Removing now

@@ -0,0 +1,34 @@
resource "aws_iam_role" "eventbridge_forwarder_role" {
name = "${local.short_prefix}-eventbridge-forwarder-role"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no short_prefix in the infra project. We could use imms-${var.environment} instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you Matt, done

Action = "sts:AssumeRole",
Condition = {
StringEquals = {
"aws:SourceAccount" = var.immunisation_account_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be imms_account_id

resource_arn = "arn:aws:ec2:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:eip-allocation/${aws_eip.example.id}"

tags = {
Environment = "imms-${var.environment}-fhir-api-eip-shield"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should go in the name attribute - same for the other aws_shield_protection resources

}
}

locals {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can combine these outer locals blocks

Copy link
Contributor

@dlzhry2nhs dlzhry2nhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Let's do a plan or even apply to dev before we merge it.

Also will need to note that this will need releasing to higher environments from the /infra directory at some point in future.

dlzhry2nhs
dlzhry2nhs previously approved these changes Oct 7, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

@Akol125 Akol125 merged commit fb50f98 into master Oct 8, 2025
7 checks passed
@Akol125 Akol125 deleted the VED-500-Shield-Advanced-Alerts branch October 8, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants