-
Notifications
You must be signed in to change notification settings - Fork 17
BCDA-9874: Initial file_ingestion Implementation (bene-prefs) #1323
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 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ac7d9df
BCDA-9874: Initial Bene Prefs Implementation
mjburling 5bb0089
Merge branch 'main' into bcda-9874
juliareynolds-nava 924316c
Standardize root.tofu.tf for workspaces, ephemera
mjburling 1b1a690
Update bene_prefs arns
mjburling 7544981
Tidy lambda definition
mjburling c804963
Tidy security group
mjburling 77aa8ac
Add queue
mjburling eec6183
Add db lookup
mjburling 2293ee7
Add triggering mechanism
mjburling bc7538f
Tidy locals
mjburling 0e42425
Replace inline policies with managed policies
juliareynolds-nava a6a7be3
Merge branch 'main' into bcda-9874
juliareynolds-nava 4306e92
Update config to standard form
mjburling e2ce961
Convert assume bucket role policy to policy doc
mjburling 76661ec
Convert default_function policy to policy doc
mjburling ceacb9f
Conver managed_policy_arns to policy attachments
mjburling 36de626
Remove TODO
mjburling 99900ab
Use service_prefix in name_prefix
mjburling b8979a6
Add initial README for bene-prefs
mjburling 93cd52e
Ensure parent_env is described
mjburling 4f1589b
Introduce terraservice README
mjburling 9a3a808
append lambda to bucket name pr feedback.
juliareynolds-nava b859618
removed ec2 permissions per PR feedback
juliareynolds-nava 680b9b8
removed fixme annotation.
juliareynolds-nava 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| locals { | ||
| service = "bene-prefs" | ||
|
|
||
| account_id = module.platform.aws_caller_identity.account_id | ||
| kms_key_arn_primary = module.platform.kms_alias_primary.target_key_arn | ||
| kms_key_arn_secondary = module.platform.kms_alias_secondary.target_key_arn | ||
| name_prefix = "${local.app}-${local.env}-${local.service}" | ||
| private_subnets = nonsensitive(toset(keys(module.platform.private_subnets))) | ||
| vpc_id = module.platform.vpc_id | ||
| } | ||
|
|
||
| module "platform" { | ||
| source = "github.com/CMSgov/cdap//terraform/modules/platform?ref=ff2ef539fb06f2c98f0e3ce0c8f922bdacb96d66" | ||
|
|
||
| providers = { aws = aws, aws.secondary = aws.secondary } | ||
|
|
||
| app = local.app | ||
| env = local.env | ||
| root_module = "https://github.com/CMSgov/bcda-app/tree/main/ops/services/10-config" | ||
| service = local.service | ||
| ssm_root_map = { | ||
| bene_prefs = "/bcda/${local.env}/bene_prefs/" | ||
| } | ||
| } | ||
|
|
||
| data "aws_rds_cluster" "this" { | ||
| cluster_identifier = "${local.app}-${local.env}-aurora" | ||
| } | ||
|
|
||
| resource "aws_iam_role" "this" { | ||
| assume_role_policy = jsonencode( | ||
| { | ||
| Statement = [ | ||
| { | ||
| Action = "sts:AssumeRole" | ||
| Effect = "Allow" | ||
| Principal = { | ||
| Service = "lambda.amazonaws.com" | ||
| } | ||
| }, | ||
| { | ||
| Action = [ | ||
| "sts:TagSession", | ||
| "sts:AssumeRoleWithWebIdentity", | ||
| ] | ||
| Condition = { | ||
| StringEquals = { | ||
| "token.actions.githubusercontent.com:aud" = "sts.amazonaws.com" | ||
| } | ||
| StringLike = { | ||
| "token.actions.githubusercontent.com:sub" = "repo:CMSgov/bcda-app:*" | ||
| } | ||
| } | ||
| Effect = "Allow" | ||
| Principal = { | ||
| Federated = "arn:aws:iam::${local.account_id}:oidc-provider/token.actions.githubusercontent.com" | ||
| } | ||
| }, | ||
| { | ||
| Action = [ | ||
| "sts:TagSession", | ||
| "sts:AssumeRole", | ||
| ] | ||
| Effect = "Allow" | ||
| Principal = { | ||
| AWS = [ | ||
| module.platform.kion_roles["ct-ado-dasg-application-admin"].arn, | ||
| module.platform.kion_roles["ct-ado-bcda-application-admin"].arn | ||
| ] | ||
| } | ||
| }, | ||
| ] | ||
| Version = "2012-10-17" | ||
| } | ||
| ) | ||
| force_detach_policies = true | ||
| managed_policy_arns = [] #FIXME: populate with standalone policies that were once in-line | ||
| name = "bcda-${local.env}-${local.service}" | ||
| path = module.platform.iam_defaults.path | ||
| permissions_boundary = module.platform.iam_defaults.boundary | ||
|
|
||
| #FIXME: convert into policy | ||
| inline_policy { | ||
| name = "assume-bucket-role" | ||
| policy = jsonencode( | ||
| { | ||
| Statement = [ | ||
| { | ||
| Action = "sts:AssumeRole" | ||
| Effect = "Allow" | ||
| Resource = module.platform.ssm.bene_prefs.iam_bucket_role_arn.value | ||
| }, | ||
| ] | ||
| Version = "2012-10-17" | ||
| } | ||
| ) | ||
| } | ||
| #FIXME: convert into appropriately scoped policy | ||
| inline_policy { | ||
| name = "default-function" | ||
| policy = jsonencode( | ||
| { | ||
| Statement = [ | ||
| { | ||
| Action = [ | ||
| "ssm:GetParameters", | ||
| "ssm:GetParameter", | ||
| "sqs:ReceiveMessage", | ||
| "sqs:GetQueueAttributes", | ||
| "sqs:DeleteMessage", | ||
| "logs:PutLogEvents", | ||
| "logs:CreateLogStream", | ||
| "logs:CreateLogGroup", | ||
| "ec2:DescribeNetworkInterfaces", | ||
| "ec2:DescribeAccountAttributes", | ||
| "ec2:DeleteNetworkInterface", | ||
| "ec2:CreateNetworkInterface", | ||
| ] | ||
| Effect = "Allow" | ||
| Resource = "*" | ||
| }, | ||
| { | ||
| Action = [ | ||
| "kms:GenerateDataKey", | ||
| "kms:Encrypt", | ||
| "kms:Decrypt", | ||
| ] | ||
| Effect = "Allow" | ||
| Resource = [ | ||
| local.kms_key_arn_primary, | ||
| local.kms_key_arn_secondary | ||
| ] | ||
| }, | ||
| ] | ||
| Version = "2012-10-17" | ||
| } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| module "bucket" { | ||
| source = "github.com/CMSgov/cdap//terraform/modules/bucket?ref=787224b" | ||
|
|
||
| app = local.app | ||
| env = local.env | ||
| name = "${local.app}-${local.env}-${local.service}" | ||
| ssm_parameter = "/${local.app}/${local.env}/${local.service}/nonsensitive/bucket_name" | ||
| } | ||
|
|
||
|
|
||
|
|
||
| resource "aws_lambda_function" "this" { | ||
juliareynolds-nava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| s3_key = "function-6f861e8517dd1cce3731b9a4864d1182f405875e.zip" | ||
| s3_bucket = module.bucket.id | ||
| package_type = "Zip" | ||
| handler = "bootstrap" | ||
|
|
||
| function_name = local.name_prefix | ||
| description = "Ingests the most recent beneficiary opt-out list from BFD" #FIXME | ||
juliareynolds-nava marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| kms_key_arn = local.kms_key_arn_primary | ||
| memory_size = 128 | ||
| reserved_concurrent_executions = 1 | ||
| role = aws_iam_role.this.arn | ||
| runtime = "provided.al2" | ||
| skip_destroy = false | ||
| timeout = 900 | ||
| architectures = [ | ||
| "arm64", | ||
| ] | ||
|
|
||
| tags = { | ||
| code = "https://github.com/CMSgov/cdap/tree/main/terraform/services/opt-out-import" #FIXME | ||
| } | ||
|
|
||
| lifecycle { | ||
| # As of this writing, delivery of the opt-out function is separate from deployment of this module. | ||
| # As such, we must ignore the specific s3_key and s3_object_version configuration. | ||
| ignore_changes = [ | ||
| s3_object_version, | ||
| s3_key | ||
| ] | ||
| } | ||
|
|
||
| environment { | ||
| variables = { | ||
| APP_NAME = local.name_prefix | ||
| DB_HOST = "postgres://${data.aws_rds_cluster.this.endpoint}:${data.aws_rds_cluster.this.port}/bcda" | ||
| ENV = local.env | ||
| } | ||
| } | ||
|
|
||
| ephemeral_storage { | ||
| size = 512 | ||
| } | ||
|
|
||
| logging_config { | ||
| log_format = "Text" | ||
| log_group = "/aws/lambda/bcda-${local.env}-${local.service}" | ||
| } | ||
|
|
||
| tracing_config { | ||
| mode = "Active" | ||
| } | ||
|
|
||
| vpc_config { | ||
| ipv6_allowed_for_dual_stack = false | ||
| security_group_ids = [aws_security_group.this.id] | ||
| subnet_ids = local.private_subnets | ||
| } | ||
| } | ||
|
|
||
| resource "aws_security_group" "this" { #FIXME TODO: Replace with e.g. module.platform.security_groups.egress_only PLT-ASK JULIA | ||
| description = "Temporary SG for ${local.name_prefix}" | ||
| egress = [ | ||
| { | ||
| cidr_blocks = [ | ||
| "0.0.0.0/0", | ||
| ] | ||
| description = "" | ||
| from_port = 0 | ||
| ipv6_cidr_blocks = [ | ||
| "::/0", | ||
| ] | ||
| prefix_list_ids = [] | ||
| protocol = "-1" | ||
| security_groups = [] | ||
| self = false | ||
| to_port = 0 | ||
| }, | ||
| ] | ||
| name = local.name_prefix | ||
| tags = { name = local.name_prefix } | ||
| } | ||
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 @@ | ||
| ../root.tofu.tf |
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.