generated from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
[ELI-688] - Adding Kinesis Data Stream as a buffer for Firehose #609
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
Open
TOEL2
wants to merge
21
commits into
main
Choose a base branch
from
feature/ELI-688-kinesis-stream-buffer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e7dd4da
[ELI-688] - renaming function to generic since it doesn't actually co…
TOEL2 4eae536
[ELI-688] - renaming firehose delivery stream and adding a kinesis cl…
TOEL2 49993b8
[ELI-688] - updating firehose mock config to use kinesis as source
TOEL2 8fbec9e
[ELI-688] - update service to put to kinesis and added a factory to i…
TOEL2 1f23a9e
[ELI-688] - adding a bridge between fake aws clients
TOEL2 df722eb
[ELI-688] - adding a none placeholder to stop wireup complaining
TOEL2 3380d9c
[ELI-688] - updating firehose module and adding new data stream as a …
TOEL2 fa0395c
[ELI-688] - plumbing into lambda
TOEL2 4b7d1b1
[ELI-688] - adding and attaching policies, extending permissions boun…
TOEL2 b151610
[ELI-688] - adding and attaching kms policies
TOEL2 5fa4468
[ELI-688] - clean up and removing server side encryption as incompatible
TOEL2 0fc6e3e
[ELI-688] - adding github perms
TOEL2 959d744
[ELI-688] - adding and attaching kms policy to the stream
TOEL2 c1211b0
[ELI-688] - addressing some initial comments
TOEL2 cf1a135
[ELI-688] - adding a more useful partition key that will split up int…
TOEL2 89dd588
[ELI-688] - formatting
TOEL2 c2c46f8
[ELI-688] - formatting
TOEL2 c07dd85
[ELI-688] - checkov skips
TOEL2 28592fe
[ELI-688] - linting
TOEL2 70b9494
[ELI-688] - slightly tighter security
TOEL2 c26a144
Merge branch 'main' into feature/ELI-688-kinesis-stream-buffer
TOEL2 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
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,97 @@ | ||
| resource "aws_kms_key" "kinesis_data_stream_kms_key" { | ||
| description = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"} kinesis_data_stream_kms Master Key" | ||
| deletion_window_in_days = 14 | ||
| is_enabled = true | ||
| enable_key_rotation = true | ||
| } | ||
|
|
||
| resource "aws_kms_alias" "kinesis_data_stream_kms_key" { | ||
| name = "alias/${var.project_name}-${var.environment}-kinesis-audit-stream" | ||
| target_key_id = aws_kms_key.kinesis_data_stream_kms_key.key_id | ||
| } | ||
|
|
||
|
|
||
| data "aws_iam_policy_document" "kinesis_stream_kms_key_policy" { | ||
| #checkov:skip=CKV_AWS_111 Root user needs full KMS key management | ||
| #checkov:skip=CKV_AWS_109 Root user needs full KMS key management | ||
| #checkov:skip=CKV_AWS_356 Root user needs full KMS key management | ||
| statement { | ||
| sid = "EnableRootPermissions" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] | ||
| } | ||
|
|
||
| actions = ["kms:*"] | ||
| resources = ["*"] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowLambdaUseOfKey" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [aws_iam_role.eligibility_lambda_role.arn] | ||
| } | ||
|
|
||
| actions = [ | ||
| "kms:Encrypt", | ||
| "kms:Decrypt", | ||
| "kms:ReEncrypt*", | ||
| "kms:GenerateDataKey*", | ||
| "kms:DescribeKey" | ||
| ] | ||
|
|
||
| resources = ["*"] | ||
|
|
||
| condition { | ||
| test = "StringEquals" | ||
| variable = "kms:ViaService" | ||
| values = ["kinesis.${var.default_aws_region}.amazonaws.com"] | ||
| } | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowFirehoseRoleUseOfKey" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [aws_iam_role.eligibility_audit_firehose_role.arn] | ||
| } | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey*", | ||
| "kms:DescribeKey" | ||
| ] | ||
|
|
||
| resources = ["*"] | ||
|
|
||
| condition { | ||
| test = "StringEquals" | ||
| variable = "kms:ViaService" | ||
| values = ["firehose.eu-west-2.amazonaws.com"] | ||
| } | ||
| } | ||
| } | ||
|
||
|
|
||
| resource "aws_kms_key_policy" "kinesis_stream_kms_key_policy" { | ||
| key_id = aws_kms_key.kinesis_data_stream_kms_key.id | ||
| policy = data.aws_iam_policy_document.kinesis_stream_kms_key_policy.json | ||
| } | ||
|
|
||
| resource "aws_kinesis_stream" "kinesis_source_stream" { | ||
| name = "${var.project_name}-${var.environment}-kinesis-audit-stream" | ||
| retention_period = 24 | ||
|
|
||
| stream_mode_details { | ||
| stream_mode = "ON_DEMAND" # can discuss later | ||
| } | ||
|
|
||
| encryption_type = "KMS" | ||
| kms_key_id = aws_kms_key.kinesis_data_stream_kms_key.arn | ||
| } | ||
TOEL2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this matters as my plan came back green AND this is not something new I'm doing its already done with the audit_firehose_role