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

r/aws_api_gateway_stage: Support canary release deployment #2793

Conversation

erran
Copy link
Contributor

@erran erran commented Dec 28, 2017

Description

Fix #2727 by adding the new canary_settings argument to api_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:

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

  • Updated docs/r/aws_api_gateway_stage to include the new option/nested options.

Acceptance test run

  • Create canary settings
  • Update canary settings
  • Disable/delete canary settings
    • The overall delete successfully removes these settings but I did not test deleting settings seperately.
make testacc TESTARGS="-run 'TestAccAWSAPIGatewayStage_*'"
==> Checking that code complies with gofmt requirements...              
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run 'TestAccAWSAPIGatewayStage_*' -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
                                                                        
=== RUN   TestAccAWSAPIGatewayStage_basic                               
--- PASS: TestAccAWSAPIGatewayStage_basic (622.91s)                    
PASS                                                                    
ok      github.com/terraform-providers/terraform-provider-aws/aws       631.351s

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.
@jen20 jen20 added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 29, 2017
@bflad bflad added the service/apigateway Issues and PRs that pertain to the apigateway service. label Jan 28, 2018
Copy link
Contributor

@bflad bflad left a 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,
Copy link
Contributor

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")
Copy link
Contributor

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 in canarySettings
  • stage_variable_overrides will always default to an empty map given the existing schema
  • percent_traffic will always default to 0.0 given the existing schema
  • use_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"),
Copy link
Contributor

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 {
Copy link
Contributor

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.
Copy link
Contributor

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 bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Apr 26, 2018
@erran
Copy link
Contributor Author

erran commented May 8, 2018

@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. 😃

@bflad
Copy link
Contributor

bflad commented Oct 9, 2018

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. 😄

@ghost
Copy link

ghost commented Apr 3, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Support Api Gateway Canary release
4 participants