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

Access logs can't be disabled #121

Open
cedric-spinergie opened this issue Sep 30, 2024 · 3 comments
Open

Access logs can't be disabled #121

cedric-spinergie opened this issue Sep 30, 2024 · 3 comments

Comments

@cedric-spinergie
Copy link

cedric-spinergie commented Sep 30, 2024

The issue #115 has been closed too soon, the problem is still present.
As mentioned in #115 (comment), setting stage_access_log_settings = null results in lots of errors:

Logs
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 413, in resource "aws_cloudwatch_log_group" "this":
│  413:   name              = coalesce(each.value.log_group_name, "/aws/apigateway/${var.name}/${replace(var.stage_name, "$", "")}")
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.
╵
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 414, in resource "aws_cloudwatch_log_group" "this":
│  414:   retention_in_days = each.value.log_group_retention_in_days
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.
╵
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 415, in resource "aws_cloudwatch_log_group" "this":
│  415:   kms_key_id        = each.value.log_group_kms_key_id
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.
╵
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 416, in resource "aws_cloudwatch_log_group" "this":
│  416:   skip_destroy      = each.value.log_group_skip_destroy
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.
╵
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 417, in resource "aws_cloudwatch_log_group" "this":
│  417:   log_group_class   = each.value.log_group_class
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.
╵
╷
│ Error: Attempt to get attribute from null value
│ 
│   on .terraform/modules/api_gateway/main.tf line 419, in resource "aws_cloudwatch_log_group" "this":
│  419:   tags = merge(var.tags, each.value.log_group_tags)
│     ├────────────────
│     │ each.value is null
│ 
│ This value is null, so it does not have any attributes.

This line needs to be changed so it doesn't allow creating the resource if the var is null.

In my case, changing the for_each line to add && v != null was enough to fix the problem.

@bryantbiggs
Copy link
Member

this doesn't make sense - why are you trying to set it to null instead of using create_log_group = false?

@cedric-spinergie
Copy link
Author

cedric-spinergie commented Sep 30, 2024

this doesn't make sense - why are you trying to set it to null instead of using create_log_group = false?

@bryantbiggs Hello and thanks for replying!

Both result in a config error here. Setting it to null results in the errors I mentioned in my OP.

And setting it to exactly

  stage_access_log_settings = {
    create_log_group = false
  }

generates errors elsewhere:

│ Error: Missing required argument
│ 
│   with module.api_gateway.aws_apigatewayv2_stage.this[0],
│   on .terraform/modules/api_gateway/main.tf line 321, in resource "aws_apigatewayv2_stage" "this":
│  321: resource "aws_apigatewayv2_stage" "this" {
│ 
│ The argument "access_log_settings.0.destination_arn" is required, but no definition was found.

which is expected because create_XXX = false usually means "I'll manage it myself, use mine" which is not the goal right now.
The goal is to entirely bypass and disable everything related to access logs. In the previous issue (#115), that's also what the OP wanted to achieve.

@cedric-spinergie
Copy link
Author

@bryantbiggs Any feedback on this?

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

No branches or pull requests

2 participants