Skip to content
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

PLT-355 switch resource block to data block #96

Merged
merged 9 commits into from
Jul 23, 2024
Merged

Conversation

christopher-maboh
Copy link
Contributor

@christopher-maboh christopher-maboh commented Jun 14, 2024

🎫 Ticket

PLT-355

🛠 Changes

Resource block for access-log removed and data block added to reference access log bucket

ℹ️ Context

Our shared terraform currently creates an access log bucket for each bucket. We've recently hit the 100-bucket limit in the BCDA account (quota increase pending) so there is a reason not to create buckets unnecessarily. A terraform service for an access-log-bucket was created and points all bucket-logging to prefixes within that bucket.

🧪 Validation

terraform ran locally. only error was Error: reading S3 Bucket (bcda-access-logs): couldn't find resource because infra creating access log bucket is yet to be deployed and is being use here as a data block.

all workflows fail due to the fact that the data source being used is yet to be deployed and so terraform can't find centralized bucket

@christopher-maboh christopher-maboh requested a review from a team as a code owner June 14, 2024 20:16
versioning_configuration {
status = "Enabled"
}
data "aws_s3_bucket" "bucket-access_logs" {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data "aws_s3_bucket" "bucket-access_logs" {
data "aws_s3_bucket" "bucket_access_logs" {

terraform/modules/bucket/variables.tf Outdated Show resolved Hide resolved
output "access_log_bucket_arn" {
description = "The ARN of the access log S3 bucket"
value = data.aws_s3_bucket.bucket-access_logs.arn
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need these outputs

target_bucket = aws_s3_bucket.access_logs.id
target_prefix = "log/"
target_bucket = data.aws_s3_bucket.bucket-access_logs.id
target_prefix = "${var.name}/log/"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
target_prefix = "${var.name}/log/"
target_prefix = "${var.name}/"

terraform/modules/function/main.tf Outdated Show resolved Hide resolved
@gsf
Copy link
Member

gsf commented Jul 8, 2024

Looks good! We'll have to get #95 merged and applied before we get good plan checks here.

status = "Enabled"
}
data "aws_s3_bucket" "bucket_access_logs" {
bucket = "${var.app}-${var.env}-bucket-access-log"
Copy link
Member

Choose a reason for hiding this comment

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

With the change suggested in https://github.com/CMSgov/ab2d-bcda-dpc-platform/pull/95/files#r1674341305 we'll be able to drop app and env variables and reference the account ID as we did there.

@@ -145,6 +145,7 @@ module "zip_bucket" {
"arn:aws:iam::${data.aws_ssm_parameter.prod_account[0].value}:role/delegatedadmin/developer/${var.app}-prod-github-actions",
"arn:aws:iam::${data.aws_ssm_parameter.sbx_account[0].value}:role/delegatedadmin/developer/${var.app}-sbx-github-actions",
] : []

Copy link
Member

Choose a reason for hiding this comment

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

Sorry to nit pick but could this blank line addition be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

blank line addition has been removed

Copy link
Member

@gsf gsf 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 monitor the apply jobs

@christopher-maboh christopher-maboh merged commit 6181efb into main Jul 23, 2024
39 checks passed
@christopher-maboh christopher-maboh deleted the PLT-355b branch July 23, 2024 17:19
@gsf gsf changed the title switch resource block to data block PLT-355 switch resource block to data block Jul 23, 2024
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