-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
r/aws_api_gateway_stage: Support canary release deployment #2793
r/aws_api_gateway_stage: Support canary release deployment #2793
Conversation
Fix hashicorp#2727 by adding the new `canary_settings` argument to `api_gateway_stage`.
…ary settings This field can be used to attach canary settings to a specific deployment. It defaults to the same as the stage but can change.
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 @erran 👋 Thanks for this contribution and sorry for the delayed review. Can you please see the items below and rebase? Let us know if you have questions or if you do not have time to implement the feedback.
"canary_settings": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
MinItems: 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.
Nitpick: MinItems: 0
is extraneous here 😄
canarySettings := v.([]interface{}) | ||
canarySetting, ok := canarySettings[0].(map[string]interface{}) | ||
if !ok { | ||
return fmt.Errorf("At least one field is expected inside canary_settings") |
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.
We do not need to error check the schema here and the other ones below. It can be confusing to see this code and we can rely on a panic during acceptance testing if a future schema change breaks a reference.
d.GetOk()
will ensure there's an element incanarySettings
stage_variable_overrides
will always default to an empty map given the existing schemapercent_traffic
will always default to 0.0 given the existing schemause_stage_cache
will always default to false given the existing schema
@@ -26,6 +26,9 @@ func TestAccAWSAPIGatewayStage_basic(t *testing.T) { | |||
resource.TestCheckResourceAttr("aws_api_gateway_stage.test", "stage_name", "prod"), | |||
resource.TestCheckResourceAttr("aws_api_gateway_stage.test", "cache_cluster_enabled", "true"), | |||
resource.TestCheckResourceAttr("aws_api_gateway_stage.test", "cache_cluster_size", "0.5"), | |||
resource.TestCheckResourceAttr("aws_api_gateway_stage.test", "canary_settings.0.percent_traffic", "33.33"), |
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.
Can you please move the canary_settings
testing to its own acceptance test(s)/configuration(s) and leave just a simple check in the basic test?
resource.TestCheckResourceAttr("aws_api_gateway_stage.test", "canary_settings.#", "0"),
return nil | ||
} | ||
|
||
for k, v := range canarySettings.StageVariableOverrides { |
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.
The AWS SDK provides a convenience method which can replace this logic: aws.StringValueMap()
|
||
* `percent_traffic` - (Optional) The percent `0.0` - `100.0` of traffic to divert to the canary deployment. | ||
* `stage_variable_overrides` - (Optional) A map of overridden stage `variables` (including new variables) for the canary deployment. | ||
* `use_stage_cache` - (Optional) Whether the canary deployment uses the stage cache. |
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.
We should include Defaults to false
here
@bflad I'll take a stab at finishing up the review feedback this week. I recently moved teams and haven't looked at my open source queue in a few weeks. 😅 I'll respond back here but your comments seem simple enough to address, thank you. 😃 |
Closing this PR due to lack of activity and its non-trivial merge conflicts at this point. We can absolutely revisit this if someone has the desire. 😄 |
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! |
Description
Fix #2727 by adding the new
canary_settings
argument toapi_gateway_stage
. (Initially opened as #2792 after a bad merge/rebase)Motivation
With the release of canary deployments in API gateway I'd like to be able to:
Promote a canary deployment through terraform.I've implemented Create/Update/Delete in this pull request but did not attempt to implement promote, which I think can be accomplished today by promoting through AWS console/CLI then updating config and importing the promoted stage into terraform management.
Documentation
docs/r/aws_api_gateway_stage
to include the new option/nested options.Acceptance test run