Terraform v0.11.7
+ provider.aws v1.17.0
Please list the resources as a list, for example:
resource "aws_api_gateway_stage" "example" {
# ... other configuration ...
# new enhancement:
cloudwatch_settings {
enabled = true
log_level = "INFO" # or "ERROR"
log_full_requests = true
enable_detailed_metrics = true
}
}
Semi-related to #2406, but not directly the same thing.
I'm finding the relevant CLI documentation and SDK documentation confusing compared to what the web console provides. The documentation implies settings such as metricsEnabled
and loggingLevel
are only available for individual methods, but I might be misunderstanding, as the web console provides the ability to set these across the whole stage (and individual methods instead are able to override the stage defaults).
The image below from an API Gateway stage in the web console shows in purple what I am referring to in this issue. The green refers to what was added in #2406:
Ohhk, I worked it out!
api_gateway_method_settings
actually _does_ allow you to set these exact settings - and the caching settings - across the entire stage. The key is defining the method_path
as */*
, which is mentioned in the docs - I just missed it because I didn't think this was the place to find it.
I realise these resources completely follow the way the AWS API works, however. My confusion stems I think from the API being defined differently to the web console.
Thank you, I missed that in the docs as well, and came here to ask. Glad you shared. đź‘Ť
Very helpful, I was pulling my hair out till i came across this page. Many thanks.
@tdmalone I am not seeing those getting set, my settings block on api_gateway_method_settings
says this, but I can't get the boxes in the purple set:
settings {
metrics_enabled = true
logging_level = "INFO"
data_trace_enabled = true
}
@joshprocore Is your method_path
set to */*
?
If it already is, I’m afraid I’m not sure what’s going on - API Gateway configuration is particularly messy in general; one idea might be to create the resources in the web console then import them and look for differences in a plan.
I have it set to ${aws_api_gateway_resource.GatewayResource.path_part}/${aws_api_gateway_method.GatewayMethod.http_method}
Should I try */*
? I feel like that would globally change all resource settings right?
EDIT:
Are you certain those checkboxes etc were populated by the tf? like if you destroy and re-add are they still there?
Also it seems odd that gateway_method_settings would change stage settings
If you’re wanting to change it for the whole stage, then yes - that’s what this issue is about. If you’re only wanting to change it for a particular method... then that’s a different question and I’m not too sure what to try (I can’t remember - it’s been a while!)
Ok thanks, seems like I will need to code dive... but... lmk if you come across any epiphanies :)
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Ohhk, I worked it out!
api_gateway_method_settings
actually _does_ allow you to set these exact settings - and the caching settings - across the entire stage. The key is defining themethod_path
as*/*
, which is mentioned in the docs - I just missed it because I didn't think this was the place to find it.I realise these resources completely follow the way the AWS API works, however. My confusion stems I think from the API being defined differently to the web console.