Skip to content

AB2D-7247 Refactor IDR Importer Module#1822

Open
smirnovaae wants to merge 5 commits into
mainfrom
AB2D-7247/refactor_idr_module
Open

AB2D-7247 Refactor IDR Importer Module#1822
smirnovaae wants to merge 5 commits into
mainfrom
AB2D-7247/refactor_idr_module

Conversation

@smirnovaae

Copy link
Copy Markdown
Contributor

🎫 Ticket

https://jira.cms.gov/browse/AB2D-7247

🛠 Changes

  • Moved ab2d_db_user, idr_snowflake_user, and idr_snowflake_role from the environment block to the ECS secrets block, referencing them via valueFrom = instead of value = <...>.value.
  • Removed the nonsensitive(...) wrapper from container_definitions, since no sensitive .value remains inline — restoring Tofu's sensitive-value masking.
  • Non-sensitive params (ab2d_db_database, ab2d_db_host, idr_db_importer_bucket) remain as plain environment values.

ℹ️ Context

We want to refactor the IDR importer module to define secrets outside of the nonsensitive block so that sensitive values like database passwords are not inadvertently exposed during a tofu apply.

🧪 Validation

Task completed successfully

Screenshot 2026-07-07 at 2 20 28 PM

@smirnovaae smirnovaae requested a review from a team as a code owner July 7, 2026 21:20

@mianava mianava left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This importer can be moved to use the service module.

@smirnovaae smirnovaae requested a review from mianava July 8, 2026 17:59
# 30-idr-db-importer terraservice. It has no IAM path, so its ARN is
# constructed here as a string to avoid a reverse cross-state dependency
# (10-core applies before 30-idr-db-importer).
"arn:aws:iam::${local.aws_account_number}:role/${local.service_prefix}-idr-db-importer-task-role"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this for access to an S3 bucket?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this bucket be moved into its service idr-db-importer? I assume it's required for the IDR importer and is not "core"

Comment thread ops/services/30-idr-db-importer/main.tf Outdated
security_groups = [data.aws_security_group.idr_db_importer.id]
subnets = keys(module.platform.private_subnets)

additional_task_role_policies = { s3 = data.aws_iam_policy.idr_db_importer_task.arn }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

where is this policy generated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. It was looking up the policy from 10-core by name, which was more complicated than needed. I moved the policy into 30-idr-db-importer as aws_iam_policy.idr_db_importer_task and now reference it directly.

@smirnovaae smirnovaae requested a review from mianava July 10, 2026 22:07
{ name = "IDR_SNOWFLAKE_PRIVATE_KEY", valueFrom = data.aws_ssm_parameter.idr_private_key[0].arn },
{ name = "IDR_SNOWFLAKE_WAREHOUSE", valueFrom = data.aws_ssm_parameter.idr_snowflake_warehouse[0].arn },
{ name = "IDR_SNOWFLAKE_USER", valueFrom = data.aws_ssm_parameter.idr_snowflake_user[0].arn },
{ name = "IDR_SNOWFLAKE_ROLE", valueFrom = data.aws_ssm_parameter.idr_snowflake_role[0].arn }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these stored in SOPS? If so, use platform module with ssm_root_map

ssm_root_map = { this = "/ab2d/${local.env}/id-db-importer/" }
Ideally, these get stored in a pattern that matches their relevant service (hence "idr-db-importer" is the path because that's how this terraservice has been named)

And then you can use module.platform.ssm.this.snowflake_role.arn

"s3:ListBucket"
]
Resource = [
"arn:aws:s3:::${data.aws_ssm_parameter.idr_db_importer_bucket.value}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommend getting the arn directly https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket -- though I'd favor moving the s3 bucket to be colocated with idr-db-importer as it is critical to this service

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.

2 participants