-
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: Added API Gateway Usage Plan #12542
Conversation
27cbcb3
to
eddab20
Compare
4080496
to
cd6069e
Compare
a842ef2
to
dd7e49e
Compare
dd7e49e
to
aa071ae
Compare
Hi @stack72! Compiled & played a lot with it, adding, removing arguments, replacing data, etc. Gauthier |
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.
Hi @Ninir
Left a few small comments. Apart from that, this LGTM
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSAPIGatewayUsagePlan_' ✭
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/18 12:37:12 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSAPIGatewayUsagePlan_ -timeout 120m
=== RUN TestAccAWSAPIGatewayUsagePlan_importBasic
--- PASS: TestAccAWSAPIGatewayUsagePlan_importBasic (43.59s)
=== RUN TestAccAWSAPIGatewayUsagePlan_basic
--- PASS: TestAccAWSAPIGatewayUsagePlan_basic (97.42s)
=== RUN TestAccAWSAPIGatewayUsagePlan_description
--- PASS: TestAccAWSAPIGatewayUsagePlan_description (149.52s)
=== RUN TestAccAWSAPIGatewayUsagePlan_productCode
--- PASS: TestAccAWSAPIGatewayUsagePlan_productCode (151.22s)
=== RUN TestAccAWSAPIGatewayUsagePlan_throttling
--- PASS: TestAccAWSAPIGatewayUsagePlan_throttling (118.91s)
=== RUN TestAccAWSAPIGatewayUsagePlan_quota
--- PASS: TestAccAWSAPIGatewayUsagePlan_quota (124.36s)
=== RUN TestAccAWSAPIGatewayUsagePlan_apiStages
--- PASS: TestAccAWSAPIGatewayUsagePlan_apiStages (163.00s)
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 848.058s
settings := v.(*schema.Set).List() | ||
q, ok := settings[0].(map[string]interface{}) | ||
|
||
if errors := validateApiGatewayUsagePlanQuotaSettings(q); len(errors) > 0 { |
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.
why validate here rather than pre create?
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 mean setting the ValidateFunc? Well, I need to figure out the combination of 2 fields, and don't know how to proceed better :/
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.
Ok i understand what you mean now - let's leave this as is
|
||
if up.ApiStages != nil { | ||
config := flattenApiGatewayUsageApiStages(up.ApiStages) | ||
d.Set("api_stages", config) |
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'd like us to check that the setting of this to state doesn't throw an error. i.e.
if err := d.Set("api_stages", flattenApiGatewayUsageApiStages(up.ApiStages)); err != nil {
return fmt.Errorf("[DEBUG] Error setting api_stages error: %#v", err)
}
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.
Sure, nice catch, will do!
|
||
if up.Throttle != nil { | ||
config := flattenApiGatewayUsagePlanThrottling(up.Throttle) | ||
d.Set("throttle_settings", config) |
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.
same as above
|
||
if up.Quota != nil { | ||
config := flattenApiGatewayUsagePlanQuota(up.Quota) | ||
d.Set("quota_settings", config) |
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.
same as above
return fmt.Errorf("Error updating API Gateway Usage Plan: %s", err) | ||
} | ||
|
||
d.SetId(*up.Id) |
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 we need to reset the ID 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.
Nope, seems like a leftover, will remove. Thanks for the catch!
@stack72 Hi Paul, Fixed your points. Here are the new acc tests: $ TF_LOG=DEBUG TF_LOG_PATH=terraform.log make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSAPIGatewayUsagePlan_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/18 14:47:55 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSAPIGatewayUsagePlan_ -timeout 120m
=== RUN TestAccAWSAPIGatewayUsagePlan_importBasic
--- PASS: TestAccAWSAPIGatewayUsagePlan_importBasic (26.29s)
=== RUN TestAccAWSAPIGatewayUsagePlan_basic
--- PASS: TestAccAWSAPIGatewayUsagePlan_basic (104.66s)
=== RUN TestAccAWSAPIGatewayUsagePlan_description
--- PASS: TestAccAWSAPIGatewayUsagePlan_description (97.53s)
=== RUN TestAccAWSAPIGatewayUsagePlan_productCode
--- PASS: TestAccAWSAPIGatewayUsagePlan_productCode (88.78s)
=== RUN TestAccAWSAPIGatewayUsagePlan_throttling
--- PASS: TestAccAWSAPIGatewayUsagePlan_throttling (63.81s)
=== RUN TestAccAWSAPIGatewayUsagePlan_quota
--- PASS: TestAccAWSAPIGatewayUsagePlan_quota (63.94s)
=== RUN TestAccAWSAPIGatewayUsagePlan_apiStages
--- PASS: TestAccAWSAPIGatewayUsagePlan_apiStages (84.74s)
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 529.772s Thanks for the review :) |
LGTM now thanks :) |
@Ninir can you ping me on stack72 at hashicorp dot com :) |
* Added api_gateway_usage_plan * Updated documentation * Fixed AWS usage plan review points
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. |
Description
This adds the API Gateway usage plan, based on the following API: https://docs.aws.amazon.com/apigateway/api-reference/resource/usage-plan/
Whereas the creation is made of Go Struct, Update is based on PatchOperations.
The table below is based on the update documentation:
Related issues
#8532
Tests
TODOs