-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
provider/aws: Add support for api_gateway_method_settings #13542
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, few minor questions
|
||
func resourceAwsApiGatewayMethodSettings() *schema.Resource { | ||
return &schema.Resource{ | ||
Create: resourceAwsApiGatewayMethodSettingsUpdate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no difference between Create
and Update
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no create API method, because the method settings is part of the stage which we're updating. The aws_api_gateway_stage
resource in turn has no notion of method settings so they shouldn't clash in any way.
return nil | ||
} | ||
|
||
d.Set("settings.0.metrics_enabled", settings.MetricsEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think they'll/we'll ever allow more than one settings object at a time? If so, might be worth it to go ahead and write a flatten function here. If not, ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it given the nature of these settings (e.g. on/off logging or monitoring) and even if they do so I think we should keep it as is because the ability to use count
on top level resources allows the user to do all kinds of things they wouldn't be able to do if they worked with "subresources" (multiple settings
blocks nested inside the resource).
ops = append(ops, &apigateway.PatchOperation{ | ||
Op: aws.String("replace"), | ||
Path: aws.String(prefix + "metrics/enabled"), | ||
Value: aws.String(fmt.Sprintf("%t", d.Get("settings.0.metrics_enabled").(bool))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking that Value
needs to be a string
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It surprised me too when I saw that for the first time, but I guess it makes sense if they want to support patching of whole objects (marshalled JSON which is just string), not just primitive data types.
TL;DR: https://github.com/aws/aws-sdk-go/blob/master/service/apigateway/api.go#L17073-L17077
This sort of resource that updates something that already exists rather than creating a new thing can be confusing. I assume there's a reason not to just add these settings into the EDIT: oh, I see. It is for a particular method on a particular stage. |
resource "aws_api_gateway_method_settings" "s" { | ||
rest_api_id = "${aws_api_gateway_rest_api.test.id}" | ||
stage_name = "${aws_api_gateway_stage.test.stage_name}" | ||
method_path = "${aws_api_gateway_resource.test.path_part}/${aws_api_gateway_method.test.http_method}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it seems like this is just being used to construct a prefix for a longer path anyway (and thus method_path
is not a first-class concept in the underlying API?), perhaps it would be better to leave these things separated and combine them in code, thus avoiding the need to explain it below as just "concatenate two things together".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for questioning this - I was actually playing with that idea too! 😄
I'm not completely opposed to 2 fields (e.g. path_part
& method
).
The API allows you to define things like */*
or */GET
and I'm just little bit worried that they might later introduce (or even already support) some kind of special magic syntax which doesn't involve /
and we'd prevent the user from specifying such paths. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.path_part
won't work if the resource has a non-root parent though, right? E.g. /a/b/c
with method on node c
. I tried using resource.path
instead, which contains the fully qualified path, but the leading slash returned in the path was causing the settings to not be applied properly. My solution for the time being looks like:
"${substr("${aws_api_gateway_resource.test.path}/${aws_api_gateway_method.test.http_method}", 1, -1)}"
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Closes #6972
Closes #6612
Test plan