From df7825f4e8b34e0d7c361340028e2cb10bbc3314 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 18 Jan 2020 17:54:40 -0500 Subject: [PATCH 01/17] r/aws_appmesh_route: Add support for retry policies. --- aws/resource_aws_appmesh_route.go | 55 ++++++ aws/resource_aws_appmesh_route_test.go | 204 +++++++++++++++++++-- aws/resource_aws_appmesh_test.go | 11 +- aws/structure.go | 54 ++++++ website/docs/r/appmesh_route.html.markdown | 53 ++++++ 5 files changed, 358 insertions(+), 19 deletions(-) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index fba4783b6b32..347cd46c7b36 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -213,6 +213,61 @@ func resourceAwsAppmeshRoute() *schema.Resource { }, }, }, + + "retry_policy": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "http_retry_events": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + + "max_retries": { + Type: schema.TypeInt, + Required: true, + }, + + "per_retry_timeout": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "tcp_retry_events": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + }, + }, + }, }, }, }, diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index 443b30bd0d08..cdcad9e035d3 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -129,8 +129,10 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -152,8 +154,10 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/path"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -196,6 +200,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -214,6 +219,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -247,32 +253,25 @@ func testAccAwsAppmeshRoute_tags(t *testing.T) { Config: testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName, "foo", "bar", "good", "bad"), Check: resource.ComposeTestCheckFunc( testAccCheckAppmeshRouteExists(resourceName, &r), - resource.TestCheckResourceAttr( - resourceName, "tags.%", "2"), - resource.TestCheckResourceAttr( - resourceName, "tags.foo", "bar"), - resource.TestCheckResourceAttr( - resourceName, "tags.good", "bad"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.foo", "bar"), + resource.TestCheckResourceAttr(resourceName, "tags.good", "bad"), ), }, { Config: testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName, "foo2", "bar", "good", "bad2"), Check: resource.ComposeTestCheckFunc( testAccCheckAppmeshRouteExists(resourceName, &r), - resource.TestCheckResourceAttr( - resourceName, "tags.%", "2"), - resource.TestCheckResourceAttr( - resourceName, "tags.foo2", "bar"), - resource.TestCheckResourceAttr( - resourceName, "tags.good", "bad2"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.foo2", "bar"), + resource.TestCheckResourceAttr(resourceName, "tags.good", "bad2"), ), }, { Config: testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rName), Check: resource.ComposeTestCheckFunc( testAccCheckAppmeshRouteExists(resourceName, &r), - resource.TestCheckResourceAttr( - resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, { @@ -318,8 +317,10 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", "POST"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -354,8 +355,10 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", "PUT"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/path"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", "https"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -401,8 +404,10 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "42"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -424,8 +429,98 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "1000"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + ResourceName: resourceName, + ImportStateIdFunc: testAccAwsAppmeshRouteImportStateIdFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { + var r appmesh.RouteData + resourceName := "aws_appmesh_route.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vrName := acctest.RandomWithPrefix("tf-acc-test") + vn1Name := acctest.RandomWithPrefix("tf-acc-test") + vn2Name := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAwsAppmeshRouteConfig_httpRetryPolicy(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.header.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.http_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.http_retry_events.3149296306", "server-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.max_retries", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + Config: testAccAwsAppmeshRouteConfig_httpRetryPolicyUpdated(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.header.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.method", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.http_retry_events.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.http_retry_events.1737003747", "gateway-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.http_retry_events.3092941836", "client-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.max_retries", "3"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), @@ -773,3 +868,84 @@ resource "aws_appmesh_route" "test" { } `, rName, priority) } + +func testAccAwsAppmeshRouteConfig_httpRetryPolicy(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + http_route { + match { + prefix = "/" + } + + retry_policy { + http_retry_events = [ + "server-error", + ] + + max_retries = 1 + + per_retry_timeout { + unit = "s" + value = 15 + } + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} + +func testAccAwsAppmeshRouteConfig_httpRetryPolicyUpdated(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + http_route { + match { + prefix = "/" + } + + retry_policy { + http_retry_events = [ + "client-error", + "gateway-error", + ] + + max_retries = 3 + + per_retry_timeout { + unit = "ms" + value = 250000 + } + + tcp_retry_events = [ + "connection-error", + ] + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index 86bb8a44f762..de167dd34d9b 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -12,11 +12,12 @@ func TestAccAWSAppmesh(t *testing.T) { "tags": testAccAwsAppmeshMesh_tags, }, "Route": { - "httpHeader": testAccAwsAppmeshRoute_httpHeader, - "httpRoute": testAccAwsAppmeshRoute_httpRoute, - "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, - "routePriority": testAccAwsAppmeshRoute_routePriority, - "tags": testAccAwsAppmeshRoute_tags, + "httpHeader": testAccAwsAppmeshRoute_httpHeader, + "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, + "httpRoute": testAccAwsAppmeshRoute_httpRoute, + "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, + "routePriority": testAccAwsAppmeshRoute_routePriority, + "tags": testAccAwsAppmeshRoute_tags, }, "VirtualNode": { "basic": testAccAwsAppmeshVirtualNode_basic, diff --git a/aws/structure.go b/aws/structure.go index 684e142f958d..538b1d50a218 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5461,6 +5461,41 @@ func expandAppmeshRouteSpec(vSpec []interface{}) *appmesh.RouteSpec { spec.HttpRoute.Match = httpRouteMatch } + + if vHttpRetryPolicy, ok := mHttpRoute["retry_policy"].([]interface{}); ok && len(vHttpRetryPolicy) > 0 && vHttpRetryPolicy[0] != nil { + httpRetryPolicy := &appmesh.HttpRetryPolicy{} + + mHttpRetryPolicy := vHttpRetryPolicy[0].(map[string]interface{}) + + if vMaxRetries, ok := mHttpRetryPolicy["max_retries"].(int); ok && vMaxRetries > 0 { + httpRetryPolicy.MaxRetries = aws.Int64(int64(vMaxRetries)) + } + + if vHttpRetryEvents, ok := mHttpRetryPolicy["http_retry_events"].(*schema.Set); ok && vHttpRetryEvents.Len() > 0 { + httpRetryPolicy.HttpRetryEvents = expandStringSet(vHttpRetryEvents) + } + + if vPerRetryTimeout, ok := mHttpRetryPolicy["per_retry_timeout"].([]interface{}); ok && len(vPerRetryTimeout) > 0 && vPerRetryTimeout[0] != nil { + perRetryTimeout := &appmesh.Duration{} + + mPerRetryTimeout := vPerRetryTimeout[0].(map[string]interface{}) + + if vUnit, ok := mPerRetryTimeout["unit"].(string); ok && vUnit != "" { + perRetryTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mPerRetryTimeout["value"].(int); ok && vValue > 0 { + perRetryTimeout.Value = aws.Int64(int64(vValue)) + } + + httpRetryPolicy.PerRetryTimeout = perRetryTimeout + } + + if vTcpRetryEvents, ok := mHttpRetryPolicy["tcp_retry_events"].(*schema.Set); ok && vTcpRetryEvents.Len() > 0 { + httpRetryPolicy.TcpRetryEvents = expandStringSet(vTcpRetryEvents) + } + + spec.HttpRoute.RetryPolicy = httpRetryPolicy + } } if vTcpRoute, ok := mSpec["tcp_route"].([]interface{}); ok && len(vTcpRoute) > 0 && vTcpRoute[0] != nil { @@ -5574,6 +5609,25 @@ func flattenAppmeshRouteSpec(spec *appmesh.RouteSpec) []interface{} { } } + if httpRetryPolicy := httpRoute.RetryPolicy; httpRetryPolicy != nil { + mHttpRetryPolicy := map[string]interface{}{ + "http_retry_events": flattenStringSet(httpRetryPolicy.HttpRetryEvents), + "max_retries": int(aws.Int64Value(httpRetryPolicy.MaxRetries)), + "tcp_retry_events": flattenStringSet(httpRetryPolicy.TcpRetryEvents), + } + + if perRetryTimeout := httpRetryPolicy.PerRetryTimeout; perRetryTimeout != nil { + mPerRetryTimeout := map[string]interface{}{ + "unit": aws.StringValue(perRetryTimeout.Unit), + "value": int(aws.Int64Value(perRetryTimeout.Value)), + } + + mHttpRetryPolicy["per_retry_timeout"] = []interface{}{mPerRetryTimeout} + } + + mHttpRoute["retry_policy"] = []interface{}{mHttpRetryPolicy} + } + mSpec["http_route"] = []interface{}{mHttpRoute} } diff --git a/website/docs/r/appmesh_route.html.markdown b/website/docs/r/appmesh_route.html.markdown index 99792e474370..f6dd997cbbdc 100644 --- a/website/docs/r/appmesh_route.html.markdown +++ b/website/docs/r/appmesh_route.html.markdown @@ -77,6 +77,43 @@ resource "aws_appmesh_route" "serviceb" { } ``` +### Retry Policy + +```hcl +resource "aws_appmesh_route" "serviceb" { + name = "serviceB-route" + mesh_name = "${aws_appmesh_mesh.simple.id}" + virtual_router_name = "${aws_appmesh_virtual_router.serviceb.name}" + + spec { + http_route { + match { + prefix = "/" + } + + retry_policy { + http_retry_events = [ + "server-error", + ] + max_retries = 1 + + per_retry_timeout { + unit = "s" + value = 15 + } + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.serviceb.name}" + weight = 100 + } + } + } + } +} +``` + ### TCP Routing ```hcl @@ -119,6 +156,7 @@ The `http_route` object supports the following: * `action` - (Required) The action to take if a match is determined. * `match` - (Required) The criteria for determining an HTTP request match. +* `retry_policy` - (Optional) The retry policy. The `tcp_route` object supports the following: @@ -137,6 +175,21 @@ This parameter must always start with /, which by itself matches all requests to * `method` - (Optional) The client request header method to match on. Valid values: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`. * `scheme` - (Optional) The client request header scheme to match on. Valid values: `http`, `https`. +The `retry_policy` object supports the following: + +* `http_retry_events` - (Optional) List of HTTP retry events. +Valid values: `client-error` (HTTP status code 409), `gateway-error` (HTTP status codes 502, 503, and 504), `server-error` (HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511), `stream-error` (retry on refused stream). +* `max_retries` - (Required) The maximum number of retries. +* `per_retry_timeout` - (Required) The per-retry timeout. +* `tcp_retry_events` - (Optional) List of TCP retry events. The only valid value is `connection-error`. + +You must specify at least one value for `http_retry_events`, or at least one value for `tcp_retry_events`. + +The `per_retry_timeout` object supports the following: + +* `unit` - (Required) Retry unit. Valid values: `ms`, `s`. +* `value` - (Required) Retry value. + The `weighted_target` object supports the following: * `virtual_node` - (Required) The virtual node to associate with the weighted target. From 6a00f484a62b59c4c4bd4e5c09c3a34a3fb70eef Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 18 Jan 2020 18:36:12 -0500 Subject: [PATCH 02/17] r/aws_appmesh_route: Support gRPC and HTTP/2 services. --- aws/resource_aws_appmesh_route.go | 313 +++++++++- aws/resource_aws_appmesh_route_test.go | 455 +++++++++++++++ aws/resource_aws_appmesh_test.go | 4 +- aws/structure.go | 642 +++++++++++++++------ website/docs/r/appmesh_route.html.markdown | 44 +- 5 files changed, 1243 insertions(+), 215 deletions(-) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index 347cd46c7b36..04e5ee35e9d8 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -55,12 +55,12 @@ func resourceAwsAppmeshRoute() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "http_route": { + "grpc_route": { Type: schema.TypeList, Optional: true, MinItems: 0, MaxItems: 1, - ConflictsWith: []string{"spec.0.tcp_route"}, + ConflictsWith: []string{"spec.0.http2_route", "spec.0.http_route", "spec.0.tcp_route"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "action": { @@ -103,7 +103,7 @@ func resourceAwsAppmeshRoute() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "header": { + "metadata": { Type: schema.TypeSet, Optional: true, MinItems: 0, @@ -177,38 +177,18 @@ func resourceAwsAppmeshRoute() *schema.Resource { }, }, }, - Set: appmeshHttpRouteHeaderHash, + Set: appmeshGrpcRouteMetadataHash, }, - "method": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - appmesh.HttpMethodConnect, - appmesh.HttpMethodDelete, - appmesh.HttpMethodGet, - appmesh.HttpMethodHead, - appmesh.HttpMethodOptions, - appmesh.HttpMethodPatch, - appmesh.HttpMethodPost, - appmesh.HttpMethodPut, - appmesh.HttpMethodTrace, - }, false), - }, - - "prefix": { + "method_name": { Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^/`), "must start with /"), + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 50), }, - "scheme": { + "service_name": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - appmesh.HttpSchemeHttp, - appmesh.HttpSchemeHttps, - }, false), }, }, }, @@ -221,6 +201,14 @@ func resourceAwsAppmeshRoute() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "grpc_retry_events": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + "http_retry_events": { Type: schema.TypeSet, Optional: true, @@ -272,6 +260,18 @@ func resourceAwsAppmeshRoute() *schema.Resource { }, }, + "http2_route": func() *schema.Schema { + schema := appmeshRouteHttpRouteSchema() + schema.ConflictsWith = []string{"spec.0.grpc_route", "spec.0.http_route", "spec.0.tcp_route"} + return schema + }(), + + "http_route": func() *schema.Schema { + schema := appmeshRouteHttpRouteSchema() + schema.ConflictsWith = []string{"spec.0.grpc_route", "spec.0.http2_route", "spec.0.tcp_route"} + return schema + }(), + "priority": { Type: schema.TypeInt, Optional: true, @@ -283,7 +283,7 @@ func resourceAwsAppmeshRoute() *schema.Resource { Optional: true, MinItems: 0, MaxItems: 1, - ConflictsWith: []string{"spec.0.http_route"}, + ConflictsWith: []string{"spec.0.grpc_route", "spec.0.http2_route", "spec.0.http_route"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "action": { @@ -345,6 +345,225 @@ func resourceAwsAppmeshRoute() *schema.Resource { } } +// appmeshRouteHttpRouteSchema returns the schema for `http2_route` and `http_route` attributes. +func appmeshRouteHttpRouteSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "weighted_target": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 10, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "virtual_node": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "weight": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(0, 100), + }, + }, + }, + Set: appmeshWeightedTargetHash, + }, + }, + }, + }, + + "match": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "header": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + MaxItems: 10, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "invert": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "exact": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "prefix": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "range": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "end": { + Type: schema.TypeInt, + Required: true, + }, + + "start": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "regex": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "suffix": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + }, + }, + }, + + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 50), + }, + }, + }, + Set: appmeshHttpRouteHeaderHash, + }, + + "method": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.HttpMethodConnect, + appmesh.HttpMethodDelete, + appmesh.HttpMethodGet, + appmesh.HttpMethodHead, + appmesh.HttpMethodOptions, + appmesh.HttpMethodPatch, + appmesh.HttpMethodPost, + appmesh.HttpMethodPut, + appmesh.HttpMethodTrace, + }, false), + }, + + "prefix": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^/`), "must start with /"), + }, + + "scheme": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.HttpSchemeHttp, + appmesh.HttpSchemeHttps, + }, false), + }, + }, + }, + }, + + "retry_policy": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "http_retry_events": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + + "max_retries": { + Type: schema.TypeInt, + Required: true, + }, + + "per_retry_timeout": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "tcp_retry_events": { + Type: schema.TypeSet, + Optional: true, + MinItems: 0, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + }, + }, + }, + }, + }, + } +} + func resourceAwsAppmeshRouteCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn @@ -494,6 +713,42 @@ func resourceAwsAppmeshRouteImport(d *schema.ResourceData, meta interface{}) ([] return []*schema.ResourceData{d}, nil } +func appmeshGrpcRouteMetadataHash(vGrpcRouteMetadata interface{}) int { + var buf bytes.Buffer + mGrpcRouteMetadata := vGrpcRouteMetadata.(map[string]interface{}) + if v, ok := mGrpcRouteMetadata["invert"].(bool); ok { + buf.WriteString(fmt.Sprintf("%t-", v)) + } + if vMatch, ok := mGrpcRouteMetadata["match"].([]interface{}); ok && len(vMatch) > 0 && vMatch[0] != nil { + mMatch := vMatch[0].(map[string]interface{}) + if v, ok := mMatch["exact"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if v, ok := mMatch["prefix"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if vRange, ok := mMatch["range"].([]interface{}); ok && len(vRange) > 0 && vRange[0] != nil { + mRange := vRange[0].(map[string]interface{}) + if v, ok := mRange["end"].(int); ok { + buf.WriteString(fmt.Sprintf("%d-", v)) + } + if v, ok := mRange["start"].(int); ok { + buf.WriteString(fmt.Sprintf("%d-", v)) + } + } + if v, ok := mMatch["regex"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if v, ok := mMatch["suffix"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + if v, ok := mGrpcRouteMetadata["name"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + return hashcode.String(buf.String()) +} + func appmeshHttpRouteHeaderHash(vHttpRouteHeader interface{}) int { var buf bytes.Buffer mHttpRouteHeader := vHttpRouteHeader.(map[string]interface{}) diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index cdcad9e035d3..de4207081822 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -99,6 +99,225 @@ func testSweepAppmeshRoutes(region string) error { return nil } +func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { + var r appmesh.RouteData + resourceName := "aws_appmesh_route.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vrName := acctest.RandomWithPrefix("tf-acc-test") + vn1Name := acctest.RandomWithPrefix("tf-acc-test") + vn2Name := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAwsAppmeshRouteConfig_grpcRoute(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2366200004.invert", "false"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2366200004.match.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2366200004.name", "X-Testing1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.method_name", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.service_name", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.grpc_retry_events.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.grpc_retry_events.176391714", "deadline-exceeded"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.grpc_retry_events.3889764549", "resource-exhausted"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.http_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.http_retry_events.3149296306", "server-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.max_retries", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + Config: testAccAwsAppmeshRouteConfig_grpcRouteUpdated(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2971741486.invert", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2971741486.match.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.2971741486.name", "X-Testing1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.invert", "false"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.exact", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.prefix", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.range.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.range.0.end", "7"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.range.0.start", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.regex", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.match.0.suffix", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.metadata.3147536248.name", "X-Testing2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.method_name", "test"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.match.0.service_name", "test.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.grpc_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.grpc_retry_events.4193647559", "cancelled"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.http_retry_events.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.http_retry_events.1737003747", "gateway-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.http_retry_events.3092941836", "client-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.max_retries", "3"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + ResourceName: resourceName, + ImportStateIdFunc: testAccAwsAppmeshRouteImportStateIdFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccAwsAppmeshRoute_http2Route(t *testing.T) { + var r appmesh.RouteData + resourceName := "aws_appmesh_route.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vrName := acctest.RandomWithPrefix("tf-acc-test") + vn1Name := acctest.RandomWithPrefix("tf-acc-test") + vn2Name := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAwsAppmeshRouteConfig_http2Route(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2366200004.invert", "false"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2366200004.match.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2366200004.name", "X-Testing1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.method", "POST"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.prefix", "/"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.scheme", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.http_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.http_retry_events.3149296306", "server-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.max_retries", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + Config: testAccAwsAppmeshRouteConfig_http2RouteUpdated(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2971741486.invert", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2971741486.match.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.2971741486.name", "X-Testing1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.invert", "false"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.exact", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.prefix", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.range.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.range.0.end", "7"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.range.0.start", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.regex", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.match.0.suffix", ""), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.header.3147536248.name", "X-Testing2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.method", "PUT"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.prefix", "/path"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.match.0.scheme", "https"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.http_retry_events.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.http_retry_events.1737003747", "gateway-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.http_retry_events.3092941836", "client-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.max_retries", "3"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + ResourceName: resourceName, + ImportStateIdFunc: testAccAwsAppmeshRouteImportStateIdFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { var r appmesh.RouteData resourceName := "aws_appmesh_route.test" @@ -121,6 +340,8 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -146,6 +367,8 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "2"), @@ -195,6 +418,8 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), @@ -214,6 +439,8 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), @@ -306,6 +533,8 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -334,6 +563,8 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -396,6 +627,8 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -421,6 +654,8 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -470,6 +705,8 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -501,6 +738,8 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.0.weighted_target.#", "1"), @@ -635,6 +874,222 @@ resource "aws_appmesh_virtual_node" "bar" { `, meshName, vrName, vn1Name, vn2Name) } +func testAccAwsAppmeshRouteConfig_grpcRoute(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + grpc_route { + match { + metadata { + name = "X-Testing1" + } + } + + retry_policy { + grpc_retry_events = [ + "deadline-exceeded", + "resource-exhausted", + ] + + http_retry_events = [ + "server-error", + ] + + max_retries = 1 + + per_retry_timeout { + unit = "s" + value = 15 + } + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} + +func testAccAwsAppmeshRouteConfig_grpcRouteUpdated(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + grpc_route { + match { + method_name = "test" + service_name = "test.local" + + metadata { + name = "X-Testing1" + invert = true + } + + metadata { + name = "X-Testing2" + invert = false + + match { + range { + start = 2 + end = 7 + } + } + } + } + + retry_policy { + grpc_retry_events = [ + "cancelled", + ] + + http_retry_events = [ + "client-error", + "gateway-error", + ] + + max_retries = 3 + + per_retry_timeout { + unit = "ms" + value = 250000 + } + + tcp_retry_events = [ + "connection-error", + ] + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} + +func testAccAwsAppmeshRouteConfig_http2Route(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + http2_route { + match { + prefix = "/" + method = "POST" + scheme = "http" + + header { + name = "X-Testing1" + } + } + + retry_policy { + http_retry_events = [ + "server-error", + ] + + max_retries = 1 + + per_retry_timeout { + unit = "s" + value = 15 + } + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} + +func testAccAwsAppmeshRouteConfig_http2RouteUpdated(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + http2_route { + match { + prefix = "/path" + method = "PUT" + scheme = "https" + + header { + name = "X-Testing1" + invert = true + } + + header { + name = "X-Testing2" + invert = false + + match { + range { + start = 2 + end = 7 + } + } + } + } + + retry_policy { + http_retry_events = [ + "client-error", + "gateway-error", + ] + + max_retries = 3 + + per_retry_timeout { + unit = "ms" + value = 250000 + } + + tcp_retry_events = [ + "connection-error", + ] + } + + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + } + } +} +`, rName) +} + func testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rName string) string { return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` resource "aws_appmesh_route" "test" { diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index de167dd34d9b..d637b467f316 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -12,11 +12,13 @@ func TestAccAWSAppmesh(t *testing.T) { "tags": testAccAwsAppmeshMesh_tags, }, "Route": { + "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, + "http2Route": testAccAwsAppmeshRoute_http2Route, "httpHeader": testAccAwsAppmeshRoute_httpHeader, "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, "httpRoute": testAccAwsAppmeshRoute_httpRoute, - "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, "routePriority": testAccAwsAppmeshRoute_routePriority, + "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, "tags": testAccAwsAppmeshRoute_tags, }, "VirtualNode": { diff --git a/aws/structure.go b/aws/structure.go index 538b1d50a218..588558d87fa8 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5355,183 +5355,357 @@ func expandAppmeshRouteSpec(vSpec []interface{}) *appmesh.RouteSpec { } mSpec := vSpec[0].(map[string]interface{}) + if vGrpcRoute, ok := mSpec["grpc_route"].([]interface{}); ok { + spec.GrpcRoute = expandAppmeshGrpcRoute(vGrpcRoute) + } + + if vHttp2Route, ok := mSpec["http2_route"].([]interface{}); ok { + spec.Http2Route = expandAppmeshHttpRoute(vHttp2Route) + } + + if vHttpRoute, ok := mSpec["http_route"].([]interface{}); ok { + spec.HttpRoute = expandAppmeshHttpRoute(vHttpRoute) + } + if vPriority, ok := mSpec["priority"].(int); ok && vPriority > 0 { spec.Priority = aws.Int64(int64(vPriority)) } - if vHttpRoute, ok := mSpec["http_route"].([]interface{}); ok && len(vHttpRoute) > 0 && vHttpRoute[0] != nil { - mHttpRoute := vHttpRoute[0].(map[string]interface{}) + if vTcpRoute, ok := mSpec["tcp_route"].([]interface{}); ok { + spec.TcpRoute = expandAppmeshTcpRoute(vTcpRoute) + } - spec.HttpRoute = &appmesh.HttpRoute{} + return spec +} - if vHttpRouteAction, ok := mHttpRoute["action"].([]interface{}); ok && len(vHttpRouteAction) > 0 && vHttpRouteAction[0] != nil { - mHttpRouteAction := vHttpRouteAction[0].(map[string]interface{}) +func expandAppmeshGrpcRoute(vGrpcRoute []interface{}) *appmesh.GrpcRoute { + if len(vGrpcRoute) == 0 || vGrpcRoute[0] == nil { + return nil + } - if vWeightedTargets, ok := mHttpRouteAction["weighted_target"].(*schema.Set); ok && vWeightedTargets.Len() > 0 { - weightedTargets := []*appmesh.WeightedTarget{} + mGrpcRoute := vGrpcRoute[0].(map[string]interface{}) - for _, vWeightedTarget := range vWeightedTargets.List() { - weightedTarget := &appmesh.WeightedTarget{} + grpcRoute := &appmesh.GrpcRoute{} - mWeightedTarget := vWeightedTarget.(map[string]interface{}) + if vGrpcRouteAction, ok := mGrpcRoute["action"].([]interface{}); ok && len(vGrpcRouteAction) > 0 && vGrpcRouteAction[0] != nil { + mGrpcRouteAction := vGrpcRouteAction[0].(map[string]interface{}) - if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { - weightedTarget.VirtualNode = aws.String(vVirtualNode) - } - if vWeight, ok := mWeightedTarget["weight"].(int); ok && vWeight > 0 { - weightedTarget.Weight = aws.Int64(int64(vWeight)) - } + if vWeightedTargets, ok := mGrpcRouteAction["weighted_target"].(*schema.Set); ok && vWeightedTargets.Len() > 0 { + weightedTargets := []*appmesh.WeightedTarget{} - weightedTargets = append(weightedTargets, weightedTarget) - } + for _, vWeightedTarget := range vWeightedTargets.List() { + weightedTarget := &appmesh.WeightedTarget{} + + mWeightedTarget := vWeightedTarget.(map[string]interface{}) - spec.HttpRoute.Action = &appmesh.HttpRouteAction{ - WeightedTargets: weightedTargets, + if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { + weightedTarget.VirtualNode = aws.String(vVirtualNode) } + if vWeight, ok := mWeightedTarget["weight"].(int); ok && vWeight > 0 { + weightedTarget.Weight = aws.Int64(int64(vWeight)) + } + + weightedTargets = append(weightedTargets, weightedTarget) + } + + grpcRoute.Action = &appmesh.GrpcRouteAction{ + WeightedTargets: weightedTargets, } } + } - if vHttpRouteMatch, ok := mHttpRoute["match"].([]interface{}); ok && len(vHttpRouteMatch) > 0 && vHttpRouteMatch[0] != nil { - httpRouteMatch := &appmesh.HttpRouteMatch{} + if vGrpcRouteMatch, ok := mGrpcRoute["match"].([]interface{}); ok && len(vGrpcRouteMatch) > 0 && vGrpcRouteMatch[0] != nil { + grpcRouteMatch := &appmesh.GrpcRouteMatch{} - mHttpRouteMatch := vHttpRouteMatch[0].(map[string]interface{}) + mGrpcRouteMatch := vGrpcRouteMatch[0].(map[string]interface{}) - if vMethod, ok := mHttpRouteMatch["method"].(string); ok && vMethod != "" { - httpRouteMatch.Method = aws.String(vMethod) - } - if vPrefix, ok := mHttpRouteMatch["prefix"].(string); ok && vPrefix != "" { - httpRouteMatch.Prefix = aws.String(vPrefix) - } - if vScheme, ok := mHttpRouteMatch["scheme"].(string); ok && vScheme != "" { - httpRouteMatch.Scheme = aws.String(vScheme) - } + if vMethodName, ok := mGrpcRouteMatch["method_name"].(string); ok && vMethodName != "" { + grpcRouteMatch.MethodName = aws.String(vMethodName) + } + if vServiceName, ok := mGrpcRouteMatch["service_name"].(string); ok && vServiceName != "" { + grpcRouteMatch.ServiceName = aws.String(vServiceName) + } + + if vGrpcRouteMetadatas, ok := mGrpcRouteMatch["metadata"].(*schema.Set); ok && vGrpcRouteMetadatas.Len() > 0 { + grpcRouteMetadatas := []*appmesh.GrpcRouteMetadata{} + + for _, vGrpcRouteMetadata := range vGrpcRouteMetadatas.List() { + grpcRouteMetadata := &appmesh.GrpcRouteMetadata{} - if vHttpRouteHeaders, ok := mHttpRouteMatch["header"].(*schema.Set); ok && vHttpRouteHeaders.Len() > 0 { - httpRouteHeaders := []*appmesh.HttpRouteHeader{} + mGrpcRouteMetadata := vGrpcRouteMetadata.(map[string]interface{}) + + if vInvert, ok := mGrpcRouteMetadata["invert"].(bool); ok { + grpcRouteMetadata.Invert = aws.Bool(vInvert) + } + if vName, ok := mGrpcRouteMetadata["name"].(string); ok && vName != "" { + grpcRouteMetadata.Name = aws.String(vName) + } - for _, vHttpRouteHeader := range vHttpRouteHeaders.List() { - httpRouteHeader := &appmesh.HttpRouteHeader{} + if vMatch, ok := mGrpcRouteMetadata["match"].([]interface{}); ok && len(vMatch) > 0 && vMatch[0] != nil { + grpcRouteMetadata.Match = &appmesh.GrpcRouteMetadataMatchMethod{} - mHttpRouteHeader := vHttpRouteHeader.(map[string]interface{}) + mMatch := vMatch[0].(map[string]interface{}) - if vInvert, ok := mHttpRouteHeader["invert"].(bool); ok { - httpRouteHeader.Invert = aws.Bool(vInvert) + if vExact, ok := mMatch["exact"].(string); ok && vExact != "" { + grpcRouteMetadata.Match.Exact = aws.String(vExact) } - if vName, ok := mHttpRouteHeader["name"].(string); ok && vName != "" { - httpRouteHeader.Name = aws.String(vName) + if vPrefix, ok := mMatch["prefix"].(string); ok && vPrefix != "" { + grpcRouteMetadata.Match.Prefix = aws.String(vPrefix) + } + if vRegex, ok := mMatch["regex"].(string); ok && vRegex != "" { + grpcRouteMetadata.Match.Regex = aws.String(vRegex) + } + if vSuffix, ok := mMatch["suffix"].(string); ok && vSuffix != "" { + grpcRouteMetadata.Match.Suffix = aws.String(vSuffix) } - if vMatch, ok := mHttpRouteHeader["match"].([]interface{}); ok && len(vMatch) > 0 && vMatch[0] != nil { - httpRouteHeader.Match = &appmesh.HeaderMatchMethod{} + if vRange, ok := mMatch["range"].([]interface{}); ok && len(vRange) > 0 && vRange[0] != nil { + grpcRouteMetadata.Match.Range = &appmesh.MatchRange{} - mMatch := vMatch[0].(map[string]interface{}) + mRange := vRange[0].(map[string]interface{}) - if vExact, ok := mMatch["exact"].(string); ok && vExact != "" { - httpRouteHeader.Match.Exact = aws.String(vExact) - } - if vPrefix, ok := mMatch["prefix"].(string); ok && vPrefix != "" { - httpRouteHeader.Match.Prefix = aws.String(vPrefix) + if vEnd, ok := mRange["end"].(int); ok && vEnd > 0 { + grpcRouteMetadata.Match.Range.End = aws.Int64(int64(vEnd)) } - if vRegex, ok := mMatch["regex"].(string); ok && vRegex != "" { - httpRouteHeader.Match.Regex = aws.String(vRegex) - } - if vSuffix, ok := mMatch["suffix"].(string); ok && vSuffix != "" { - httpRouteHeader.Match.Suffix = aws.String(vSuffix) + if vStart, ok := mRange["start"].(int); ok && vStart > 0 { + grpcRouteMetadata.Match.Range.Start = aws.Int64(int64(vStart)) } + } + } - if vRange, ok := mMatch["range"].([]interface{}); ok && len(vRange) > 0 && vRange[0] != nil { - httpRouteHeader.Match.Range = &appmesh.MatchRange{} + grpcRouteMetadatas = append(grpcRouteMetadatas, grpcRouteMetadata) + } - mRange := vRange[0].(map[string]interface{}) + grpcRouteMatch.Metadata = grpcRouteMetadatas + } - if vEnd, ok := mRange["end"].(int); ok && vEnd > 0 { - httpRouteHeader.Match.Range.End = aws.Int64(int64(vEnd)) - } - if vStart, ok := mRange["start"].(int); ok && vStart > 0 { - httpRouteHeader.Match.Range.Start = aws.Int64(int64(vStart)) - } - } - } + grpcRoute.Match = grpcRouteMatch + } - httpRouteHeaders = append(httpRouteHeaders, httpRouteHeader) - } + if vGrpcRetryPolicy, ok := mGrpcRoute["retry_policy"].([]interface{}); ok && len(vGrpcRetryPolicy) > 0 && vGrpcRetryPolicy[0] != nil { + grpcRetryPolicy := &appmesh.GrpcRetryPolicy{} - httpRouteMatch.Headers = httpRouteHeaders - } + mGrpcRetryPolicy := vGrpcRetryPolicy[0].(map[string]interface{}) + + if vMaxRetries, ok := mGrpcRetryPolicy["max_retries"].(int); ok && vMaxRetries > 0 { + grpcRetryPolicy.MaxRetries = aws.Int64(int64(vMaxRetries)) + } - spec.HttpRoute.Match = httpRouteMatch + if vGrpcRetryEvents, ok := mGrpcRetryPolicy["grpc_retry_events"].(*schema.Set); ok && vGrpcRetryEvents.Len() > 0 { + grpcRetryPolicy.GrpcRetryEvents = expandStringSet(vGrpcRetryEvents) } - if vHttpRetryPolicy, ok := mHttpRoute["retry_policy"].([]interface{}); ok && len(vHttpRetryPolicy) > 0 && vHttpRetryPolicy[0] != nil { - httpRetryPolicy := &appmesh.HttpRetryPolicy{} + if vHttpRetryEvents, ok := mGrpcRetryPolicy["http_retry_events"].(*schema.Set); ok && vHttpRetryEvents.Len() > 0 { + grpcRetryPolicy.HttpRetryEvents = expandStringSet(vHttpRetryEvents) + } - mHttpRetryPolicy := vHttpRetryPolicy[0].(map[string]interface{}) + if vPerRetryTimeout, ok := mGrpcRetryPolicy["per_retry_timeout"].([]interface{}); ok && len(vPerRetryTimeout) > 0 && vPerRetryTimeout[0] != nil { + perRetryTimeout := &appmesh.Duration{} - if vMaxRetries, ok := mHttpRetryPolicy["max_retries"].(int); ok && vMaxRetries > 0 { - httpRetryPolicy.MaxRetries = aws.Int64(int64(vMaxRetries)) - } + mPerRetryTimeout := vPerRetryTimeout[0].(map[string]interface{}) - if vHttpRetryEvents, ok := mHttpRetryPolicy["http_retry_events"].(*schema.Set); ok && vHttpRetryEvents.Len() > 0 { - httpRetryPolicy.HttpRetryEvents = expandStringSet(vHttpRetryEvents) + if vUnit, ok := mPerRetryTimeout["unit"].(string); ok && vUnit != "" { + perRetryTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mPerRetryTimeout["value"].(int); ok && vValue > 0 { + perRetryTimeout.Value = aws.Int64(int64(vValue)) } - if vPerRetryTimeout, ok := mHttpRetryPolicy["per_retry_timeout"].([]interface{}); ok && len(vPerRetryTimeout) > 0 && vPerRetryTimeout[0] != nil { - perRetryTimeout := &appmesh.Duration{} + grpcRetryPolicy.PerRetryTimeout = perRetryTimeout + } + + if vTcpRetryEvents, ok := mGrpcRetryPolicy["tcp_retry_events"].(*schema.Set); ok && vTcpRetryEvents.Len() > 0 { + grpcRetryPolicy.TcpRetryEvents = expandStringSet(vTcpRetryEvents) + } + + grpcRoute.RetryPolicy = grpcRetryPolicy + } + + return grpcRoute +} + +func expandAppmeshHttpRoute(vHttpRoute []interface{}) *appmesh.HttpRoute { + if len(vHttpRoute) == 0 || vHttpRoute[0] == nil { + return nil + } + + mHttpRoute := vHttpRoute[0].(map[string]interface{}) + + httpRoute := &appmesh.HttpRoute{} - mPerRetryTimeout := vPerRetryTimeout[0].(map[string]interface{}) + if vHttpRouteAction, ok := mHttpRoute["action"].([]interface{}); ok && len(vHttpRouteAction) > 0 && vHttpRouteAction[0] != nil { + mHttpRouteAction := vHttpRouteAction[0].(map[string]interface{}) - if vUnit, ok := mPerRetryTimeout["unit"].(string); ok && vUnit != "" { - perRetryTimeout.Unit = aws.String(vUnit) + if vWeightedTargets, ok := mHttpRouteAction["weighted_target"].(*schema.Set); ok && vWeightedTargets.Len() > 0 { + weightedTargets := []*appmesh.WeightedTarget{} + + for _, vWeightedTarget := range vWeightedTargets.List() { + weightedTarget := &appmesh.WeightedTarget{} + + mWeightedTarget := vWeightedTarget.(map[string]interface{}) + + if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { + weightedTarget.VirtualNode = aws.String(vVirtualNode) } - if vValue, ok := mPerRetryTimeout["value"].(int); ok && vValue > 0 { - perRetryTimeout.Value = aws.Int64(int64(vValue)) + if vWeight, ok := mWeightedTarget["weight"].(int); ok && vWeight > 0 { + weightedTarget.Weight = aws.Int64(int64(vWeight)) } - httpRetryPolicy.PerRetryTimeout = perRetryTimeout + weightedTargets = append(weightedTargets, weightedTarget) } - if vTcpRetryEvents, ok := mHttpRetryPolicy["tcp_retry_events"].(*schema.Set); ok && vTcpRetryEvents.Len() > 0 { - httpRetryPolicy.TcpRetryEvents = expandStringSet(vTcpRetryEvents) + httpRoute.Action = &appmesh.HttpRouteAction{ + WeightedTargets: weightedTargets, } - - spec.HttpRoute.RetryPolicy = httpRetryPolicy } } - if vTcpRoute, ok := mSpec["tcp_route"].([]interface{}); ok && len(vTcpRoute) > 0 && vTcpRoute[0] != nil { - mTcpRoute := vTcpRoute[0].(map[string]interface{}) + if vHttpRouteMatch, ok := mHttpRoute["match"].([]interface{}); ok && len(vHttpRouteMatch) > 0 && vHttpRouteMatch[0] != nil { + httpRouteMatch := &appmesh.HttpRouteMatch{} + + mHttpRouteMatch := vHttpRouteMatch[0].(map[string]interface{}) + + if vMethod, ok := mHttpRouteMatch["method"].(string); ok && vMethod != "" { + httpRouteMatch.Method = aws.String(vMethod) + } + if vPrefix, ok := mHttpRouteMatch["prefix"].(string); ok && vPrefix != "" { + httpRouteMatch.Prefix = aws.String(vPrefix) + } + if vScheme, ok := mHttpRouteMatch["scheme"].(string); ok && vScheme != "" { + httpRouteMatch.Scheme = aws.String(vScheme) + } - spec.TcpRoute = &appmesh.TcpRoute{} + if vHttpRouteHeaders, ok := mHttpRouteMatch["header"].(*schema.Set); ok && vHttpRouteHeaders.Len() > 0 { + httpRouteHeaders := []*appmesh.HttpRouteHeader{} - if vTcpRouteAction, ok := mTcpRoute["action"].([]interface{}); ok && len(vTcpRouteAction) > 0 && vTcpRouteAction[0] != nil { - mTcpRouteAction := vTcpRouteAction[0].(map[string]interface{}) + for _, vHttpRouteHeader := range vHttpRouteHeaders.List() { + httpRouteHeader := &appmesh.HttpRouteHeader{} - if vWeightedTargets, ok := mTcpRouteAction["weighted_target"].(*schema.Set); ok && vWeightedTargets.Len() > 0 { - weightedTargets := []*appmesh.WeightedTarget{} + mHttpRouteHeader := vHttpRouteHeader.(map[string]interface{}) + + if vInvert, ok := mHttpRouteHeader["invert"].(bool); ok { + httpRouteHeader.Invert = aws.Bool(vInvert) + } + if vName, ok := mHttpRouteHeader["name"].(string); ok && vName != "" { + httpRouteHeader.Name = aws.String(vName) + } - for _, vWeightedTarget := range vWeightedTargets.List() { - weightedTarget := &appmesh.WeightedTarget{} + if vMatch, ok := mHttpRouteHeader["match"].([]interface{}); ok && len(vMatch) > 0 && vMatch[0] != nil { + httpRouteHeader.Match = &appmesh.HeaderMatchMethod{} - mWeightedTarget := vWeightedTarget.(map[string]interface{}) + mMatch := vMatch[0].(map[string]interface{}) - if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { - weightedTarget.VirtualNode = aws.String(vVirtualNode) + if vExact, ok := mMatch["exact"].(string); ok && vExact != "" { + httpRouteHeader.Match.Exact = aws.String(vExact) } - if vWeight, ok := mWeightedTarget["weight"].(int); ok && vWeight > 0 { - weightedTarget.Weight = aws.Int64(int64(vWeight)) + if vPrefix, ok := mMatch["prefix"].(string); ok && vPrefix != "" { + httpRouteHeader.Match.Prefix = aws.String(vPrefix) } + if vRegex, ok := mMatch["regex"].(string); ok && vRegex != "" { + httpRouteHeader.Match.Regex = aws.String(vRegex) + } + if vSuffix, ok := mMatch["suffix"].(string); ok && vSuffix != "" { + httpRouteHeader.Match.Suffix = aws.String(vSuffix) + } + + if vRange, ok := mMatch["range"].([]interface{}); ok && len(vRange) > 0 && vRange[0] != nil { + httpRouteHeader.Match.Range = &appmesh.MatchRange{} - weightedTargets = append(weightedTargets, weightedTarget) + mRange := vRange[0].(map[string]interface{}) + + if vEnd, ok := mRange["end"].(int); ok && vEnd > 0 { + httpRouteHeader.Match.Range.End = aws.Int64(int64(vEnd)) + } + if vStart, ok := mRange["start"].(int); ok && vStart > 0 { + httpRouteHeader.Match.Range.Start = aws.Int64(int64(vStart)) + } + } } - spec.TcpRoute.Action = &appmesh.TcpRouteAction{ - WeightedTargets: weightedTargets, + httpRouteHeaders = append(httpRouteHeaders, httpRouteHeader) + } + + httpRouteMatch.Headers = httpRouteHeaders + } + + httpRoute.Match = httpRouteMatch + } + + if vHttpRetryPolicy, ok := mHttpRoute["retry_policy"].([]interface{}); ok && len(vHttpRetryPolicy) > 0 && vHttpRetryPolicy[0] != nil { + httpRetryPolicy := &appmesh.HttpRetryPolicy{} + + mHttpRetryPolicy := vHttpRetryPolicy[0].(map[string]interface{}) + + if vMaxRetries, ok := mHttpRetryPolicy["max_retries"].(int); ok && vMaxRetries > 0 { + httpRetryPolicy.MaxRetries = aws.Int64(int64(vMaxRetries)) + } + + if vHttpRetryEvents, ok := mHttpRetryPolicy["http_retry_events"].(*schema.Set); ok && vHttpRetryEvents.Len() > 0 { + httpRetryPolicy.HttpRetryEvents = expandStringSet(vHttpRetryEvents) + } + + if vPerRetryTimeout, ok := mHttpRetryPolicy["per_retry_timeout"].([]interface{}); ok && len(vPerRetryTimeout) > 0 && vPerRetryTimeout[0] != nil { + perRetryTimeout := &appmesh.Duration{} + + mPerRetryTimeout := vPerRetryTimeout[0].(map[string]interface{}) + + if vUnit, ok := mPerRetryTimeout["unit"].(string); ok && vUnit != "" { + perRetryTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mPerRetryTimeout["value"].(int); ok && vValue > 0 { + perRetryTimeout.Value = aws.Int64(int64(vValue)) + } + + httpRetryPolicy.PerRetryTimeout = perRetryTimeout + } + + if vTcpRetryEvents, ok := mHttpRetryPolicy["tcp_retry_events"].(*schema.Set); ok && vTcpRetryEvents.Len() > 0 { + httpRetryPolicy.TcpRetryEvents = expandStringSet(vTcpRetryEvents) + } + + httpRoute.RetryPolicy = httpRetryPolicy + } + + return httpRoute +} + +func expandAppmeshTcpRoute(vTcpRoute []interface{}) *appmesh.TcpRoute { + if len(vTcpRoute) == 0 || vTcpRoute[0] == nil { + return nil + } + + mTcpRoute := vTcpRoute[0].(map[string]interface{}) + + tcpRoute := &appmesh.TcpRoute{} + + if vTcpRouteAction, ok := mTcpRoute["action"].([]interface{}); ok && len(vTcpRouteAction) > 0 && vTcpRouteAction[0] != nil { + mTcpRouteAction := vTcpRouteAction[0].(map[string]interface{}) + + if vWeightedTargets, ok := mTcpRouteAction["weighted_target"].(*schema.Set); ok && vWeightedTargets.Len() > 0 { + weightedTargets := []*appmesh.WeightedTarget{} + + for _, vWeightedTarget := range vWeightedTargets.List() { + weightedTarget := &appmesh.WeightedTarget{} + + mWeightedTarget := vWeightedTarget.(map[string]interface{}) + + if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { + weightedTarget.VirtualNode = aws.String(vVirtualNode) + } + if vWeight, ok := mWeightedTarget["weight"].(int); ok && vWeight > 0 { + weightedTarget.Weight = aws.Int64(int64(vWeight)) } + + weightedTargets = append(weightedTargets, weightedTarget) + } + + tcpRoute.Action = &appmesh.TcpRouteAction{ + WeightedTargets: weightedTargets, } } } - return spec + return tcpRoute } func flattenAppmeshRouteSpec(spec *appmesh.RouteSpec) []interface{} { @@ -5540,125 +5714,229 @@ func flattenAppmeshRouteSpec(spec *appmesh.RouteSpec) []interface{} { } mSpec := map[string]interface{}{ - "priority": int(aws.Int64Value(spec.Priority)), + "grpc_route": flattenAppmeshGrpcRoute(spec.GrpcRoute), + "http2_route": flattenAppmeshHttpRoute(spec.Http2Route), + "http_route": flattenAppmeshHttpRoute(spec.HttpRoute), + "priority": int(aws.Int64Value(spec.Priority)), + "tcp_route": flattenAppmeshTcpRoute(spec.TcpRoute), } - if httpRoute := spec.HttpRoute; httpRoute != nil { - mHttpRoute := map[string]interface{}{} + return []interface{}{mSpec} +} + +func flattenAppmeshGrpcRoute(grpcRoute *appmesh.GrpcRoute) []interface{} { + if grpcRoute == nil { + return []interface{}{} + } - if action := httpRoute.Action; action != nil { - if weightedTargets := action.WeightedTargets; weightedTargets != nil { - vWeightedTargets := []interface{}{} + mGrpcRoute := map[string]interface{}{} - for _, weightedTarget := range weightedTargets { - mWeightedTarget := map[string]interface{}{ - "virtual_node": aws.StringValue(weightedTarget.VirtualNode), - "weight": int(aws.Int64Value(weightedTarget.Weight)), - } + if action := grpcRoute.Action; action != nil { + if weightedTargets := action.WeightedTargets; weightedTargets != nil { + vWeightedTargets := []interface{}{} - vWeightedTargets = append(vWeightedTargets, mWeightedTarget) + for _, weightedTarget := range weightedTargets { + mWeightedTarget := map[string]interface{}{ + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + "weight": int(aws.Int64Value(weightedTarget.Weight)), } - mHttpRoute["action"] = []interface{}{ - map[string]interface{}{ - "weighted_target": schema.NewSet(appmeshWeightedTargetHash, vWeightedTargets), - }, - } + vWeightedTargets = append(vWeightedTargets, mWeightedTarget) + } + + mGrpcRoute["action"] = []interface{}{ + map[string]interface{}{ + "weighted_target": schema.NewSet(appmeshWeightedTargetHash, vWeightedTargets), + }, } } + } - if httpRouteMatch := httpRoute.Match; httpRouteMatch != nil { - vHttpRouteHeaders := []interface{}{} + if grpcRouteMatch := grpcRoute.Match; grpcRouteMatch != nil { + vGrpcRouteMetadatas := []interface{}{} - for _, httpRouteHeader := range httpRouteMatch.Headers { - mHttpRouteHeader := map[string]interface{}{ - "invert": aws.BoolValue(httpRouteHeader.Invert), - "name": aws.StringValue(httpRouteHeader.Name), + for _, grpcRouteMetadata := range grpcRouteMatch.Metadata { + mGrpcRouteMetadata := map[string]interface{}{ + "invert": aws.BoolValue(grpcRouteMetadata.Invert), + "name": aws.StringValue(grpcRouteMetadata.Name), + } + + if match := grpcRouteMetadata.Match; match != nil { + mMatch := map[string]interface{}{ + "exact": aws.StringValue(match.Exact), + "prefix": aws.StringValue(match.Prefix), + "regex": aws.StringValue(match.Regex), + "suffix": aws.StringValue(match.Suffix), } - if match := httpRouteHeader.Match; match != nil { - mMatch := map[string]interface{}{ - "exact": aws.StringValue(match.Exact), - "prefix": aws.StringValue(match.Prefix), - "regex": aws.StringValue(match.Regex), - "suffix": aws.StringValue(match.Suffix), + if r := match.Range; r != nil { + mRange := map[string]interface{}{ + "end": int(aws.Int64Value(r.End)), + "start": int(aws.Int64Value(r.Start)), } - if r := match.Range; r != nil { - mRange := map[string]interface{}{ - "end": int(aws.Int64Value(r.End)), - "start": int(aws.Int64Value(r.Start)), - } + mMatch["range"] = []interface{}{mRange} + } - mMatch["range"] = []interface{}{mRange} - } + mGrpcRouteMetadata["match"] = []interface{}{mMatch} + } - mHttpRouteHeader["match"] = []interface{}{mMatch} + vGrpcRouteMetadatas = append(vGrpcRouteMetadatas, mGrpcRouteMetadata) + } + + mGrpcRoute["match"] = []interface{}{ + map[string]interface{}{ + "metadata": schema.NewSet(appmeshGrpcRouteMetadataHash, vGrpcRouteMetadatas), + "method_name": aws.StringValue(grpcRouteMatch.MethodName), + "service_name": aws.StringValue(grpcRouteMatch.ServiceName), + }, + } + } + + if grpcRetryPolicy := grpcRoute.RetryPolicy; grpcRetryPolicy != nil { + mGrpcRetryPolicy := map[string]interface{}{ + "grpc_retry_events": flattenStringSet(grpcRetryPolicy.GrpcRetryEvents), + "http_retry_events": flattenStringSet(grpcRetryPolicy.HttpRetryEvents), + "max_retries": int(aws.Int64Value(grpcRetryPolicy.MaxRetries)), + "tcp_retry_events": flattenStringSet(grpcRetryPolicy.TcpRetryEvents), + } + + if perRetryTimeout := grpcRetryPolicy.PerRetryTimeout; perRetryTimeout != nil { + mPerRetryTimeout := map[string]interface{}{ + "unit": aws.StringValue(perRetryTimeout.Unit), + "value": int(aws.Int64Value(perRetryTimeout.Value)), + } + + mGrpcRetryPolicy["per_retry_timeout"] = []interface{}{mPerRetryTimeout} + } + + mGrpcRoute["retry_policy"] = []interface{}{mGrpcRetryPolicy} + } + + return []interface{}{mGrpcRoute} +} + +func flattenAppmeshHttpRoute(httpRoute *appmesh.HttpRoute) []interface{} { + if httpRoute == nil { + return []interface{}{} + } + + mHttpRoute := map[string]interface{}{} + + if action := httpRoute.Action; action != nil { + if weightedTargets := action.WeightedTargets; weightedTargets != nil { + vWeightedTargets := []interface{}{} + + for _, weightedTarget := range weightedTargets { + mWeightedTarget := map[string]interface{}{ + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + "weight": int(aws.Int64Value(weightedTarget.Weight)), } - vHttpRouteHeaders = append(vHttpRouteHeaders, mHttpRouteHeader) + vWeightedTargets = append(vWeightedTargets, mWeightedTarget) } - mHttpRoute["match"] = []interface{}{ + mHttpRoute["action"] = []interface{}{ map[string]interface{}{ - "header": schema.NewSet(appmeshHttpRouteHeaderHash, vHttpRouteHeaders), - "method": aws.StringValue(httpRouteMatch.Method), - "prefix": aws.StringValue(httpRouteMatch.Prefix), - "scheme": aws.StringValue(httpRouteMatch.Scheme), + "weighted_target": schema.NewSet(appmeshWeightedTargetHash, vWeightedTargets), }, } } + } + + if httpRouteMatch := httpRoute.Match; httpRouteMatch != nil { + vHttpRouteHeaders := []interface{}{} - if httpRetryPolicy := httpRoute.RetryPolicy; httpRetryPolicy != nil { - mHttpRetryPolicy := map[string]interface{}{ - "http_retry_events": flattenStringSet(httpRetryPolicy.HttpRetryEvents), - "max_retries": int(aws.Int64Value(httpRetryPolicy.MaxRetries)), - "tcp_retry_events": flattenStringSet(httpRetryPolicy.TcpRetryEvents), + for _, httpRouteHeader := range httpRouteMatch.Headers { + mHttpRouteHeader := map[string]interface{}{ + "invert": aws.BoolValue(httpRouteHeader.Invert), + "name": aws.StringValue(httpRouteHeader.Name), } - if perRetryTimeout := httpRetryPolicy.PerRetryTimeout; perRetryTimeout != nil { - mPerRetryTimeout := map[string]interface{}{ - "unit": aws.StringValue(perRetryTimeout.Unit), - "value": int(aws.Int64Value(perRetryTimeout.Value)), + if match := httpRouteHeader.Match; match != nil { + mMatch := map[string]interface{}{ + "exact": aws.StringValue(match.Exact), + "prefix": aws.StringValue(match.Prefix), + "regex": aws.StringValue(match.Regex), + "suffix": aws.StringValue(match.Suffix), } - mHttpRetryPolicy["per_retry_timeout"] = []interface{}{mPerRetryTimeout} + if r := match.Range; r != nil { + mRange := map[string]interface{}{ + "end": int(aws.Int64Value(r.End)), + "start": int(aws.Int64Value(r.Start)), + } + + mMatch["range"] = []interface{}{mRange} + } + + mHttpRouteHeader["match"] = []interface{}{mMatch} } - mHttpRoute["retry_policy"] = []interface{}{mHttpRetryPolicy} + vHttpRouteHeaders = append(vHttpRouteHeaders, mHttpRouteHeader) } - mSpec["http_route"] = []interface{}{mHttpRoute} + mHttpRoute["match"] = []interface{}{ + map[string]interface{}{ + "header": schema.NewSet(appmeshHttpRouteHeaderHash, vHttpRouteHeaders), + "method": aws.StringValue(httpRouteMatch.Method), + "prefix": aws.StringValue(httpRouteMatch.Prefix), + "scheme": aws.StringValue(httpRouteMatch.Scheme), + }, + } } - if tcpRoute := spec.TcpRoute; tcpRoute != nil { - mTcpRoute := map[string]interface{}{} + if httpRetryPolicy := httpRoute.RetryPolicy; httpRetryPolicy != nil { + mHttpRetryPolicy := map[string]interface{}{ + "http_retry_events": flattenStringSet(httpRetryPolicy.HttpRetryEvents), + "max_retries": int(aws.Int64Value(httpRetryPolicy.MaxRetries)), + "tcp_retry_events": flattenStringSet(httpRetryPolicy.TcpRetryEvents), + } - if action := tcpRoute.Action; action != nil { - if weightedTargets := action.WeightedTargets; weightedTargets != nil { - vWeightedTargets := []interface{}{} + if perRetryTimeout := httpRetryPolicy.PerRetryTimeout; perRetryTimeout != nil { + mPerRetryTimeout := map[string]interface{}{ + "unit": aws.StringValue(perRetryTimeout.Unit), + "value": int(aws.Int64Value(perRetryTimeout.Value)), + } - for _, weightedTarget := range weightedTargets { - mWeightedTarget := map[string]interface{}{ - "virtual_node": aws.StringValue(weightedTarget.VirtualNode), - "weight": int(aws.Int64Value(weightedTarget.Weight)), - } + mHttpRetryPolicy["per_retry_timeout"] = []interface{}{mPerRetryTimeout} + } - vWeightedTargets = append(vWeightedTargets, mWeightedTarget) - } + mHttpRoute["retry_policy"] = []interface{}{mHttpRetryPolicy} + } - mTcpRoute["action"] = []interface{}{ - map[string]interface{}{ - "weighted_target": schema.NewSet(appmeshWeightedTargetHash, vWeightedTargets), - }, + return []interface{}{mHttpRoute} +} + +func flattenAppmeshTcpRoute(tcpRoute *appmesh.TcpRoute) []interface{} { + if tcpRoute == nil { + return []interface{}{} + } + + mTcpRoute := map[string]interface{}{} + + if action := tcpRoute.Action; action != nil { + if weightedTargets := action.WeightedTargets; weightedTargets != nil { + vWeightedTargets := []interface{}{} + + for _, weightedTarget := range weightedTargets { + mWeightedTarget := map[string]interface{}{ + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + "weight": int(aws.Int64Value(weightedTarget.Weight)), } + + vWeightedTargets = append(vWeightedTargets, mWeightedTarget) } - } - mSpec["tcp_route"] = []interface{}{mTcpRoute} + mTcpRoute["action"] = []interface{}{ + map[string]interface{}{ + "weighted_target": schema.NewSet(appmeshWeightedTargetHash, vWeightedTargets), + }, + } + } } - return []interface{}{mSpec} + return []interface{}{mTcpRoute} } func flattenAppsyncPipelineConfig(c *appsync.PipelineConfig) []interface{} { diff --git a/website/docs/r/appmesh_route.html.markdown b/website/docs/r/appmesh_route.html.markdown index f6dd997cbbdc..9a53952b26b9 100644 --- a/website/docs/r/appmesh_route.html.markdown +++ b/website/docs/r/appmesh_route.html.markdown @@ -147,12 +147,20 @@ The following arguments are supported: The `spec` object supports the following: +* `grpc_route` - (Optional) The gRPC routing information for the route. +* `http2_route` - (Optional) The HTTP/2 routing information for the route. * `http_route` - (Optional) The HTTP routing information for the route. * `priority` - (Optional) The priority for the route, between `0` and `1000`. Routes are matched based on the specified value, where `0` is the highest priority. * `tcp_route` - (Optional) The TCP routing information for the route. -The `http_route` object supports the following: +The `grpc_route` object supports the following: + +* `action` - (Required) The action to take if a match is determined. +* `match` - (Required) The criteria for determining an gRPC request match. +* `rety_policy` - (Optional) The retry policy. + +The `http2_route` and `http_route` objects supports the following: * `action` - (Required) The action to take if a match is determined. * `match` - (Required) The criteria for determining an HTTP request match. @@ -167,7 +175,37 @@ The `action` object supports the following: * `weighted_target` - (Required) The targets that traffic is routed to when a request matches the route. You can specify one or more targets and their relative weights with which to distribute traffic. -The `http_route`'s `match` object supports the following: +The `grpc_route`'s `match` object supports the following: + +* `metadata` - (Optional) The data to match from the gRPC request. +* `method_name` - (Optional) The method name to match from the request. If you specify a name, you must also specify a `service_name`. +* `service_name` - (Optional) The fully qualified domain name for the service to match from the request. + +The `metadata` object supports the following: + +* `name` - (Required) The name of the route. +* `invert` - (Optional) If `true`, the match is on the opposite of the `match` criteria. Default is `false`. +* `match` - (Optional) The data to match from the request. + +The `metadata`'s `match` object supports the following: + +* `exact` - (Optional) The value sent by the client must match the specified value exactly. +* `prefix` - (Optional) The value sent by the client must begin with the specified characters. +* `range`- (Optional) The object that specifies the range of numbers that the value sent by the client must be included in. +* `regex` - (Optional) The value sent by the client must include the specified characters. +* `suffix` - (Optional) The value sent by the client must end with the specified characters. + +The `grpc_route`'s `retry_policy` object supports the following: + +* `grpc_retry_events` - (Optional) List of gRPC retry events. +Valid values: `cancelled`, `deadline-exceeded`, `internal`, `resource-exhausted`, `unavailable`. +* `http_retry_events` - (Optional) List of HTTP retry events. +Valid values: `client-error` (HTTP status code 409), `gateway-error` (HTTP status codes 502, 503, and 504), `server-error` (HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511), `stream-error` (retry on refused stream). +* `max_retries` - (Required) The maximum number of retries. +* `per_retry_timeout` - (Required) The per-retry timeout. +* `tcp_retry_events` - (Optional) List of TCP retry events. The only valid value is `connection-error`. + +The `http2_route` and `http_route`'s `match` object supports the following: * `prefix` - (Required) Specifies the path with which to match requests. This parameter must always start with /, which by itself matches all requests to the virtual router service name. @@ -175,7 +213,7 @@ This parameter must always start with /, which by itself matches all requests to * `method` - (Optional) The client request header method to match on. Valid values: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`. * `scheme` - (Optional) The client request header scheme to match on. Valid values: `http`, `https`. -The `retry_policy` object supports the following: +The `http2_route` and `http_route`'s `retry_policy` object supports the following: * `http_retry_events` - (Optional) List of HTTP retry events. Valid values: `client-error` (HTTP status code 409), `gateway-error` (HTTP status codes 502, 503, and 504), `server-error` (HTTP status codes 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, and 511), `stream-error` (retry on refused stream). From da1316e1ec857709eda85ca36dd84c7690815576 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 1 Feb 2020 18:04:30 -0500 Subject: [PATCH 03/17] Add App Mesh Preview service from https://github.com/ewbankkit/aws-sdk-go/tree/appmesh-preview-01-2020. --- .../aws-sdk-go/service/appmeshpreview/api.go | 9089 +++++++++++++++++ .../appmeshpreviewiface/interface.go | 164 + .../aws-sdk-go/service/appmeshpreview/doc.go | 26 + .../service/appmeshpreview/errors.go | 58 + .../service/appmeshpreview/service.go | 104 + 5 files changed, 9441 insertions(+) create mode 100644 vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/api.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/appmeshpreviewiface/interface.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/doc.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/errors.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/service.go diff --git a/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/api.go b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/api.go new file mode 100644 index 000000000000..e4a61beee2e0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/api.go @@ -0,0 +1,9089 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package appmeshpreview + +import ( + "fmt" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol" +) + +const opCreateMesh = "CreateMesh" + +// CreateMeshRequest generates a "aws/request.Request" representing the +// client's request for the CreateMesh operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateMesh for more information on using the CreateMesh +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateMeshRequest method. +// req, resp := client.CreateMeshRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateMesh +func (c *AppMeshPreview) CreateMeshRequest(input *CreateMeshInput) (req *request.Request, output *CreateMeshOutput) { + op := &request.Operation{ + Name: opCreateMesh, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes", + } + + if input == nil { + input = &CreateMeshInput{} + } + + output = &CreateMeshOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateMesh API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation CreateMesh for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateMesh +func (c *AppMeshPreview) CreateMesh(input *CreateMeshInput) (*CreateMeshOutput, error) { + req, out := c.CreateMeshRequest(input) + return out, req.Send() +} + +// CreateMeshWithContext is the same as CreateMesh with the addition of +// the ability to pass a context and additional request options. +// +// See CreateMesh for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) CreateMeshWithContext(ctx aws.Context, input *CreateMeshInput, opts ...request.Option) (*CreateMeshOutput, error) { + req, out := c.CreateMeshRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateRoute = "CreateRoute" + +// CreateRouteRequest generates a "aws/request.Request" representing the +// client's request for the CreateRoute operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateRoute for more information on using the CreateRoute +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateRouteRequest method. +// req, resp := client.CreateRouteRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateRoute +func (c *AppMeshPreview) CreateRouteRequest(input *CreateRouteInput) (req *request.Request, output *CreateRouteOutput) { + op := &request.Operation{ + Name: opCreateRoute, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouter/{virtualRouterName}/routes", + } + + if input == nil { + input = &CreateRouteInput{} + } + + output = &CreateRouteOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateRoute API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation CreateRoute for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateRoute +func (c *AppMeshPreview) CreateRoute(input *CreateRouteInput) (*CreateRouteOutput, error) { + req, out := c.CreateRouteRequest(input) + return out, req.Send() +} + +// CreateRouteWithContext is the same as CreateRoute with the addition of +// the ability to pass a context and additional request options. +// +// See CreateRoute for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) CreateRouteWithContext(ctx aws.Context, input *CreateRouteInput, opts ...request.Option) (*CreateRouteOutput, error) { + req, out := c.CreateRouteRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateVirtualNode = "CreateVirtualNode" + +// CreateVirtualNodeRequest generates a "aws/request.Request" representing the +// client's request for the CreateVirtualNode operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateVirtualNode for more information on using the CreateVirtualNode +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateVirtualNodeRequest method. +// req, resp := client.CreateVirtualNodeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualNode +func (c *AppMeshPreview) CreateVirtualNodeRequest(input *CreateVirtualNodeInput) (req *request.Request, output *CreateVirtualNodeOutput) { + op := &request.Operation{ + Name: opCreateVirtualNode, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualNodes", + } + + if input == nil { + input = &CreateVirtualNodeInput{} + } + + output = &CreateVirtualNodeOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateVirtualNode API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation CreateVirtualNode for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualNode +func (c *AppMeshPreview) CreateVirtualNode(input *CreateVirtualNodeInput) (*CreateVirtualNodeOutput, error) { + req, out := c.CreateVirtualNodeRequest(input) + return out, req.Send() +} + +// CreateVirtualNodeWithContext is the same as CreateVirtualNode with the addition of +// the ability to pass a context and additional request options. +// +// See CreateVirtualNode for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) CreateVirtualNodeWithContext(ctx aws.Context, input *CreateVirtualNodeInput, opts ...request.Option) (*CreateVirtualNodeOutput, error) { + req, out := c.CreateVirtualNodeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateVirtualRouter = "CreateVirtualRouter" + +// CreateVirtualRouterRequest generates a "aws/request.Request" representing the +// client's request for the CreateVirtualRouter operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateVirtualRouter for more information on using the CreateVirtualRouter +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateVirtualRouterRequest method. +// req, resp := client.CreateVirtualRouterRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualRouter +func (c *AppMeshPreview) CreateVirtualRouterRequest(input *CreateVirtualRouterInput) (req *request.Request, output *CreateVirtualRouterOutput) { + op := &request.Operation{ + Name: opCreateVirtualRouter, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouters", + } + + if input == nil { + input = &CreateVirtualRouterInput{} + } + + output = &CreateVirtualRouterOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateVirtualRouter API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation CreateVirtualRouter for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualRouter +func (c *AppMeshPreview) CreateVirtualRouter(input *CreateVirtualRouterInput) (*CreateVirtualRouterOutput, error) { + req, out := c.CreateVirtualRouterRequest(input) + return out, req.Send() +} + +// CreateVirtualRouterWithContext is the same as CreateVirtualRouter with the addition of +// the ability to pass a context and additional request options. +// +// See CreateVirtualRouter for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) CreateVirtualRouterWithContext(ctx aws.Context, input *CreateVirtualRouterInput, opts ...request.Option) (*CreateVirtualRouterOutput, error) { + req, out := c.CreateVirtualRouterRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateVirtualService = "CreateVirtualService" + +// CreateVirtualServiceRequest generates a "aws/request.Request" representing the +// client's request for the CreateVirtualService operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateVirtualService for more information on using the CreateVirtualService +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateVirtualServiceRequest method. +// req, resp := client.CreateVirtualServiceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualService +func (c *AppMeshPreview) CreateVirtualServiceRequest(input *CreateVirtualServiceInput) (req *request.Request, output *CreateVirtualServiceOutput) { + op := &request.Operation{ + Name: opCreateVirtualService, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualServices", + } + + if input == nil { + input = &CreateVirtualServiceInput{} + } + + output = &CreateVirtualServiceOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateVirtualService API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation CreateVirtualService for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/CreateVirtualService +func (c *AppMeshPreview) CreateVirtualService(input *CreateVirtualServiceInput) (*CreateVirtualServiceOutput, error) { + req, out := c.CreateVirtualServiceRequest(input) + return out, req.Send() +} + +// CreateVirtualServiceWithContext is the same as CreateVirtualService with the addition of +// the ability to pass a context and additional request options. +// +// See CreateVirtualService for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) CreateVirtualServiceWithContext(ctx aws.Context, input *CreateVirtualServiceInput, opts ...request.Option) (*CreateVirtualServiceOutput, error) { + req, out := c.CreateVirtualServiceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteMesh = "DeleteMesh" + +// DeleteMeshRequest generates a "aws/request.Request" representing the +// client's request for the DeleteMesh operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteMesh for more information on using the DeleteMesh +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteMeshRequest method. +// req, resp := client.DeleteMeshRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteMesh +func (c *AppMeshPreview) DeleteMeshRequest(input *DeleteMeshInput) (req *request.Request, output *DeleteMeshOutput) { + op := &request.Operation{ + Name: opDeleteMesh, + HTTPMethod: "DELETE", + HTTPPath: "/v20190125/meshes/{meshName}", + } + + if input == nil { + input = &DeleteMeshInput{} + } + + output = &DeleteMeshOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteMesh API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DeleteMesh for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ResourceInUseException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteMesh +func (c *AppMeshPreview) DeleteMesh(input *DeleteMeshInput) (*DeleteMeshOutput, error) { + req, out := c.DeleteMeshRequest(input) + return out, req.Send() +} + +// DeleteMeshWithContext is the same as DeleteMesh with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteMesh for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DeleteMeshWithContext(ctx aws.Context, input *DeleteMeshInput, opts ...request.Option) (*DeleteMeshOutput, error) { + req, out := c.DeleteMeshRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteRoute = "DeleteRoute" + +// DeleteRouteRequest generates a "aws/request.Request" representing the +// client's request for the DeleteRoute operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteRoute for more information on using the DeleteRoute +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteRouteRequest method. +// req, resp := client.DeleteRouteRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteRoute +func (c *AppMeshPreview) DeleteRouteRequest(input *DeleteRouteInput) (req *request.Request, output *DeleteRouteOutput) { + op := &request.Operation{ + Name: opDeleteRoute, + HTTPMethod: "DELETE", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouter/{virtualRouterName}/routes/{routeName}", + } + + if input == nil { + input = &DeleteRouteInput{} + } + + output = &DeleteRouteOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteRoute API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DeleteRoute for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ResourceInUseException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteRoute +func (c *AppMeshPreview) DeleteRoute(input *DeleteRouteInput) (*DeleteRouteOutput, error) { + req, out := c.DeleteRouteRequest(input) + return out, req.Send() +} + +// DeleteRouteWithContext is the same as DeleteRoute with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteRoute for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DeleteRouteWithContext(ctx aws.Context, input *DeleteRouteInput, opts ...request.Option) (*DeleteRouteOutput, error) { + req, out := c.DeleteRouteRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteVirtualNode = "DeleteVirtualNode" + +// DeleteVirtualNodeRequest generates a "aws/request.Request" representing the +// client's request for the DeleteVirtualNode operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteVirtualNode for more information on using the DeleteVirtualNode +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteVirtualNodeRequest method. +// req, resp := client.DeleteVirtualNodeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualNode +func (c *AppMeshPreview) DeleteVirtualNodeRequest(input *DeleteVirtualNodeInput) (req *request.Request, output *DeleteVirtualNodeOutput) { + op := &request.Operation{ + Name: opDeleteVirtualNode, + HTTPMethod: "DELETE", + HTTPPath: "/v20190125/meshes/{meshName}/virtualNodes/{virtualNodeName}", + } + + if input == nil { + input = &DeleteVirtualNodeInput{} + } + + output = &DeleteVirtualNodeOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteVirtualNode API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DeleteVirtualNode for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ResourceInUseException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualNode +func (c *AppMeshPreview) DeleteVirtualNode(input *DeleteVirtualNodeInput) (*DeleteVirtualNodeOutput, error) { + req, out := c.DeleteVirtualNodeRequest(input) + return out, req.Send() +} + +// DeleteVirtualNodeWithContext is the same as DeleteVirtualNode with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteVirtualNode for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DeleteVirtualNodeWithContext(ctx aws.Context, input *DeleteVirtualNodeInput, opts ...request.Option) (*DeleteVirtualNodeOutput, error) { + req, out := c.DeleteVirtualNodeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteVirtualRouter = "DeleteVirtualRouter" + +// DeleteVirtualRouterRequest generates a "aws/request.Request" representing the +// client's request for the DeleteVirtualRouter operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteVirtualRouter for more information on using the DeleteVirtualRouter +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteVirtualRouterRequest method. +// req, resp := client.DeleteVirtualRouterRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualRouter +func (c *AppMeshPreview) DeleteVirtualRouterRequest(input *DeleteVirtualRouterInput) (req *request.Request, output *DeleteVirtualRouterOutput) { + op := &request.Operation{ + Name: opDeleteVirtualRouter, + HTTPMethod: "DELETE", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouters/{virtualRouterName}", + } + + if input == nil { + input = &DeleteVirtualRouterInput{} + } + + output = &DeleteVirtualRouterOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteVirtualRouter API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DeleteVirtualRouter for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ResourceInUseException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualRouter +func (c *AppMeshPreview) DeleteVirtualRouter(input *DeleteVirtualRouterInput) (*DeleteVirtualRouterOutput, error) { + req, out := c.DeleteVirtualRouterRequest(input) + return out, req.Send() +} + +// DeleteVirtualRouterWithContext is the same as DeleteVirtualRouter with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteVirtualRouter for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DeleteVirtualRouterWithContext(ctx aws.Context, input *DeleteVirtualRouterInput, opts ...request.Option) (*DeleteVirtualRouterOutput, error) { + req, out := c.DeleteVirtualRouterRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteVirtualService = "DeleteVirtualService" + +// DeleteVirtualServiceRequest generates a "aws/request.Request" representing the +// client's request for the DeleteVirtualService operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteVirtualService for more information on using the DeleteVirtualService +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteVirtualServiceRequest method. +// req, resp := client.DeleteVirtualServiceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualService +func (c *AppMeshPreview) DeleteVirtualServiceRequest(input *DeleteVirtualServiceInput) (req *request.Request, output *DeleteVirtualServiceOutput) { + op := &request.Operation{ + Name: opDeleteVirtualService, + HTTPMethod: "DELETE", + HTTPPath: "/v20190125/meshes/{meshName}/virtualServices/{virtualServiceName}", + } + + if input == nil { + input = &DeleteVirtualServiceInput{} + } + + output = &DeleteVirtualServiceOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteVirtualService API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DeleteVirtualService for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DeleteVirtualService +func (c *AppMeshPreview) DeleteVirtualService(input *DeleteVirtualServiceInput) (*DeleteVirtualServiceOutput, error) { + req, out := c.DeleteVirtualServiceRequest(input) + return out, req.Send() +} + +// DeleteVirtualServiceWithContext is the same as DeleteVirtualService with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteVirtualService for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DeleteVirtualServiceWithContext(ctx aws.Context, input *DeleteVirtualServiceInput, opts ...request.Option) (*DeleteVirtualServiceOutput, error) { + req, out := c.DeleteVirtualServiceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeMesh = "DescribeMesh" + +// DescribeMeshRequest generates a "aws/request.Request" representing the +// client's request for the DescribeMesh operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeMesh for more information on using the DescribeMesh +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeMeshRequest method. +// req, resp := client.DescribeMeshRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeMesh +func (c *AppMeshPreview) DescribeMeshRequest(input *DescribeMeshInput) (req *request.Request, output *DescribeMeshOutput) { + op := &request.Operation{ + Name: opDescribeMesh, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}", + } + + if input == nil { + input = &DescribeMeshInput{} + } + + output = &DescribeMeshOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeMesh API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DescribeMesh for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeMesh +func (c *AppMeshPreview) DescribeMesh(input *DescribeMeshInput) (*DescribeMeshOutput, error) { + req, out := c.DescribeMeshRequest(input) + return out, req.Send() +} + +// DescribeMeshWithContext is the same as DescribeMesh with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeMesh for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DescribeMeshWithContext(ctx aws.Context, input *DescribeMeshInput, opts ...request.Option) (*DescribeMeshOutput, error) { + req, out := c.DescribeMeshRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeRoute = "DescribeRoute" + +// DescribeRouteRequest generates a "aws/request.Request" representing the +// client's request for the DescribeRoute operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeRoute for more information on using the DescribeRoute +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeRouteRequest method. +// req, resp := client.DescribeRouteRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeRoute +func (c *AppMeshPreview) DescribeRouteRequest(input *DescribeRouteInput) (req *request.Request, output *DescribeRouteOutput) { + op := &request.Operation{ + Name: opDescribeRoute, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouter/{virtualRouterName}/routes/{routeName}", + } + + if input == nil { + input = &DescribeRouteInput{} + } + + output = &DescribeRouteOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeRoute API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DescribeRoute for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeRoute +func (c *AppMeshPreview) DescribeRoute(input *DescribeRouteInput) (*DescribeRouteOutput, error) { + req, out := c.DescribeRouteRequest(input) + return out, req.Send() +} + +// DescribeRouteWithContext is the same as DescribeRoute with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeRoute for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DescribeRouteWithContext(ctx aws.Context, input *DescribeRouteInput, opts ...request.Option) (*DescribeRouteOutput, error) { + req, out := c.DescribeRouteRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeVirtualNode = "DescribeVirtualNode" + +// DescribeVirtualNodeRequest generates a "aws/request.Request" representing the +// client's request for the DescribeVirtualNode operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeVirtualNode for more information on using the DescribeVirtualNode +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeVirtualNodeRequest method. +// req, resp := client.DescribeVirtualNodeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualNode +func (c *AppMeshPreview) DescribeVirtualNodeRequest(input *DescribeVirtualNodeInput) (req *request.Request, output *DescribeVirtualNodeOutput) { + op := &request.Operation{ + Name: opDescribeVirtualNode, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualNodes/{virtualNodeName}", + } + + if input == nil { + input = &DescribeVirtualNodeInput{} + } + + output = &DescribeVirtualNodeOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeVirtualNode API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DescribeVirtualNode for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualNode +func (c *AppMeshPreview) DescribeVirtualNode(input *DescribeVirtualNodeInput) (*DescribeVirtualNodeOutput, error) { + req, out := c.DescribeVirtualNodeRequest(input) + return out, req.Send() +} + +// DescribeVirtualNodeWithContext is the same as DescribeVirtualNode with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeVirtualNode for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DescribeVirtualNodeWithContext(ctx aws.Context, input *DescribeVirtualNodeInput, opts ...request.Option) (*DescribeVirtualNodeOutput, error) { + req, out := c.DescribeVirtualNodeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeVirtualRouter = "DescribeVirtualRouter" + +// DescribeVirtualRouterRequest generates a "aws/request.Request" representing the +// client's request for the DescribeVirtualRouter operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeVirtualRouter for more information on using the DescribeVirtualRouter +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeVirtualRouterRequest method. +// req, resp := client.DescribeVirtualRouterRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualRouter +func (c *AppMeshPreview) DescribeVirtualRouterRequest(input *DescribeVirtualRouterInput) (req *request.Request, output *DescribeVirtualRouterOutput) { + op := &request.Operation{ + Name: opDescribeVirtualRouter, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouters/{virtualRouterName}", + } + + if input == nil { + input = &DescribeVirtualRouterInput{} + } + + output = &DescribeVirtualRouterOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeVirtualRouter API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DescribeVirtualRouter for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualRouter +func (c *AppMeshPreview) DescribeVirtualRouter(input *DescribeVirtualRouterInput) (*DescribeVirtualRouterOutput, error) { + req, out := c.DescribeVirtualRouterRequest(input) + return out, req.Send() +} + +// DescribeVirtualRouterWithContext is the same as DescribeVirtualRouter with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeVirtualRouter for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DescribeVirtualRouterWithContext(ctx aws.Context, input *DescribeVirtualRouterInput, opts ...request.Option) (*DescribeVirtualRouterOutput, error) { + req, out := c.DescribeVirtualRouterRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDescribeVirtualService = "DescribeVirtualService" + +// DescribeVirtualServiceRequest generates a "aws/request.Request" representing the +// client's request for the DescribeVirtualService operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DescribeVirtualService for more information on using the DescribeVirtualService +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DescribeVirtualServiceRequest method. +// req, resp := client.DescribeVirtualServiceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualService +func (c *AppMeshPreview) DescribeVirtualServiceRequest(input *DescribeVirtualServiceInput) (req *request.Request, output *DescribeVirtualServiceOutput) { + op := &request.Operation{ + Name: opDescribeVirtualService, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualServices/{virtualServiceName}", + } + + if input == nil { + input = &DescribeVirtualServiceInput{} + } + + output = &DescribeVirtualServiceOutput{} + req = c.newRequest(op, input, output) + return +} + +// DescribeVirtualService API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation DescribeVirtualService for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/DescribeVirtualService +func (c *AppMeshPreview) DescribeVirtualService(input *DescribeVirtualServiceInput) (*DescribeVirtualServiceOutput, error) { + req, out := c.DescribeVirtualServiceRequest(input) + return out, req.Send() +} + +// DescribeVirtualServiceWithContext is the same as DescribeVirtualService with the addition of +// the ability to pass a context and additional request options. +// +// See DescribeVirtualService for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) DescribeVirtualServiceWithContext(ctx aws.Context, input *DescribeVirtualServiceInput, opts ...request.Option) (*DescribeVirtualServiceOutput, error) { + req, out := c.DescribeVirtualServiceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListMeshes = "ListMeshes" + +// ListMeshesRequest generates a "aws/request.Request" representing the +// client's request for the ListMeshes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListMeshes for more information on using the ListMeshes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListMeshesRequest method. +// req, resp := client.ListMeshesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListMeshes +func (c *AppMeshPreview) ListMeshesRequest(input *ListMeshesInput) (req *request.Request, output *ListMeshesOutput) { + op := &request.Operation{ + Name: opListMeshes, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes", + } + + if input == nil { + input = &ListMeshesInput{} + } + + output = &ListMeshesOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListMeshes API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation ListMeshes for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListMeshes +func (c *AppMeshPreview) ListMeshes(input *ListMeshesInput) (*ListMeshesOutput, error) { + req, out := c.ListMeshesRequest(input) + return out, req.Send() +} + +// ListMeshesWithContext is the same as ListMeshes with the addition of +// the ability to pass a context and additional request options. +// +// See ListMeshes for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) ListMeshesWithContext(ctx aws.Context, input *ListMeshesInput, opts ...request.Option) (*ListMeshesOutput, error) { + req, out := c.ListMeshesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListRoutes = "ListRoutes" + +// ListRoutesRequest generates a "aws/request.Request" representing the +// client's request for the ListRoutes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListRoutes for more information on using the ListRoutes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListRoutesRequest method. +// req, resp := client.ListRoutesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListRoutes +func (c *AppMeshPreview) ListRoutesRequest(input *ListRoutesInput) (req *request.Request, output *ListRoutesOutput) { + op := &request.Operation{ + Name: opListRoutes, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouter/{virtualRouterName}/routes", + } + + if input == nil { + input = &ListRoutesInput{} + } + + output = &ListRoutesOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListRoutes API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation ListRoutes for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListRoutes +func (c *AppMeshPreview) ListRoutes(input *ListRoutesInput) (*ListRoutesOutput, error) { + req, out := c.ListRoutesRequest(input) + return out, req.Send() +} + +// ListRoutesWithContext is the same as ListRoutes with the addition of +// the ability to pass a context and additional request options. +// +// See ListRoutes for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) ListRoutesWithContext(ctx aws.Context, input *ListRoutesInput, opts ...request.Option) (*ListRoutesOutput, error) { + req, out := c.ListRoutesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListVirtualNodes = "ListVirtualNodes" + +// ListVirtualNodesRequest generates a "aws/request.Request" representing the +// client's request for the ListVirtualNodes operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListVirtualNodes for more information on using the ListVirtualNodes +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListVirtualNodesRequest method. +// req, resp := client.ListVirtualNodesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualNodes +func (c *AppMeshPreview) ListVirtualNodesRequest(input *ListVirtualNodesInput) (req *request.Request, output *ListVirtualNodesOutput) { + op := &request.Operation{ + Name: opListVirtualNodes, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualNodes", + } + + if input == nil { + input = &ListVirtualNodesInput{} + } + + output = &ListVirtualNodesOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListVirtualNodes API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation ListVirtualNodes for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualNodes +func (c *AppMeshPreview) ListVirtualNodes(input *ListVirtualNodesInput) (*ListVirtualNodesOutput, error) { + req, out := c.ListVirtualNodesRequest(input) + return out, req.Send() +} + +// ListVirtualNodesWithContext is the same as ListVirtualNodes with the addition of +// the ability to pass a context and additional request options. +// +// See ListVirtualNodes for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) ListVirtualNodesWithContext(ctx aws.Context, input *ListVirtualNodesInput, opts ...request.Option) (*ListVirtualNodesOutput, error) { + req, out := c.ListVirtualNodesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListVirtualRouters = "ListVirtualRouters" + +// ListVirtualRoutersRequest generates a "aws/request.Request" representing the +// client's request for the ListVirtualRouters operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListVirtualRouters for more information on using the ListVirtualRouters +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListVirtualRoutersRequest method. +// req, resp := client.ListVirtualRoutersRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualRouters +func (c *AppMeshPreview) ListVirtualRoutersRequest(input *ListVirtualRoutersInput) (req *request.Request, output *ListVirtualRoutersOutput) { + op := &request.Operation{ + Name: opListVirtualRouters, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouters", + } + + if input == nil { + input = &ListVirtualRoutersInput{} + } + + output = &ListVirtualRoutersOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListVirtualRouters API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation ListVirtualRouters for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualRouters +func (c *AppMeshPreview) ListVirtualRouters(input *ListVirtualRoutersInput) (*ListVirtualRoutersOutput, error) { + req, out := c.ListVirtualRoutersRequest(input) + return out, req.Send() +} + +// ListVirtualRoutersWithContext is the same as ListVirtualRouters with the addition of +// the ability to pass a context and additional request options. +// +// See ListVirtualRouters for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) ListVirtualRoutersWithContext(ctx aws.Context, input *ListVirtualRoutersInput, opts ...request.Option) (*ListVirtualRoutersOutput, error) { + req, out := c.ListVirtualRoutersRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opListVirtualServices = "ListVirtualServices" + +// ListVirtualServicesRequest generates a "aws/request.Request" representing the +// client's request for the ListVirtualServices operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ListVirtualServices for more information on using the ListVirtualServices +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ListVirtualServicesRequest method. +// req, resp := client.ListVirtualServicesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualServices +func (c *AppMeshPreview) ListVirtualServicesRequest(input *ListVirtualServicesInput) (req *request.Request, output *ListVirtualServicesOutput) { + op := &request.Operation{ + Name: opListVirtualServices, + HTTPMethod: "GET", + HTTPPath: "/v20190125/meshes/{meshName}/virtualServices", + } + + if input == nil { + input = &ListVirtualServicesInput{} + } + + output = &ListVirtualServicesOutput{} + req = c.newRequest(op, input, output) + return +} + +// ListVirtualServices API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation ListVirtualServices for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/ListVirtualServices +func (c *AppMeshPreview) ListVirtualServices(input *ListVirtualServicesInput) (*ListVirtualServicesOutput, error) { + req, out := c.ListVirtualServicesRequest(input) + return out, req.Send() +} + +// ListVirtualServicesWithContext is the same as ListVirtualServices with the addition of +// the ability to pass a context and additional request options. +// +// See ListVirtualServices for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) ListVirtualServicesWithContext(ctx aws.Context, input *ListVirtualServicesInput, opts ...request.Option) (*ListVirtualServicesOutput, error) { + req, out := c.ListVirtualServicesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateMesh = "UpdateMesh" + +// UpdateMeshRequest generates a "aws/request.Request" representing the +// client's request for the UpdateMesh operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateMesh for more information on using the UpdateMesh +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateMeshRequest method. +// req, resp := client.UpdateMeshRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateMesh +func (c *AppMeshPreview) UpdateMeshRequest(input *UpdateMeshInput) (req *request.Request, output *UpdateMeshOutput) { + op := &request.Operation{ + Name: opUpdateMesh, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}", + } + + if input == nil { + input = &UpdateMeshInput{} + } + + output = &UpdateMeshOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateMesh API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation UpdateMesh for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateMesh +func (c *AppMeshPreview) UpdateMesh(input *UpdateMeshInput) (*UpdateMeshOutput, error) { + req, out := c.UpdateMeshRequest(input) + return out, req.Send() +} + +// UpdateMeshWithContext is the same as UpdateMesh with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateMesh for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) UpdateMeshWithContext(ctx aws.Context, input *UpdateMeshInput, opts ...request.Option) (*UpdateMeshOutput, error) { + req, out := c.UpdateMeshRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateRoute = "UpdateRoute" + +// UpdateRouteRequest generates a "aws/request.Request" representing the +// client's request for the UpdateRoute operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateRoute for more information on using the UpdateRoute +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateRouteRequest method. +// req, resp := client.UpdateRouteRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateRoute +func (c *AppMeshPreview) UpdateRouteRequest(input *UpdateRouteInput) (req *request.Request, output *UpdateRouteOutput) { + op := &request.Operation{ + Name: opUpdateRoute, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouter/{virtualRouterName}/routes/{routeName}", + } + + if input == nil { + input = &UpdateRouteInput{} + } + + output = &UpdateRouteOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateRoute API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation UpdateRoute for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateRoute +func (c *AppMeshPreview) UpdateRoute(input *UpdateRouteInput) (*UpdateRouteOutput, error) { + req, out := c.UpdateRouteRequest(input) + return out, req.Send() +} + +// UpdateRouteWithContext is the same as UpdateRoute with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateRoute for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) UpdateRouteWithContext(ctx aws.Context, input *UpdateRouteInput, opts ...request.Option) (*UpdateRouteOutput, error) { + req, out := c.UpdateRouteRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateVirtualNode = "UpdateVirtualNode" + +// UpdateVirtualNodeRequest generates a "aws/request.Request" representing the +// client's request for the UpdateVirtualNode operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateVirtualNode for more information on using the UpdateVirtualNode +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateVirtualNodeRequest method. +// req, resp := client.UpdateVirtualNodeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualNode +func (c *AppMeshPreview) UpdateVirtualNodeRequest(input *UpdateVirtualNodeInput) (req *request.Request, output *UpdateVirtualNodeOutput) { + op := &request.Operation{ + Name: opUpdateVirtualNode, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualNodes/{virtualNodeName}", + } + + if input == nil { + input = &UpdateVirtualNodeInput{} + } + + output = &UpdateVirtualNodeOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateVirtualNode API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation UpdateVirtualNode for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualNode +func (c *AppMeshPreview) UpdateVirtualNode(input *UpdateVirtualNodeInput) (*UpdateVirtualNodeOutput, error) { + req, out := c.UpdateVirtualNodeRequest(input) + return out, req.Send() +} + +// UpdateVirtualNodeWithContext is the same as UpdateVirtualNode with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateVirtualNode for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) UpdateVirtualNodeWithContext(ctx aws.Context, input *UpdateVirtualNodeInput, opts ...request.Option) (*UpdateVirtualNodeOutput, error) { + req, out := c.UpdateVirtualNodeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateVirtualRouter = "UpdateVirtualRouter" + +// UpdateVirtualRouterRequest generates a "aws/request.Request" representing the +// client's request for the UpdateVirtualRouter operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateVirtualRouter for more information on using the UpdateVirtualRouter +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateVirtualRouterRequest method. +// req, resp := client.UpdateVirtualRouterRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualRouter +func (c *AppMeshPreview) UpdateVirtualRouterRequest(input *UpdateVirtualRouterInput) (req *request.Request, output *UpdateVirtualRouterOutput) { + op := &request.Operation{ + Name: opUpdateVirtualRouter, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualRouters/{virtualRouterName}", + } + + if input == nil { + input = &UpdateVirtualRouterInput{} + } + + output = &UpdateVirtualRouterOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateVirtualRouter API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation UpdateVirtualRouter for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualRouter +func (c *AppMeshPreview) UpdateVirtualRouter(input *UpdateVirtualRouterInput) (*UpdateVirtualRouterOutput, error) { + req, out := c.UpdateVirtualRouterRequest(input) + return out, req.Send() +} + +// UpdateVirtualRouterWithContext is the same as UpdateVirtualRouter with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateVirtualRouter for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) UpdateVirtualRouterWithContext(ctx aws.Context, input *UpdateVirtualRouterInput, opts ...request.Option) (*UpdateVirtualRouterOutput, error) { + req, out := c.UpdateVirtualRouterRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateVirtualService = "UpdateVirtualService" + +// UpdateVirtualServiceRequest generates a "aws/request.Request" representing the +// client's request for the UpdateVirtualService operation. The "output" return +// value will be populated with the request's response once the request completes +// successfully. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateVirtualService for more information on using the UpdateVirtualService +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateVirtualServiceRequest method. +// req, resp := client.UpdateVirtualServiceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualService +func (c *AppMeshPreview) UpdateVirtualServiceRequest(input *UpdateVirtualServiceInput) (req *request.Request, output *UpdateVirtualServiceOutput) { + op := &request.Operation{ + Name: opUpdateVirtualService, + HTTPMethod: "PUT", + HTTPPath: "/v20190125/meshes/{meshName}/virtualServices/{virtualServiceName}", + } + + if input == nil { + input = &UpdateVirtualServiceInput{} + } + + output = &UpdateVirtualServiceOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateVirtualService API operation for AWS App Mesh Preview. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for AWS App Mesh Preview's +// API operation UpdateVirtualService for usage and error information. +// +// Returned Error Types: +// * BadRequestException +// +// * ConflictException +// +// * ForbiddenException +// +// * InternalServerErrorException +// +// * LimitExceededException +// +// * NotFoundException +// +// * ServiceUnavailableException +// +// * TooManyRequestsException +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25/UpdateVirtualService +func (c *AppMeshPreview) UpdateVirtualService(input *UpdateVirtualServiceInput) (*UpdateVirtualServiceOutput, error) { + req, out := c.UpdateVirtualServiceRequest(input) + return out, req.Send() +} + +// UpdateVirtualServiceWithContext is the same as UpdateVirtualService with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateVirtualService for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *AppMeshPreview) UpdateVirtualServiceWithContext(ctx aws.Context, input *UpdateVirtualServiceInput, opts ...request.Option) (*UpdateVirtualServiceOutput, error) { + req, out := c.UpdateVirtualServiceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +type AccessLog struct { + _ struct{} `type:"structure"` + + File *FileAccessLog `locationName:"file" type:"structure"` +} + +// String returns the string representation +func (s AccessLog) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AccessLog) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AccessLog) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AccessLog"} + if s.File != nil { + if err := s.File.Validate(); err != nil { + invalidParams.AddNested("File", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetFile sets the File field's value. +func (s *AccessLog) SetFile(v *FileAccessLog) *AccessLog { + s.File = v + return s +} + +type AwsCloudMapInstanceAttribute struct { + _ struct{} `type:"structure"` + + // Key is a required field + Key *string `locationName:"key" min:"1" type:"string" required:"true"` + + // Value is a required field + Value *string `locationName:"value" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s AwsCloudMapInstanceAttribute) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AwsCloudMapInstanceAttribute) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AwsCloudMapInstanceAttribute) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AwsCloudMapInstanceAttribute"} + if s.Key == nil { + invalidParams.Add(request.NewErrParamRequired("Key")) + } + if s.Key != nil && len(*s.Key) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Key", 1)) + } + if s.Value == nil { + invalidParams.Add(request.NewErrParamRequired("Value")) + } + if s.Value != nil && len(*s.Value) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Value", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKey sets the Key field's value. +func (s *AwsCloudMapInstanceAttribute) SetKey(v string) *AwsCloudMapInstanceAttribute { + s.Key = &v + return s +} + +// SetValue sets the Value field's value. +func (s *AwsCloudMapInstanceAttribute) SetValue(v string) *AwsCloudMapInstanceAttribute { + s.Value = &v + return s +} + +type AwsCloudMapServiceDiscovery struct { + _ struct{} `type:"structure"` + + Attributes []*AwsCloudMapInstanceAttribute `locationName:"attributes" type:"list"` + + // NamespaceName is a required field + NamespaceName *string `locationName:"namespaceName" min:"1" type:"string" required:"true"` + + // ServiceName is a required field + ServiceName *string `locationName:"serviceName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s AwsCloudMapServiceDiscovery) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AwsCloudMapServiceDiscovery) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AwsCloudMapServiceDiscovery) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AwsCloudMapServiceDiscovery"} + if s.NamespaceName == nil { + invalidParams.Add(request.NewErrParamRequired("NamespaceName")) + } + if s.NamespaceName != nil && len(*s.NamespaceName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("NamespaceName", 1)) + } + if s.ServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("ServiceName")) + } + if s.ServiceName != nil && len(*s.ServiceName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("ServiceName", 1)) + } + if s.Attributes != nil { + for i, v := range s.Attributes { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Attributes", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributes sets the Attributes field's value. +func (s *AwsCloudMapServiceDiscovery) SetAttributes(v []*AwsCloudMapInstanceAttribute) *AwsCloudMapServiceDiscovery { + s.Attributes = v + return s +} + +// SetNamespaceName sets the NamespaceName field's value. +func (s *AwsCloudMapServiceDiscovery) SetNamespaceName(v string) *AwsCloudMapServiceDiscovery { + s.NamespaceName = &v + return s +} + +// SetServiceName sets the ServiceName field's value. +func (s *AwsCloudMapServiceDiscovery) SetServiceName(v string) *AwsCloudMapServiceDiscovery { + s.ServiceName = &v + return s +} + +type Backend struct { + _ struct{} `type:"structure"` + + VirtualService *VirtualServiceBackend `locationName:"virtualService" type:"structure"` +} + +// String returns the string representation +func (s Backend) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Backend) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *Backend) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "Backend"} + if s.VirtualService != nil { + if err := s.VirtualService.Validate(); err != nil { + invalidParams.AddNested("VirtualService", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetVirtualService sets the VirtualService field's value. +func (s *Backend) SetVirtualService(v *VirtualServiceBackend) *Backend { + s.VirtualService = v + return s +} + +type BackendDefaults struct { + _ struct{} `type:"structure"` + + ClientPolicy *ClientPolicy `locationName:"clientPolicy" type:"structure"` +} + +// String returns the string representation +func (s BackendDefaults) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s BackendDefaults) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *BackendDefaults) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "BackendDefaults"} + if s.ClientPolicy != nil { + if err := s.ClientPolicy.Validate(); err != nil { + invalidParams.AddNested("ClientPolicy", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientPolicy sets the ClientPolicy field's value. +func (s *BackendDefaults) SetClientPolicy(v *ClientPolicy) *BackendDefaults { + s.ClientPolicy = v + return s +} + +type BadRequestException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s BadRequestException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s BadRequestException) GoString() string { + return s.String() +} + +func newErrorBadRequestException(v protocol.ResponseMetadata) error { + return &BadRequestException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s BadRequestException) Code() string { + return "BadRequestException" +} + +// Message returns the exception's message. +func (s BadRequestException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s BadRequestException) OrigErr() error { + return nil +} + +func (s BadRequestException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s BadRequestException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s BadRequestException) RequestID() string { + return s.respMetadata.RequestID +} + +type ClientPolicy struct { + _ struct{} `type:"structure"` + + Tls *ClientPolicyTls `locationName:"tls" type:"structure"` +} + +// String returns the string representation +func (s ClientPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ClientPolicy) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ClientPolicy) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ClientPolicy"} + if s.Tls != nil { + if err := s.Tls.Validate(); err != nil { + invalidParams.AddNested("Tls", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetTls sets the Tls field's value. +func (s *ClientPolicy) SetTls(v *ClientPolicyTls) *ClientPolicy { + s.Tls = v + return s +} + +type ClientPolicyTls struct { + _ struct{} `type:"structure"` + + Enforce *bool `locationName:"enforce" type:"boolean"` + + Ports []*int64 `locationName:"ports" type:"list"` + + Validation *TlsValidationContext `locationName:"validation" type:"structure"` +} + +// String returns the string representation +func (s ClientPolicyTls) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ClientPolicyTls) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ClientPolicyTls) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ClientPolicyTls"} + if s.Validation != nil { + if err := s.Validation.Validate(); err != nil { + invalidParams.AddNested("Validation", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEnforce sets the Enforce field's value. +func (s *ClientPolicyTls) SetEnforce(v bool) *ClientPolicyTls { + s.Enforce = &v + return s +} + +// SetPorts sets the Ports field's value. +func (s *ClientPolicyTls) SetPorts(v []*int64) *ClientPolicyTls { + s.Ports = v + return s +} + +// SetValidation sets the Validation field's value. +func (s *ClientPolicyTls) SetValidation(v *TlsValidationContext) *ClientPolicyTls { + s.Validation = v + return s +} + +type ConflictException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s ConflictException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ConflictException) GoString() string { + return s.String() +} + +func newErrorConflictException(v protocol.ResponseMetadata) error { + return &ConflictException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s ConflictException) Code() string { + return "ConflictException" +} + +// Message returns the exception's message. +func (s ConflictException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s ConflictException) OrigErr() error { + return nil +} + +func (s ConflictException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s ConflictException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s ConflictException) RequestID() string { + return s.respMetadata.RequestID +} + +type CreateMeshInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + Spec *MeshSpec `locationName:"spec" type:"structure"` +} + +// String returns the string representation +func (s CreateMeshInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateMeshInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateMeshInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateMeshInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *CreateMeshInput) SetClientToken(v string) *CreateMeshInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *CreateMeshInput) SetMeshName(v string) *CreateMeshInput { + s.MeshName = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *CreateMeshInput) SetSpec(v *MeshSpec) *CreateMeshInput { + s.Spec = v + return s +} + +type CreateMeshOutput struct { + _ struct{} `type:"structure" payload:"Mesh"` + + // Mesh is a required field + Mesh *MeshData `locationName:"mesh" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateMeshOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateMeshOutput) GoString() string { + return s.String() +} + +// SetMesh sets the Mesh field's value. +func (s *CreateMeshOutput) SetMesh(v *MeshData) *CreateMeshOutput { + s.Mesh = v + return s +} + +type CreateRouteInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // RouteName is a required field + RouteName *string `locationName:"routeName" min:"1" type:"string" required:"true"` + + // Spec is a required field + Spec *RouteSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateRouteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateRouteInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateRouteInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateRouteInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.RouteName == nil { + invalidParams.Add(request.NewErrParamRequired("RouteName")) + } + if s.RouteName != nil && len(*s.RouteName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RouteName", 1)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *CreateRouteInput) SetClientToken(v string) *CreateRouteInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *CreateRouteInput) SetMeshName(v string) *CreateRouteInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *CreateRouteInput) SetMeshOwner(v string) *CreateRouteInput { + s.MeshOwner = &v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *CreateRouteInput) SetRouteName(v string) *CreateRouteInput { + s.RouteName = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *CreateRouteInput) SetSpec(v *RouteSpec) *CreateRouteInput { + s.Spec = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *CreateRouteInput) SetVirtualRouterName(v string) *CreateRouteInput { + s.VirtualRouterName = &v + return s +} + +type CreateRouteOutput struct { + _ struct{} `type:"structure" payload:"Route"` + + // Route is a required field + Route *RouteData `locationName:"route" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateRouteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateRouteOutput) GoString() string { + return s.String() +} + +// SetRoute sets the Route field's value. +func (s *CreateRouteOutput) SetRoute(v *RouteData) *CreateRouteOutput { + s.Route = v + return s +} + +type CreateVirtualNodeInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualNodeSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualNodeName is a required field + VirtualNodeName *string `locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualNodeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualNodeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateVirtualNodeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateVirtualNodeInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualNodeName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNodeName")) + } + if s.VirtualNodeName != nil && len(*s.VirtualNodeName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNodeName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *CreateVirtualNodeInput) SetClientToken(v string) *CreateVirtualNodeInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *CreateVirtualNodeInput) SetMeshName(v string) *CreateVirtualNodeInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *CreateVirtualNodeInput) SetMeshOwner(v string) *CreateVirtualNodeInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *CreateVirtualNodeInput) SetSpec(v *VirtualNodeSpec) *CreateVirtualNodeInput { + s.Spec = v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *CreateVirtualNodeInput) SetVirtualNodeName(v string) *CreateVirtualNodeInput { + s.VirtualNodeName = &v + return s +} + +type CreateVirtualNodeOutput struct { + _ struct{} `type:"structure" payload:"VirtualNode"` + + // VirtualNode is a required field + VirtualNode *VirtualNodeData `locationName:"virtualNode" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualNodeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualNodeOutput) GoString() string { + return s.String() +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *CreateVirtualNodeOutput) SetVirtualNode(v *VirtualNodeData) *CreateVirtualNodeOutput { + s.VirtualNode = v + return s +} + +type CreateVirtualRouterInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualRouterSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualRouterInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualRouterInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateVirtualRouterInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateVirtualRouterInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *CreateVirtualRouterInput) SetClientToken(v string) *CreateVirtualRouterInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *CreateVirtualRouterInput) SetMeshName(v string) *CreateVirtualRouterInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *CreateVirtualRouterInput) SetMeshOwner(v string) *CreateVirtualRouterInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *CreateVirtualRouterInput) SetSpec(v *VirtualRouterSpec) *CreateVirtualRouterInput { + s.Spec = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *CreateVirtualRouterInput) SetVirtualRouterName(v string) *CreateVirtualRouterInput { + s.VirtualRouterName = &v + return s +} + +type CreateVirtualRouterOutput struct { + _ struct{} `type:"structure" payload:"VirtualRouter"` + + // VirtualRouter is a required field + VirtualRouter *VirtualRouterData `locationName:"virtualRouter" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualRouterOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualRouterOutput) GoString() string { + return s.String() +} + +// SetVirtualRouter sets the VirtualRouter field's value. +func (s *CreateVirtualRouterOutput) SetVirtualRouter(v *VirtualRouterData) *CreateVirtualRouterOutput { + s.VirtualRouter = v + return s +} + +type CreateVirtualServiceInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualServiceSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualServiceName is a required field + VirtualServiceName *string `locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualServiceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualServiceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateVirtualServiceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateVirtualServiceInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualServiceName")) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *CreateVirtualServiceInput) SetClientToken(v string) *CreateVirtualServiceInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *CreateVirtualServiceInput) SetMeshName(v string) *CreateVirtualServiceInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *CreateVirtualServiceInput) SetMeshOwner(v string) *CreateVirtualServiceInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *CreateVirtualServiceInput) SetSpec(v *VirtualServiceSpec) *CreateVirtualServiceInput { + s.Spec = v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *CreateVirtualServiceInput) SetVirtualServiceName(v string) *CreateVirtualServiceInput { + s.VirtualServiceName = &v + return s +} + +type CreateVirtualServiceOutput struct { + _ struct{} `type:"structure" payload:"VirtualService"` + + // VirtualService is a required field + VirtualService *VirtualServiceData `locationName:"virtualService" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CreateVirtualServiceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateVirtualServiceOutput) GoString() string { + return s.String() +} + +// SetVirtualService sets the VirtualService field's value. +func (s *CreateVirtualServiceOutput) SetVirtualService(v *VirtualServiceData) *CreateVirtualServiceOutput { + s.VirtualService = v + return s +} + +type DeleteMeshInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteMeshInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteMeshInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteMeshInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteMeshInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DeleteMeshInput) SetMeshName(v string) *DeleteMeshInput { + s.MeshName = &v + return s +} + +type DeleteMeshOutput struct { + _ struct{} `type:"structure" payload:"Mesh"` + + // Mesh is a required field + Mesh *MeshData `locationName:"mesh" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DeleteMeshOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteMeshOutput) GoString() string { + return s.String() +} + +// SetMesh sets the Mesh field's value. +func (s *DeleteMeshOutput) SetMesh(v *MeshData) *DeleteMeshOutput { + s.Mesh = v + return s +} + +type DeleteRouteInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // RouteName is a required field + RouteName *string `location:"uri" locationName:"routeName" min:"1" type:"string" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteRouteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteRouteInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteRouteInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteRouteInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.RouteName == nil { + invalidParams.Add(request.NewErrParamRequired("RouteName")) + } + if s.RouteName != nil && len(*s.RouteName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RouteName", 1)) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DeleteRouteInput) SetMeshName(v string) *DeleteRouteInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DeleteRouteInput) SetMeshOwner(v string) *DeleteRouteInput { + s.MeshOwner = &v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *DeleteRouteInput) SetRouteName(v string) *DeleteRouteInput { + s.RouteName = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *DeleteRouteInput) SetVirtualRouterName(v string) *DeleteRouteInput { + s.VirtualRouterName = &v + return s +} + +type DeleteRouteOutput struct { + _ struct{} `type:"structure" payload:"Route"` + + // Route is a required field + Route *RouteData `locationName:"route" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DeleteRouteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteRouteOutput) GoString() string { + return s.String() +} + +// SetRoute sets the Route field's value. +func (s *DeleteRouteOutput) SetRoute(v *RouteData) *DeleteRouteOutput { + s.Route = v + return s +} + +type DeleteVirtualNodeInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualNodeName is a required field + VirtualNodeName *string `location:"uri" locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualNodeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualNodeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteVirtualNodeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteVirtualNodeInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualNodeName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNodeName")) + } + if s.VirtualNodeName != nil && len(*s.VirtualNodeName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNodeName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DeleteVirtualNodeInput) SetMeshName(v string) *DeleteVirtualNodeInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DeleteVirtualNodeInput) SetMeshOwner(v string) *DeleteVirtualNodeInput { + s.MeshOwner = &v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *DeleteVirtualNodeInput) SetVirtualNodeName(v string) *DeleteVirtualNodeInput { + s.VirtualNodeName = &v + return s +} + +type DeleteVirtualNodeOutput struct { + _ struct{} `type:"structure" payload:"VirtualNode"` + + // VirtualNode is a required field + VirtualNode *VirtualNodeData `locationName:"virtualNode" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualNodeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualNodeOutput) GoString() string { + return s.String() +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *DeleteVirtualNodeOutput) SetVirtualNode(v *VirtualNodeData) *DeleteVirtualNodeOutput { + s.VirtualNode = v + return s +} + +type DeleteVirtualRouterInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualRouterInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualRouterInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteVirtualRouterInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteVirtualRouterInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DeleteVirtualRouterInput) SetMeshName(v string) *DeleteVirtualRouterInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DeleteVirtualRouterInput) SetMeshOwner(v string) *DeleteVirtualRouterInput { + s.MeshOwner = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *DeleteVirtualRouterInput) SetVirtualRouterName(v string) *DeleteVirtualRouterInput { + s.VirtualRouterName = &v + return s +} + +type DeleteVirtualRouterOutput struct { + _ struct{} `type:"structure" payload:"VirtualRouter"` + + // VirtualRouter is a required field + VirtualRouter *VirtualRouterData `locationName:"virtualRouter" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualRouterOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualRouterOutput) GoString() string { + return s.String() +} + +// SetVirtualRouter sets the VirtualRouter field's value. +func (s *DeleteVirtualRouterOutput) SetVirtualRouter(v *VirtualRouterData) *DeleteVirtualRouterOutput { + s.VirtualRouter = v + return s +} + +type DeleteVirtualServiceInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualServiceName is a required field + VirtualServiceName *string `location:"uri" locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualServiceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualServiceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteVirtualServiceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteVirtualServiceInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualServiceName")) + } + if s.VirtualServiceName != nil && len(*s.VirtualServiceName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualServiceName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DeleteVirtualServiceInput) SetMeshName(v string) *DeleteVirtualServiceInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DeleteVirtualServiceInput) SetMeshOwner(v string) *DeleteVirtualServiceInput { + s.MeshOwner = &v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *DeleteVirtualServiceInput) SetVirtualServiceName(v string) *DeleteVirtualServiceInput { + s.VirtualServiceName = &v + return s +} + +type DeleteVirtualServiceOutput struct { + _ struct{} `type:"structure" payload:"VirtualService"` + + // VirtualService is a required field + VirtualService *VirtualServiceData `locationName:"virtualService" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DeleteVirtualServiceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteVirtualServiceOutput) GoString() string { + return s.String() +} + +// SetVirtualService sets the VirtualService field's value. +func (s *DeleteVirtualServiceOutput) SetVirtualService(v *VirtualServiceData) *DeleteVirtualServiceOutput { + s.VirtualService = v + return s +} + +type DescribeMeshInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` +} + +// String returns the string representation +func (s DescribeMeshInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeMeshInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeMeshInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeMeshInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DescribeMeshInput) SetMeshName(v string) *DescribeMeshInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DescribeMeshInput) SetMeshOwner(v string) *DescribeMeshInput { + s.MeshOwner = &v + return s +} + +type DescribeMeshOutput struct { + _ struct{} `type:"structure" payload:"Mesh"` + + // Mesh is a required field + Mesh *MeshData `locationName:"mesh" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeMeshOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeMeshOutput) GoString() string { + return s.String() +} + +// SetMesh sets the Mesh field's value. +func (s *DescribeMeshOutput) SetMesh(v *MeshData) *DescribeMeshOutput { + s.Mesh = v + return s +} + +type DescribeRouteInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // RouteName is a required field + RouteName *string `location:"uri" locationName:"routeName" min:"1" type:"string" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeRouteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeRouteInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeRouteInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeRouteInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.RouteName == nil { + invalidParams.Add(request.NewErrParamRequired("RouteName")) + } + if s.RouteName != nil && len(*s.RouteName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RouteName", 1)) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DescribeRouteInput) SetMeshName(v string) *DescribeRouteInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DescribeRouteInput) SetMeshOwner(v string) *DescribeRouteInput { + s.MeshOwner = &v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *DescribeRouteInput) SetRouteName(v string) *DescribeRouteInput { + s.RouteName = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *DescribeRouteInput) SetVirtualRouterName(v string) *DescribeRouteInput { + s.VirtualRouterName = &v + return s +} + +type DescribeRouteOutput struct { + _ struct{} `type:"structure" payload:"Route"` + + // Route is a required field + Route *RouteData `locationName:"route" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeRouteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeRouteOutput) GoString() string { + return s.String() +} + +// SetRoute sets the Route field's value. +func (s *DescribeRouteOutput) SetRoute(v *RouteData) *DescribeRouteOutput { + s.Route = v + return s +} + +type DescribeVirtualNodeInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualNodeName is a required field + VirtualNodeName *string `location:"uri" locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualNodeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualNodeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeVirtualNodeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeVirtualNodeInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualNodeName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNodeName")) + } + if s.VirtualNodeName != nil && len(*s.VirtualNodeName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNodeName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DescribeVirtualNodeInput) SetMeshName(v string) *DescribeVirtualNodeInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DescribeVirtualNodeInput) SetMeshOwner(v string) *DescribeVirtualNodeInput { + s.MeshOwner = &v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *DescribeVirtualNodeInput) SetVirtualNodeName(v string) *DescribeVirtualNodeInput { + s.VirtualNodeName = &v + return s +} + +type DescribeVirtualNodeOutput struct { + _ struct{} `type:"structure" payload:"VirtualNode"` + + // VirtualNode is a required field + VirtualNode *VirtualNodeData `locationName:"virtualNode" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualNodeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualNodeOutput) GoString() string { + return s.String() +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *DescribeVirtualNodeOutput) SetVirtualNode(v *VirtualNodeData) *DescribeVirtualNodeOutput { + s.VirtualNode = v + return s +} + +type DescribeVirtualRouterInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualRouterInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualRouterInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeVirtualRouterInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeVirtualRouterInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DescribeVirtualRouterInput) SetMeshName(v string) *DescribeVirtualRouterInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DescribeVirtualRouterInput) SetMeshOwner(v string) *DescribeVirtualRouterInput { + s.MeshOwner = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *DescribeVirtualRouterInput) SetVirtualRouterName(v string) *DescribeVirtualRouterInput { + s.VirtualRouterName = &v + return s +} + +type DescribeVirtualRouterOutput struct { + _ struct{} `type:"structure" payload:"VirtualRouter"` + + // VirtualRouter is a required field + VirtualRouter *VirtualRouterData `locationName:"virtualRouter" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualRouterOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualRouterOutput) GoString() string { + return s.String() +} + +// SetVirtualRouter sets the VirtualRouter field's value. +func (s *DescribeVirtualRouterOutput) SetVirtualRouter(v *VirtualRouterData) *DescribeVirtualRouterOutput { + s.VirtualRouter = v + return s +} + +type DescribeVirtualServiceInput struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // VirtualServiceName is a required field + VirtualServiceName *string `location:"uri" locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualServiceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualServiceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DescribeVirtualServiceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DescribeVirtualServiceInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualServiceName")) + } + if s.VirtualServiceName != nil && len(*s.VirtualServiceName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualServiceName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMeshName sets the MeshName field's value. +func (s *DescribeVirtualServiceInput) SetMeshName(v string) *DescribeVirtualServiceInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *DescribeVirtualServiceInput) SetMeshOwner(v string) *DescribeVirtualServiceInput { + s.MeshOwner = &v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *DescribeVirtualServiceInput) SetVirtualServiceName(v string) *DescribeVirtualServiceInput { + s.VirtualServiceName = &v + return s +} + +type DescribeVirtualServiceOutput struct { + _ struct{} `type:"structure" payload:"VirtualService"` + + // VirtualService is a required field + VirtualService *VirtualServiceData `locationName:"virtualService" type:"structure" required:"true"` +} + +// String returns the string representation +func (s DescribeVirtualServiceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeVirtualServiceOutput) GoString() string { + return s.String() +} + +// SetVirtualService sets the VirtualService field's value. +func (s *DescribeVirtualServiceOutput) SetVirtualService(v *VirtualServiceData) *DescribeVirtualServiceOutput { + s.VirtualService = v + return s +} + +type DnsServiceDiscovery struct { + _ struct{} `type:"structure"` + + // Hostname is a required field + Hostname *string `locationName:"hostname" type:"string" required:"true"` +} + +// String returns the string representation +func (s DnsServiceDiscovery) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DnsServiceDiscovery) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DnsServiceDiscovery) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DnsServiceDiscovery"} + if s.Hostname == nil { + invalidParams.Add(request.NewErrParamRequired("Hostname")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetHostname sets the Hostname field's value. +func (s *DnsServiceDiscovery) SetHostname(v string) *DnsServiceDiscovery { + s.Hostname = &v + return s +} + +type Duration struct { + _ struct{} `type:"structure"` + + Unit *string `locationName:"unit" type:"string" enum:"DurationUnit"` + + Value *int64 `locationName:"value" type:"long"` +} + +// String returns the string representation +func (s Duration) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Duration) GoString() string { + return s.String() +} + +// SetUnit sets the Unit field's value. +func (s *Duration) SetUnit(v string) *Duration { + s.Unit = &v + return s +} + +// SetValue sets the Value field's value. +func (s *Duration) SetValue(v int64) *Duration { + s.Value = &v + return s +} + +type EgressFilter struct { + _ struct{} `type:"structure"` + + // Type is a required field + Type *string `locationName:"type" type:"string" required:"true" enum:"EgressFilterType"` +} + +// String returns the string representation +func (s EgressFilter) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s EgressFilter) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *EgressFilter) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "EgressFilter"} + if s.Type == nil { + invalidParams.Add(request.NewErrParamRequired("Type")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetType sets the Type field's value. +func (s *EgressFilter) SetType(v string) *EgressFilter { + s.Type = &v + return s +} + +type FileAccessLog struct { + _ struct{} `type:"structure"` + + // Path is a required field + Path *string `locationName:"path" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s FileAccessLog) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s FileAccessLog) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *FileAccessLog) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "FileAccessLog"} + if s.Path == nil { + invalidParams.Add(request.NewErrParamRequired("Path")) + } + if s.Path != nil && len(*s.Path) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Path", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPath sets the Path field's value. +func (s *FileAccessLog) SetPath(v string) *FileAccessLog { + s.Path = &v + return s +} + +type ForbiddenException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s ForbiddenException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ForbiddenException) GoString() string { + return s.String() +} + +func newErrorForbiddenException(v protocol.ResponseMetadata) error { + return &ForbiddenException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s ForbiddenException) Code() string { + return "ForbiddenException" +} + +// Message returns the exception's message. +func (s ForbiddenException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s ForbiddenException) OrigErr() error { + return nil +} + +func (s ForbiddenException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s ForbiddenException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s ForbiddenException) RequestID() string { + return s.respMetadata.RequestID +} + +type GrpcRetryPolicy struct { + _ struct{} `type:"structure"` + + GrpcRetryEvents []*string `locationName:"grpcRetryEvents" min:"1" type:"list"` + + HttpRetryEvents []*string `locationName:"httpRetryEvents" min:"1" type:"list"` + + // MaxRetries is a required field + MaxRetries *int64 `locationName:"maxRetries" type:"long" required:"true"` + + // PerRetryTimeout is a required field + PerRetryTimeout *Duration `locationName:"perRetryTimeout" type:"structure" required:"true"` + + TcpRetryEvents []*string `locationName:"tcpRetryEvents" min:"1" type:"list"` +} + +// String returns the string representation +func (s GrpcRetryPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRetryPolicy) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRetryPolicy) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRetryPolicy"} + if s.GrpcRetryEvents != nil && len(s.GrpcRetryEvents) < 1 { + invalidParams.Add(request.NewErrParamMinLen("GrpcRetryEvents", 1)) + } + if s.HttpRetryEvents != nil && len(s.HttpRetryEvents) < 1 { + invalidParams.Add(request.NewErrParamMinLen("HttpRetryEvents", 1)) + } + if s.MaxRetries == nil { + invalidParams.Add(request.NewErrParamRequired("MaxRetries")) + } + if s.PerRetryTimeout == nil { + invalidParams.Add(request.NewErrParamRequired("PerRetryTimeout")) + } + if s.TcpRetryEvents != nil && len(s.TcpRetryEvents) < 1 { + invalidParams.Add(request.NewErrParamMinLen("TcpRetryEvents", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetGrpcRetryEvents sets the GrpcRetryEvents field's value. +func (s *GrpcRetryPolicy) SetGrpcRetryEvents(v []*string) *GrpcRetryPolicy { + s.GrpcRetryEvents = v + return s +} + +// SetHttpRetryEvents sets the HttpRetryEvents field's value. +func (s *GrpcRetryPolicy) SetHttpRetryEvents(v []*string) *GrpcRetryPolicy { + s.HttpRetryEvents = v + return s +} + +// SetMaxRetries sets the MaxRetries field's value. +func (s *GrpcRetryPolicy) SetMaxRetries(v int64) *GrpcRetryPolicy { + s.MaxRetries = &v + return s +} + +// SetPerRetryTimeout sets the PerRetryTimeout field's value. +func (s *GrpcRetryPolicy) SetPerRetryTimeout(v *Duration) *GrpcRetryPolicy { + s.PerRetryTimeout = v + return s +} + +// SetTcpRetryEvents sets the TcpRetryEvents field's value. +func (s *GrpcRetryPolicy) SetTcpRetryEvents(v []*string) *GrpcRetryPolicy { + s.TcpRetryEvents = v + return s +} + +type GrpcRoute struct { + _ struct{} `type:"structure"` + + // Action is a required field + Action *GrpcRouteAction `locationName:"action" type:"structure" required:"true"` + + // Match is a required field + Match *GrpcRouteMatch `locationName:"match" type:"structure" required:"true"` + + RetryPolicy *GrpcRetryPolicy `locationName:"retryPolicy" type:"structure"` + + Timeout *GrpcTimeout `locationName:"timeout" type:"structure"` +} + +// String returns the string representation +func (s GrpcRoute) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRoute) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRoute) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRoute"} + if s.Action == nil { + invalidParams.Add(request.NewErrParamRequired("Action")) + } + if s.Match == nil { + invalidParams.Add(request.NewErrParamRequired("Match")) + } + if s.Action != nil { + if err := s.Action.Validate(); err != nil { + invalidParams.AddNested("Action", err.(request.ErrInvalidParams)) + } + } + if s.Match != nil { + if err := s.Match.Validate(); err != nil { + invalidParams.AddNested("Match", err.(request.ErrInvalidParams)) + } + } + if s.RetryPolicy != nil { + if err := s.RetryPolicy.Validate(); err != nil { + invalidParams.AddNested("RetryPolicy", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAction sets the Action field's value. +func (s *GrpcRoute) SetAction(v *GrpcRouteAction) *GrpcRoute { + s.Action = v + return s +} + +// SetMatch sets the Match field's value. +func (s *GrpcRoute) SetMatch(v *GrpcRouteMatch) *GrpcRoute { + s.Match = v + return s +} + +// SetRetryPolicy sets the RetryPolicy field's value. +func (s *GrpcRoute) SetRetryPolicy(v *GrpcRetryPolicy) *GrpcRoute { + s.RetryPolicy = v + return s +} + +// SetTimeout sets the Timeout field's value. +func (s *GrpcRoute) SetTimeout(v *GrpcTimeout) *GrpcRoute { + s.Timeout = v + return s +} + +type GrpcRouteAction struct { + _ struct{} `type:"structure"` + + // WeightedTargets is a required field + WeightedTargets []*WeightedTarget `locationName:"weightedTargets" min:"1" type:"list" required:"true"` +} + +// String returns the string representation +func (s GrpcRouteAction) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRouteAction) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRouteAction) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRouteAction"} + if s.WeightedTargets == nil { + invalidParams.Add(request.NewErrParamRequired("WeightedTargets")) + } + if s.WeightedTargets != nil && len(s.WeightedTargets) < 1 { + invalidParams.Add(request.NewErrParamMinLen("WeightedTargets", 1)) + } + if s.WeightedTargets != nil { + for i, v := range s.WeightedTargets { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "WeightedTargets", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetWeightedTargets sets the WeightedTargets field's value. +func (s *GrpcRouteAction) SetWeightedTargets(v []*WeightedTarget) *GrpcRouteAction { + s.WeightedTargets = v + return s +} + +type GrpcRouteMatch struct { + _ struct{} `type:"structure"` + + Metadata []*GrpcRouteMetadata `locationName:"metadata" min:"1" type:"list"` + + MethodName *string `locationName:"methodName" min:"1" type:"string"` + + ServiceName *string `locationName:"serviceName" type:"string"` +} + +// String returns the string representation +func (s GrpcRouteMatch) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRouteMatch) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRouteMatch) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRouteMatch"} + if s.Metadata != nil && len(s.Metadata) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Metadata", 1)) + } + if s.MethodName != nil && len(*s.MethodName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MethodName", 1)) + } + if s.Metadata != nil { + for i, v := range s.Metadata { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Metadata", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetMetadata sets the Metadata field's value. +func (s *GrpcRouteMatch) SetMetadata(v []*GrpcRouteMetadata) *GrpcRouteMatch { + s.Metadata = v + return s +} + +// SetMethodName sets the MethodName field's value. +func (s *GrpcRouteMatch) SetMethodName(v string) *GrpcRouteMatch { + s.MethodName = &v + return s +} + +// SetServiceName sets the ServiceName field's value. +func (s *GrpcRouteMatch) SetServiceName(v string) *GrpcRouteMatch { + s.ServiceName = &v + return s +} + +type GrpcRouteMetadata struct { + _ struct{} `type:"structure"` + + Invert *bool `locationName:"invert" type:"boolean"` + + Match *GrpcRouteMetadataMatchMethod `locationName:"match" type:"structure"` + + // Name is a required field + Name *string `locationName:"name" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s GrpcRouteMetadata) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRouteMetadata) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRouteMetadata) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRouteMetadata"} + if s.Name == nil { + invalidParams.Add(request.NewErrParamRequired("Name")) + } + if s.Name != nil && len(*s.Name) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Name", 1)) + } + if s.Match != nil { + if err := s.Match.Validate(); err != nil { + invalidParams.AddNested("Match", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInvert sets the Invert field's value. +func (s *GrpcRouteMetadata) SetInvert(v bool) *GrpcRouteMetadata { + s.Invert = &v + return s +} + +// SetMatch sets the Match field's value. +func (s *GrpcRouteMetadata) SetMatch(v *GrpcRouteMetadataMatchMethod) *GrpcRouteMetadata { + s.Match = v + return s +} + +// SetName sets the Name field's value. +func (s *GrpcRouteMetadata) SetName(v string) *GrpcRouteMetadata { + s.Name = &v + return s +} + +type GrpcRouteMetadataMatchMethod struct { + _ struct{} `type:"structure"` + + Exact *string `locationName:"exact" min:"1" type:"string"` + + Prefix *string `locationName:"prefix" min:"1" type:"string"` + + Range *MatchRange `locationName:"range" type:"structure"` + + Regex *string `locationName:"regex" min:"1" type:"string"` + + Suffix *string `locationName:"suffix" min:"1" type:"string"` +} + +// String returns the string representation +func (s GrpcRouteMetadataMatchMethod) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcRouteMetadataMatchMethod) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GrpcRouteMetadataMatchMethod) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GrpcRouteMetadataMatchMethod"} + if s.Exact != nil && len(*s.Exact) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Exact", 1)) + } + if s.Prefix != nil && len(*s.Prefix) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Prefix", 1)) + } + if s.Regex != nil && len(*s.Regex) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Regex", 1)) + } + if s.Suffix != nil && len(*s.Suffix) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Suffix", 1)) + } + if s.Range != nil { + if err := s.Range.Validate(); err != nil { + invalidParams.AddNested("Range", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetExact sets the Exact field's value. +func (s *GrpcRouteMetadataMatchMethod) SetExact(v string) *GrpcRouteMetadataMatchMethod { + s.Exact = &v + return s +} + +// SetPrefix sets the Prefix field's value. +func (s *GrpcRouteMetadataMatchMethod) SetPrefix(v string) *GrpcRouteMetadataMatchMethod { + s.Prefix = &v + return s +} + +// SetRange sets the Range field's value. +func (s *GrpcRouteMetadataMatchMethod) SetRange(v *MatchRange) *GrpcRouteMetadataMatchMethod { + s.Range = v + return s +} + +// SetRegex sets the Regex field's value. +func (s *GrpcRouteMetadataMatchMethod) SetRegex(v string) *GrpcRouteMetadataMatchMethod { + s.Regex = &v + return s +} + +// SetSuffix sets the Suffix field's value. +func (s *GrpcRouteMetadataMatchMethod) SetSuffix(v string) *GrpcRouteMetadataMatchMethod { + s.Suffix = &v + return s +} + +type GrpcTimeout struct { + _ struct{} `type:"structure"` + + Idle *Duration `locationName:"idle" type:"structure"` + + PerRequest *Duration `locationName:"perRequest" type:"structure"` +} + +// String returns the string representation +func (s GrpcTimeout) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GrpcTimeout) GoString() string { + return s.String() +} + +// SetIdle sets the Idle field's value. +func (s *GrpcTimeout) SetIdle(v *Duration) *GrpcTimeout { + s.Idle = v + return s +} + +// SetPerRequest sets the PerRequest field's value. +func (s *GrpcTimeout) SetPerRequest(v *Duration) *GrpcTimeout { + s.PerRequest = v + return s +} + +type HeaderMatchMethod struct { + _ struct{} `type:"structure"` + + Exact *string `locationName:"exact" min:"1" type:"string"` + + Prefix *string `locationName:"prefix" min:"1" type:"string"` + + Range *MatchRange `locationName:"range" type:"structure"` + + Regex *string `locationName:"regex" min:"1" type:"string"` + + Suffix *string `locationName:"suffix" min:"1" type:"string"` +} + +// String returns the string representation +func (s HeaderMatchMethod) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HeaderMatchMethod) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HeaderMatchMethod) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HeaderMatchMethod"} + if s.Exact != nil && len(*s.Exact) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Exact", 1)) + } + if s.Prefix != nil && len(*s.Prefix) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Prefix", 1)) + } + if s.Regex != nil && len(*s.Regex) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Regex", 1)) + } + if s.Suffix != nil && len(*s.Suffix) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Suffix", 1)) + } + if s.Range != nil { + if err := s.Range.Validate(); err != nil { + invalidParams.AddNested("Range", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetExact sets the Exact field's value. +func (s *HeaderMatchMethod) SetExact(v string) *HeaderMatchMethod { + s.Exact = &v + return s +} + +// SetPrefix sets the Prefix field's value. +func (s *HeaderMatchMethod) SetPrefix(v string) *HeaderMatchMethod { + s.Prefix = &v + return s +} + +// SetRange sets the Range field's value. +func (s *HeaderMatchMethod) SetRange(v *MatchRange) *HeaderMatchMethod { + s.Range = v + return s +} + +// SetRegex sets the Regex field's value. +func (s *HeaderMatchMethod) SetRegex(v string) *HeaderMatchMethod { + s.Regex = &v + return s +} + +// SetSuffix sets the Suffix field's value. +func (s *HeaderMatchMethod) SetSuffix(v string) *HeaderMatchMethod { + s.Suffix = &v + return s +} + +type HealthCheckPolicy struct { + _ struct{} `type:"structure"` + + // HealthyThreshold is a required field + HealthyThreshold *int64 `locationName:"healthyThreshold" min:"2" type:"integer" required:"true"` + + // IntervalMillis is a required field + IntervalMillis *int64 `locationName:"intervalMillis" min:"5000" type:"long" required:"true"` + + Path *string `locationName:"path" type:"string"` + + Port *int64 `locationName:"port" min:"1" type:"integer"` + + // Protocol is a required field + Protocol *string `locationName:"protocol" type:"string" required:"true" enum:"PortProtocol"` + + // TimeoutMillis is a required field + TimeoutMillis *int64 `locationName:"timeoutMillis" min:"2000" type:"long" required:"true"` + + // UnhealthyThreshold is a required field + UnhealthyThreshold *int64 `locationName:"unhealthyThreshold" min:"2" type:"integer" required:"true"` +} + +// String returns the string representation +func (s HealthCheckPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HealthCheckPolicy) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HealthCheckPolicy) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HealthCheckPolicy"} + if s.HealthyThreshold == nil { + invalidParams.Add(request.NewErrParamRequired("HealthyThreshold")) + } + if s.HealthyThreshold != nil && *s.HealthyThreshold < 2 { + invalidParams.Add(request.NewErrParamMinValue("HealthyThreshold", 2)) + } + if s.IntervalMillis == nil { + invalidParams.Add(request.NewErrParamRequired("IntervalMillis")) + } + if s.IntervalMillis != nil && *s.IntervalMillis < 5000 { + invalidParams.Add(request.NewErrParamMinValue("IntervalMillis", 5000)) + } + if s.Port != nil && *s.Port < 1 { + invalidParams.Add(request.NewErrParamMinValue("Port", 1)) + } + if s.Protocol == nil { + invalidParams.Add(request.NewErrParamRequired("Protocol")) + } + if s.TimeoutMillis == nil { + invalidParams.Add(request.NewErrParamRequired("TimeoutMillis")) + } + if s.TimeoutMillis != nil && *s.TimeoutMillis < 2000 { + invalidParams.Add(request.NewErrParamMinValue("TimeoutMillis", 2000)) + } + if s.UnhealthyThreshold == nil { + invalidParams.Add(request.NewErrParamRequired("UnhealthyThreshold")) + } + if s.UnhealthyThreshold != nil && *s.UnhealthyThreshold < 2 { + invalidParams.Add(request.NewErrParamMinValue("UnhealthyThreshold", 2)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetHealthyThreshold sets the HealthyThreshold field's value. +func (s *HealthCheckPolicy) SetHealthyThreshold(v int64) *HealthCheckPolicy { + s.HealthyThreshold = &v + return s +} + +// SetIntervalMillis sets the IntervalMillis field's value. +func (s *HealthCheckPolicy) SetIntervalMillis(v int64) *HealthCheckPolicy { + s.IntervalMillis = &v + return s +} + +// SetPath sets the Path field's value. +func (s *HealthCheckPolicy) SetPath(v string) *HealthCheckPolicy { + s.Path = &v + return s +} + +// SetPort sets the Port field's value. +func (s *HealthCheckPolicy) SetPort(v int64) *HealthCheckPolicy { + s.Port = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *HealthCheckPolicy) SetProtocol(v string) *HealthCheckPolicy { + s.Protocol = &v + return s +} + +// SetTimeoutMillis sets the TimeoutMillis field's value. +func (s *HealthCheckPolicy) SetTimeoutMillis(v int64) *HealthCheckPolicy { + s.TimeoutMillis = &v + return s +} + +// SetUnhealthyThreshold sets the UnhealthyThreshold field's value. +func (s *HealthCheckPolicy) SetUnhealthyThreshold(v int64) *HealthCheckPolicy { + s.UnhealthyThreshold = &v + return s +} + +type HttpRetryPolicy struct { + _ struct{} `type:"structure"` + + HttpRetryEvents []*string `locationName:"httpRetryEvents" min:"1" type:"list"` + + // MaxRetries is a required field + MaxRetries *int64 `locationName:"maxRetries" type:"long" required:"true"` + + // PerRetryTimeout is a required field + PerRetryTimeout *Duration `locationName:"perRetryTimeout" type:"structure" required:"true"` + + TcpRetryEvents []*string `locationName:"tcpRetryEvents" min:"1" type:"list"` +} + +// String returns the string representation +func (s HttpRetryPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpRetryPolicy) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HttpRetryPolicy) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HttpRetryPolicy"} + if s.HttpRetryEvents != nil && len(s.HttpRetryEvents) < 1 { + invalidParams.Add(request.NewErrParamMinLen("HttpRetryEvents", 1)) + } + if s.MaxRetries == nil { + invalidParams.Add(request.NewErrParamRequired("MaxRetries")) + } + if s.PerRetryTimeout == nil { + invalidParams.Add(request.NewErrParamRequired("PerRetryTimeout")) + } + if s.TcpRetryEvents != nil && len(s.TcpRetryEvents) < 1 { + invalidParams.Add(request.NewErrParamMinLen("TcpRetryEvents", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetHttpRetryEvents sets the HttpRetryEvents field's value. +func (s *HttpRetryPolicy) SetHttpRetryEvents(v []*string) *HttpRetryPolicy { + s.HttpRetryEvents = v + return s +} + +// SetMaxRetries sets the MaxRetries field's value. +func (s *HttpRetryPolicy) SetMaxRetries(v int64) *HttpRetryPolicy { + s.MaxRetries = &v + return s +} + +// SetPerRetryTimeout sets the PerRetryTimeout field's value. +func (s *HttpRetryPolicy) SetPerRetryTimeout(v *Duration) *HttpRetryPolicy { + s.PerRetryTimeout = v + return s +} + +// SetTcpRetryEvents sets the TcpRetryEvents field's value. +func (s *HttpRetryPolicy) SetTcpRetryEvents(v []*string) *HttpRetryPolicy { + s.TcpRetryEvents = v + return s +} + +type HttpRoute struct { + _ struct{} `type:"structure"` + + // Action is a required field + Action *HttpRouteAction `locationName:"action" type:"structure" required:"true"` + + // Match is a required field + Match *HttpRouteMatch `locationName:"match" type:"structure" required:"true"` + + RetryPolicy *HttpRetryPolicy `locationName:"retryPolicy" type:"structure"` + + Timeout *HttpTimeout `locationName:"timeout" type:"structure"` +} + +// String returns the string representation +func (s HttpRoute) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpRoute) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HttpRoute) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HttpRoute"} + if s.Action == nil { + invalidParams.Add(request.NewErrParamRequired("Action")) + } + if s.Match == nil { + invalidParams.Add(request.NewErrParamRequired("Match")) + } + if s.Action != nil { + if err := s.Action.Validate(); err != nil { + invalidParams.AddNested("Action", err.(request.ErrInvalidParams)) + } + } + if s.Match != nil { + if err := s.Match.Validate(); err != nil { + invalidParams.AddNested("Match", err.(request.ErrInvalidParams)) + } + } + if s.RetryPolicy != nil { + if err := s.RetryPolicy.Validate(); err != nil { + invalidParams.AddNested("RetryPolicy", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAction sets the Action field's value. +func (s *HttpRoute) SetAction(v *HttpRouteAction) *HttpRoute { + s.Action = v + return s +} + +// SetMatch sets the Match field's value. +func (s *HttpRoute) SetMatch(v *HttpRouteMatch) *HttpRoute { + s.Match = v + return s +} + +// SetRetryPolicy sets the RetryPolicy field's value. +func (s *HttpRoute) SetRetryPolicy(v *HttpRetryPolicy) *HttpRoute { + s.RetryPolicy = v + return s +} + +// SetTimeout sets the Timeout field's value. +func (s *HttpRoute) SetTimeout(v *HttpTimeout) *HttpRoute { + s.Timeout = v + return s +} + +type HttpRouteAction struct { + _ struct{} `type:"structure"` + + // WeightedTargets is a required field + WeightedTargets []*WeightedTarget `locationName:"weightedTargets" min:"1" type:"list" required:"true"` +} + +// String returns the string representation +func (s HttpRouteAction) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpRouteAction) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HttpRouteAction) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HttpRouteAction"} + if s.WeightedTargets == nil { + invalidParams.Add(request.NewErrParamRequired("WeightedTargets")) + } + if s.WeightedTargets != nil && len(s.WeightedTargets) < 1 { + invalidParams.Add(request.NewErrParamMinLen("WeightedTargets", 1)) + } + if s.WeightedTargets != nil { + for i, v := range s.WeightedTargets { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "WeightedTargets", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetWeightedTargets sets the WeightedTargets field's value. +func (s *HttpRouteAction) SetWeightedTargets(v []*WeightedTarget) *HttpRouteAction { + s.WeightedTargets = v + return s +} + +type HttpRouteHeader struct { + _ struct{} `type:"structure"` + + Invert *bool `locationName:"invert" type:"boolean"` + + Match *HeaderMatchMethod `locationName:"match" type:"structure"` + + // Name is a required field + Name *string `locationName:"name" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s HttpRouteHeader) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpRouteHeader) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HttpRouteHeader) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HttpRouteHeader"} + if s.Name == nil { + invalidParams.Add(request.NewErrParamRequired("Name")) + } + if s.Name != nil && len(*s.Name) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Name", 1)) + } + if s.Match != nil { + if err := s.Match.Validate(); err != nil { + invalidParams.AddNested("Match", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInvert sets the Invert field's value. +func (s *HttpRouteHeader) SetInvert(v bool) *HttpRouteHeader { + s.Invert = &v + return s +} + +// SetMatch sets the Match field's value. +func (s *HttpRouteHeader) SetMatch(v *HeaderMatchMethod) *HttpRouteHeader { + s.Match = v + return s +} + +// SetName sets the Name field's value. +func (s *HttpRouteHeader) SetName(v string) *HttpRouteHeader { + s.Name = &v + return s +} + +type HttpRouteMatch struct { + _ struct{} `type:"structure"` + + Headers []*HttpRouteHeader `locationName:"headers" min:"1" type:"list"` + + Method *string `locationName:"method" type:"string" enum:"HttpMethod"` + + // Prefix is a required field + Prefix *string `locationName:"prefix" type:"string" required:"true"` + + Scheme *string `locationName:"scheme" type:"string" enum:"HttpScheme"` +} + +// String returns the string representation +func (s HttpRouteMatch) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpRouteMatch) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *HttpRouteMatch) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "HttpRouteMatch"} + if s.Headers != nil && len(s.Headers) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Headers", 1)) + } + if s.Prefix == nil { + invalidParams.Add(request.NewErrParamRequired("Prefix")) + } + if s.Headers != nil { + for i, v := range s.Headers { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Headers", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetHeaders sets the Headers field's value. +func (s *HttpRouteMatch) SetHeaders(v []*HttpRouteHeader) *HttpRouteMatch { + s.Headers = v + return s +} + +// SetMethod sets the Method field's value. +func (s *HttpRouteMatch) SetMethod(v string) *HttpRouteMatch { + s.Method = &v + return s +} + +// SetPrefix sets the Prefix field's value. +func (s *HttpRouteMatch) SetPrefix(v string) *HttpRouteMatch { + s.Prefix = &v + return s +} + +// SetScheme sets the Scheme field's value. +func (s *HttpRouteMatch) SetScheme(v string) *HttpRouteMatch { + s.Scheme = &v + return s +} + +type HttpTimeout struct { + _ struct{} `type:"structure"` + + Idle *Duration `locationName:"idle" type:"structure"` + + PerRequest *Duration `locationName:"perRequest" type:"structure"` +} + +// String returns the string representation +func (s HttpTimeout) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HttpTimeout) GoString() string { + return s.String() +} + +// SetIdle sets the Idle field's value. +func (s *HttpTimeout) SetIdle(v *Duration) *HttpTimeout { + s.Idle = v + return s +} + +// SetPerRequest sets the PerRequest field's value. +func (s *HttpTimeout) SetPerRequest(v *Duration) *HttpTimeout { + s.PerRequest = v + return s +} + +type InternalServerErrorException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s InternalServerErrorException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InternalServerErrorException) GoString() string { + return s.String() +} + +func newErrorInternalServerErrorException(v protocol.ResponseMetadata) error { + return &InternalServerErrorException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s InternalServerErrorException) Code() string { + return "InternalServerErrorException" +} + +// Message returns the exception's message. +func (s InternalServerErrorException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s InternalServerErrorException) OrigErr() error { + return nil +} + +func (s InternalServerErrorException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s InternalServerErrorException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s InternalServerErrorException) RequestID() string { + return s.respMetadata.RequestID +} + +type LimitExceededException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s LimitExceededException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LimitExceededException) GoString() string { + return s.String() +} + +func newErrorLimitExceededException(v protocol.ResponseMetadata) error { + return &LimitExceededException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s LimitExceededException) Code() string { + return "LimitExceededException" +} + +// Message returns the exception's message. +func (s LimitExceededException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s LimitExceededException) OrigErr() error { + return nil +} + +func (s LimitExceededException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s LimitExceededException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s LimitExceededException) RequestID() string { + return s.respMetadata.RequestID +} + +type ListMeshesInput struct { + _ struct{} `type:"structure"` + + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + NextToken *string `location:"querystring" locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListMeshesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListMeshesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListMeshesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListMeshesInput"} + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListMeshesInput) SetLimit(v int64) *ListMeshesInput { + s.Limit = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ListMeshesInput) SetMeshOwner(v string) *ListMeshesInput { + s.MeshOwner = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListMeshesInput) SetNextToken(v string) *ListMeshesInput { + s.NextToken = &v + return s +} + +type ListMeshesOutput struct { + _ struct{} `type:"structure"` + + // Meshes is a required field + Meshes []*MeshRef `locationName:"meshes" type:"list" required:"true"` + + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListMeshesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListMeshesOutput) GoString() string { + return s.String() +} + +// SetMeshes sets the Meshes field's value. +func (s *ListMeshesOutput) SetMeshes(v []*MeshRef) *ListMeshesOutput { + s.Meshes = v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListMeshesOutput) SetNextToken(v string) *ListMeshesOutput { + s.NextToken = &v + return s +} + +type ListRoutesInput struct { + _ struct{} `type:"structure"` + + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + NextToken *string `location:"querystring" locationName:"nextToken" type:"string"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListRoutesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListRoutesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListRoutesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListRoutesInput"} + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListRoutesInput) SetLimit(v int64) *ListRoutesInput { + s.Limit = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *ListRoutesInput) SetMeshName(v string) *ListRoutesInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ListRoutesInput) SetMeshOwner(v string) *ListRoutesInput { + s.MeshOwner = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListRoutesInput) SetNextToken(v string) *ListRoutesInput { + s.NextToken = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *ListRoutesInput) SetVirtualRouterName(v string) *ListRoutesInput { + s.VirtualRouterName = &v + return s +} + +type ListRoutesOutput struct { + _ struct{} `type:"structure"` + + NextToken *string `locationName:"nextToken" type:"string"` + + // Routes is a required field + Routes []*RouteRef `locationName:"routes" type:"list" required:"true"` +} + +// String returns the string representation +func (s ListRoutesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListRoutesOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListRoutesOutput) SetNextToken(v string) *ListRoutesOutput { + s.NextToken = &v + return s +} + +// SetRoutes sets the Routes field's value. +func (s *ListRoutesOutput) SetRoutes(v []*RouteRef) *ListRoutesOutput { + s.Routes = v + return s +} + +type ListVirtualNodesInput struct { + _ struct{} `type:"structure"` + + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + NextToken *string `location:"querystring" locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListVirtualNodesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualNodesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListVirtualNodesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListVirtualNodesInput"} + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListVirtualNodesInput) SetLimit(v int64) *ListVirtualNodesInput { + s.Limit = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *ListVirtualNodesInput) SetMeshName(v string) *ListVirtualNodesInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ListVirtualNodesInput) SetMeshOwner(v string) *ListVirtualNodesInput { + s.MeshOwner = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualNodesInput) SetNextToken(v string) *ListVirtualNodesInput { + s.NextToken = &v + return s +} + +type ListVirtualNodesOutput struct { + _ struct{} `type:"structure"` + + NextToken *string `locationName:"nextToken" type:"string"` + + // VirtualNodes is a required field + VirtualNodes []*VirtualNodeRef `locationName:"virtualNodes" type:"list" required:"true"` +} + +// String returns the string representation +func (s ListVirtualNodesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualNodesOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualNodesOutput) SetNextToken(v string) *ListVirtualNodesOutput { + s.NextToken = &v + return s +} + +// SetVirtualNodes sets the VirtualNodes field's value. +func (s *ListVirtualNodesOutput) SetVirtualNodes(v []*VirtualNodeRef) *ListVirtualNodesOutput { + s.VirtualNodes = v + return s +} + +type ListVirtualRoutersInput struct { + _ struct{} `type:"structure"` + + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + NextToken *string `location:"querystring" locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListVirtualRoutersInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualRoutersInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListVirtualRoutersInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListVirtualRoutersInput"} + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListVirtualRoutersInput) SetLimit(v int64) *ListVirtualRoutersInput { + s.Limit = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *ListVirtualRoutersInput) SetMeshName(v string) *ListVirtualRoutersInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ListVirtualRoutersInput) SetMeshOwner(v string) *ListVirtualRoutersInput { + s.MeshOwner = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualRoutersInput) SetNextToken(v string) *ListVirtualRoutersInput { + s.NextToken = &v + return s +} + +type ListVirtualRoutersOutput struct { + _ struct{} `type:"structure"` + + NextToken *string `locationName:"nextToken" type:"string"` + + // VirtualRouters is a required field + VirtualRouters []*VirtualRouterRef `locationName:"virtualRouters" type:"list" required:"true"` +} + +// String returns the string representation +func (s ListVirtualRoutersOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualRoutersOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualRoutersOutput) SetNextToken(v string) *ListVirtualRoutersOutput { + s.NextToken = &v + return s +} + +// SetVirtualRouters sets the VirtualRouters field's value. +func (s *ListVirtualRoutersOutput) SetVirtualRouters(v []*VirtualRouterRef) *ListVirtualRoutersOutput { + s.VirtualRouters = v + return s +} + +type ListVirtualServicesInput struct { + _ struct{} `type:"structure"` + + Limit *int64 `location:"querystring" locationName:"limit" min:"1" type:"integer"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + NextToken *string `location:"querystring" locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s ListVirtualServicesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualServicesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListVirtualServicesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListVirtualServicesInput"} + if s.Limit != nil && *s.Limit < 1 { + invalidParams.Add(request.NewErrParamMinValue("Limit", 1)) + } + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLimit sets the Limit field's value. +func (s *ListVirtualServicesInput) SetLimit(v int64) *ListVirtualServicesInput { + s.Limit = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *ListVirtualServicesInput) SetMeshName(v string) *ListVirtualServicesInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ListVirtualServicesInput) SetMeshOwner(v string) *ListVirtualServicesInput { + s.MeshOwner = &v + return s +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualServicesInput) SetNextToken(v string) *ListVirtualServicesInput { + s.NextToken = &v + return s +} + +type ListVirtualServicesOutput struct { + _ struct{} `type:"structure"` + + NextToken *string `locationName:"nextToken" type:"string"` + + // VirtualServices is a required field + VirtualServices []*VirtualServiceRef `locationName:"virtualServices" type:"list" required:"true"` +} + +// String returns the string representation +func (s ListVirtualServicesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListVirtualServicesOutput) GoString() string { + return s.String() +} + +// SetNextToken sets the NextToken field's value. +func (s *ListVirtualServicesOutput) SetNextToken(v string) *ListVirtualServicesOutput { + s.NextToken = &v + return s +} + +// SetVirtualServices sets the VirtualServices field's value. +func (s *ListVirtualServicesOutput) SetVirtualServices(v []*VirtualServiceRef) *ListVirtualServicesOutput { + s.VirtualServices = v + return s +} + +type Listener struct { + _ struct{} `type:"structure"` + + HealthCheck *HealthCheckPolicy `locationName:"healthCheck" type:"structure"` + + // PortMapping is a required field + PortMapping *PortMapping `locationName:"portMapping" type:"structure" required:"true"` + + Tls *ListenerTls `locationName:"tls" type:"structure"` +} + +// String returns the string representation +func (s Listener) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Listener) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *Listener) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "Listener"} + if s.PortMapping == nil { + invalidParams.Add(request.NewErrParamRequired("PortMapping")) + } + if s.HealthCheck != nil { + if err := s.HealthCheck.Validate(); err != nil { + invalidParams.AddNested("HealthCheck", err.(request.ErrInvalidParams)) + } + } + if s.PortMapping != nil { + if err := s.PortMapping.Validate(); err != nil { + invalidParams.AddNested("PortMapping", err.(request.ErrInvalidParams)) + } + } + if s.Tls != nil { + if err := s.Tls.Validate(); err != nil { + invalidParams.AddNested("Tls", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetHealthCheck sets the HealthCheck field's value. +func (s *Listener) SetHealthCheck(v *HealthCheckPolicy) *Listener { + s.HealthCheck = v + return s +} + +// SetPortMapping sets the PortMapping field's value. +func (s *Listener) SetPortMapping(v *PortMapping) *Listener { + s.PortMapping = v + return s +} + +// SetTls sets the Tls field's value. +func (s *Listener) SetTls(v *ListenerTls) *Listener { + s.Tls = v + return s +} + +type ListenerTls struct { + _ struct{} `type:"structure"` + + // Certificate is a required field + Certificate *ListenerTlsCertificate `locationName:"certificate" type:"structure" required:"true"` + + // Mode is a required field + Mode *string `locationName:"mode" type:"string" required:"true" enum:"ListenerTlsMode"` +} + +// String returns the string representation +func (s ListenerTls) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListenerTls) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListenerTls) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListenerTls"} + if s.Certificate == nil { + invalidParams.Add(request.NewErrParamRequired("Certificate")) + } + if s.Mode == nil { + invalidParams.Add(request.NewErrParamRequired("Mode")) + } + if s.Certificate != nil { + if err := s.Certificate.Validate(); err != nil { + invalidParams.AddNested("Certificate", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificate sets the Certificate field's value. +func (s *ListenerTls) SetCertificate(v *ListenerTlsCertificate) *ListenerTls { + s.Certificate = v + return s +} + +// SetMode sets the Mode field's value. +func (s *ListenerTls) SetMode(v string) *ListenerTls { + s.Mode = &v + return s +} + +type ListenerTlsAcmCertificate struct { + _ struct{} `type:"structure"` + + // CertificateArn is a required field + CertificateArn *string `locationName:"certificateArn" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListenerTlsAcmCertificate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListenerTlsAcmCertificate) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListenerTlsAcmCertificate) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListenerTlsAcmCertificate"} + if s.CertificateArn == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateArn")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateArn sets the CertificateArn field's value. +func (s *ListenerTlsAcmCertificate) SetCertificateArn(v string) *ListenerTlsAcmCertificate { + s.CertificateArn = &v + return s +} + +type ListenerTlsCertificate struct { + _ struct{} `type:"structure"` + + Acm *ListenerTlsAcmCertificate `locationName:"acm" type:"structure"` + + File *ListenerTlsFileCertificate `locationName:"file" type:"structure"` + + Sds *ListenerTlsSdsCertificate `locationName:"sds" type:"structure"` +} + +// String returns the string representation +func (s ListenerTlsCertificate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListenerTlsCertificate) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListenerTlsCertificate) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListenerTlsCertificate"} + if s.Acm != nil { + if err := s.Acm.Validate(); err != nil { + invalidParams.AddNested("Acm", err.(request.ErrInvalidParams)) + } + } + if s.File != nil { + if err := s.File.Validate(); err != nil { + invalidParams.AddNested("File", err.(request.ErrInvalidParams)) + } + } + if s.Sds != nil { + if err := s.Sds.Validate(); err != nil { + invalidParams.AddNested("Sds", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAcm sets the Acm field's value. +func (s *ListenerTlsCertificate) SetAcm(v *ListenerTlsAcmCertificate) *ListenerTlsCertificate { + s.Acm = v + return s +} + +// SetFile sets the File field's value. +func (s *ListenerTlsCertificate) SetFile(v *ListenerTlsFileCertificate) *ListenerTlsCertificate { + s.File = v + return s +} + +// SetSds sets the Sds field's value. +func (s *ListenerTlsCertificate) SetSds(v *ListenerTlsSdsCertificate) *ListenerTlsCertificate { + s.Sds = v + return s +} + +type ListenerTlsFileCertificate struct { + _ struct{} `type:"structure"` + + // CertificateChain is a required field + CertificateChain *string `locationName:"certificateChain" min:"1" type:"string" required:"true"` + + // PrivateKey is a required field + PrivateKey *string `locationName:"privateKey" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s ListenerTlsFileCertificate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListenerTlsFileCertificate) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListenerTlsFileCertificate) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListenerTlsFileCertificate"} + if s.CertificateChain == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateChain")) + } + if s.CertificateChain != nil && len(*s.CertificateChain) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CertificateChain", 1)) + } + if s.PrivateKey == nil { + invalidParams.Add(request.NewErrParamRequired("PrivateKey")) + } + if s.PrivateKey != nil && len(*s.PrivateKey) < 1 { + invalidParams.Add(request.NewErrParamMinLen("PrivateKey", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateChain sets the CertificateChain field's value. +func (s *ListenerTlsFileCertificate) SetCertificateChain(v string) *ListenerTlsFileCertificate { + s.CertificateChain = &v + return s +} + +// SetPrivateKey sets the PrivateKey field's value. +func (s *ListenerTlsFileCertificate) SetPrivateKey(v string) *ListenerTlsFileCertificate { + s.PrivateKey = &v + return s +} + +type ListenerTlsSdsCertificate struct { + _ struct{} `type:"structure"` + + // SecretName is a required field + SecretName *string `locationName:"secretName" type:"string" required:"true"` + + // Source is a required field + Source *SdsSource `locationName:"source" type:"structure" required:"true"` +} + +// String returns the string representation +func (s ListenerTlsSdsCertificate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ListenerTlsSdsCertificate) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListenerTlsSdsCertificate) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ListenerTlsSdsCertificate"} + if s.SecretName == nil { + invalidParams.Add(request.NewErrParamRequired("SecretName")) + } + if s.Source == nil { + invalidParams.Add(request.NewErrParamRequired("Source")) + } + if s.Source != nil { + if err := s.Source.Validate(); err != nil { + invalidParams.AddNested("Source", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetSecretName sets the SecretName field's value. +func (s *ListenerTlsSdsCertificate) SetSecretName(v string) *ListenerTlsSdsCertificate { + s.SecretName = &v + return s +} + +// SetSource sets the Source field's value. +func (s *ListenerTlsSdsCertificate) SetSource(v *SdsSource) *ListenerTlsSdsCertificate { + s.Source = v + return s +} + +type Logging struct { + _ struct{} `type:"structure"` + + AccessLog *AccessLog `locationName:"accessLog" type:"structure"` +} + +// String returns the string representation +func (s Logging) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Logging) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *Logging) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "Logging"} + if s.AccessLog != nil { + if err := s.AccessLog.Validate(); err != nil { + invalidParams.AddNested("AccessLog", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAccessLog sets the AccessLog field's value. +func (s *Logging) SetAccessLog(v *AccessLog) *Logging { + s.AccessLog = v + return s +} + +type MatchRange struct { + _ struct{} `type:"structure"` + + // End is a required field + End *int64 `locationName:"end" type:"long" required:"true"` + + // Start is a required field + Start *int64 `locationName:"start" type:"long" required:"true"` +} + +// String returns the string representation +func (s MatchRange) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MatchRange) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *MatchRange) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "MatchRange"} + if s.End == nil { + invalidParams.Add(request.NewErrParamRequired("End")) + } + if s.Start == nil { + invalidParams.Add(request.NewErrParamRequired("Start")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEnd sets the End field's value. +func (s *MatchRange) SetEnd(v int64) *MatchRange { + s.End = &v + return s +} + +// SetStart sets the Start field's value. +func (s *MatchRange) SetStart(v int64) *MatchRange { + s.Start = &v + return s +} + +type MeshData struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // Metadata is a required field + Metadata *ResourceMetadata `locationName:"metadata" type:"structure" required:"true"` + + // Spec is a required field + Spec *MeshSpec `locationName:"spec" type:"structure" required:"true"` + + // Status is a required field + Status *MeshStatus `locationName:"status" type:"structure" required:"true"` +} + +// String returns the string representation +func (s MeshData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MeshData) GoString() string { + return s.String() +} + +// SetMeshName sets the MeshName field's value. +func (s *MeshData) SetMeshName(v string) *MeshData { + s.MeshName = &v + return s +} + +// SetMetadata sets the Metadata field's value. +func (s *MeshData) SetMetadata(v *ResourceMetadata) *MeshData { + s.Metadata = v + return s +} + +// SetSpec sets the Spec field's value. +func (s *MeshData) SetSpec(v *MeshSpec) *MeshData { + s.Spec = v + return s +} + +// SetStatus sets the Status field's value. +func (s *MeshData) SetStatus(v *MeshStatus) *MeshData { + s.Status = v + return s +} + +type MeshRef struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` +} + +// String returns the string representation +func (s MeshRef) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MeshRef) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *MeshRef) SetArn(v string) *MeshRef { + s.Arn = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *MeshRef) SetMeshName(v string) *MeshRef { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *MeshRef) SetMeshOwner(v string) *MeshRef { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *MeshRef) SetResourceOwner(v string) *MeshRef { + s.ResourceOwner = &v + return s +} + +type MeshSpec struct { + _ struct{} `type:"structure"` + + EgressFilter *EgressFilter `locationName:"egressFilter" type:"structure"` +} + +// String returns the string representation +func (s MeshSpec) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MeshSpec) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *MeshSpec) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "MeshSpec"} + if s.EgressFilter != nil { + if err := s.EgressFilter.Validate(); err != nil { + invalidParams.AddNested("EgressFilter", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEgressFilter sets the EgressFilter field's value. +func (s *MeshSpec) SetEgressFilter(v *EgressFilter) *MeshSpec { + s.EgressFilter = v + return s +} + +type MeshStatus struct { + _ struct{} `type:"structure"` + + Status *string `locationName:"status" type:"string" enum:"MeshStatusCode"` +} + +// String returns the string representation +func (s MeshStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MeshStatus) GoString() string { + return s.String() +} + +// SetStatus sets the Status field's value. +func (s *MeshStatus) SetStatus(v string) *MeshStatus { + s.Status = &v + return s +} + +type NotFoundException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s NotFoundException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s NotFoundException) GoString() string { + return s.String() +} + +func newErrorNotFoundException(v protocol.ResponseMetadata) error { + return &NotFoundException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s NotFoundException) Code() string { + return "NotFoundException" +} + +// Message returns the exception's message. +func (s NotFoundException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s NotFoundException) OrigErr() error { + return nil +} + +func (s NotFoundException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s NotFoundException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s NotFoundException) RequestID() string { + return s.respMetadata.RequestID +} + +type PortMapping struct { + _ struct{} `type:"structure"` + + // Port is a required field + Port *int64 `locationName:"port" min:"1" type:"integer" required:"true"` + + // Protocol is a required field + Protocol *string `locationName:"protocol" type:"string" required:"true" enum:"PortProtocol"` +} + +// String returns the string representation +func (s PortMapping) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PortMapping) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *PortMapping) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "PortMapping"} + if s.Port == nil { + invalidParams.Add(request.NewErrParamRequired("Port")) + } + if s.Port != nil && *s.Port < 1 { + invalidParams.Add(request.NewErrParamMinValue("Port", 1)) + } + if s.Protocol == nil { + invalidParams.Add(request.NewErrParamRequired("Protocol")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPort sets the Port field's value. +func (s *PortMapping) SetPort(v int64) *PortMapping { + s.Port = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *PortMapping) SetProtocol(v string) *PortMapping { + s.Protocol = &v + return s +} + +type ResourceInUseException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s ResourceInUseException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ResourceInUseException) GoString() string { + return s.String() +} + +func newErrorResourceInUseException(v protocol.ResponseMetadata) error { + return &ResourceInUseException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s ResourceInUseException) Code() string { + return "ResourceInUseException" +} + +// Message returns the exception's message. +func (s ResourceInUseException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s ResourceInUseException) OrigErr() error { + return nil +} + +func (s ResourceInUseException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s ResourceInUseException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s ResourceInUseException) RequestID() string { + return s.respMetadata.RequestID +} + +type ResourceMetadata struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // CreatedAt is a required field + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" required:"true"` + + // LastUpdatedAt is a required field + LastUpdatedAt *time.Time `locationName:"lastUpdatedAt" type:"timestamp" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` + + // Uid is a required field + Uid *string `locationName:"uid" type:"string" required:"true"` + + // Version is a required field + Version *int64 `locationName:"version" type:"long" required:"true"` +} + +// String returns the string representation +func (s ResourceMetadata) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ResourceMetadata) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *ResourceMetadata) SetArn(v string) *ResourceMetadata { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *ResourceMetadata) SetCreatedAt(v time.Time) *ResourceMetadata { + s.CreatedAt = &v + return s +} + +// SetLastUpdatedAt sets the LastUpdatedAt field's value. +func (s *ResourceMetadata) SetLastUpdatedAt(v time.Time) *ResourceMetadata { + s.LastUpdatedAt = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *ResourceMetadata) SetMeshOwner(v string) *ResourceMetadata { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *ResourceMetadata) SetResourceOwner(v string) *ResourceMetadata { + s.ResourceOwner = &v + return s +} + +// SetUid sets the Uid field's value. +func (s *ResourceMetadata) SetUid(v string) *ResourceMetadata { + s.Uid = &v + return s +} + +// SetVersion sets the Version field's value. +func (s *ResourceMetadata) SetVersion(v int64) *ResourceMetadata { + s.Version = &v + return s +} + +type RouteData struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // Metadata is a required field + Metadata *ResourceMetadata `locationName:"metadata" type:"structure" required:"true"` + + // RouteName is a required field + RouteName *string `locationName:"routeName" min:"1" type:"string" required:"true"` + + // Spec is a required field + Spec *RouteSpec `locationName:"spec" type:"structure" required:"true"` + + // Status is a required field + Status *RouteStatus `locationName:"status" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s RouteData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RouteData) GoString() string { + return s.String() +} + +// SetMeshName sets the MeshName field's value. +func (s *RouteData) SetMeshName(v string) *RouteData { + s.MeshName = &v + return s +} + +// SetMetadata sets the Metadata field's value. +func (s *RouteData) SetMetadata(v *ResourceMetadata) *RouteData { + s.Metadata = v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *RouteData) SetRouteName(v string) *RouteData { + s.RouteName = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *RouteData) SetSpec(v *RouteSpec) *RouteData { + s.Spec = v + return s +} + +// SetStatus sets the Status field's value. +func (s *RouteData) SetStatus(v *RouteStatus) *RouteData { + s.Status = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *RouteData) SetVirtualRouterName(v string) *RouteData { + s.VirtualRouterName = &v + return s +} + +type RouteRef struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` + + // RouteName is a required field + RouteName *string `locationName:"routeName" min:"1" type:"string" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s RouteRef) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RouteRef) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *RouteRef) SetArn(v string) *RouteRef { + s.Arn = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *RouteRef) SetMeshName(v string) *RouteRef { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *RouteRef) SetMeshOwner(v string) *RouteRef { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *RouteRef) SetResourceOwner(v string) *RouteRef { + s.ResourceOwner = &v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *RouteRef) SetRouteName(v string) *RouteRef { + s.RouteName = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *RouteRef) SetVirtualRouterName(v string) *RouteRef { + s.VirtualRouterName = &v + return s +} + +type RouteSpec struct { + _ struct{} `type:"structure"` + + GrpcRoute *GrpcRoute `locationName:"grpcRoute" type:"structure"` + + Http2Route *HttpRoute `locationName:"http2Route" type:"structure"` + + HttpRoute *HttpRoute `locationName:"httpRoute" type:"structure"` + + Priority *int64 `locationName:"priority" type:"integer"` + + TcpRoute *TcpRoute `locationName:"tcpRoute" type:"structure"` +} + +// String returns the string representation +func (s RouteSpec) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RouteSpec) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *RouteSpec) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "RouteSpec"} + if s.GrpcRoute != nil { + if err := s.GrpcRoute.Validate(); err != nil { + invalidParams.AddNested("GrpcRoute", err.(request.ErrInvalidParams)) + } + } + if s.Http2Route != nil { + if err := s.Http2Route.Validate(); err != nil { + invalidParams.AddNested("Http2Route", err.(request.ErrInvalidParams)) + } + } + if s.HttpRoute != nil { + if err := s.HttpRoute.Validate(); err != nil { + invalidParams.AddNested("HttpRoute", err.(request.ErrInvalidParams)) + } + } + if s.TcpRoute != nil { + if err := s.TcpRoute.Validate(); err != nil { + invalidParams.AddNested("TcpRoute", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetGrpcRoute sets the GrpcRoute field's value. +func (s *RouteSpec) SetGrpcRoute(v *GrpcRoute) *RouteSpec { + s.GrpcRoute = v + return s +} + +// SetHttp2Route sets the Http2Route field's value. +func (s *RouteSpec) SetHttp2Route(v *HttpRoute) *RouteSpec { + s.Http2Route = v + return s +} + +// SetHttpRoute sets the HttpRoute field's value. +func (s *RouteSpec) SetHttpRoute(v *HttpRoute) *RouteSpec { + s.HttpRoute = v + return s +} + +// SetPriority sets the Priority field's value. +func (s *RouteSpec) SetPriority(v int64) *RouteSpec { + s.Priority = &v + return s +} + +// SetTcpRoute sets the TcpRoute field's value. +func (s *RouteSpec) SetTcpRoute(v *TcpRoute) *RouteSpec { + s.TcpRoute = v + return s +} + +type RouteStatus struct { + _ struct{} `type:"structure"` + + // Status is a required field + Status *string `locationName:"status" type:"string" required:"true" enum:"RouteStatusCode"` +} + +// String returns the string representation +func (s RouteStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RouteStatus) GoString() string { + return s.String() +} + +// SetStatus sets the Status field's value. +func (s *RouteStatus) SetStatus(v string) *RouteStatus { + s.Status = &v + return s +} + +type SdsSource struct { + _ struct{} `type:"structure"` + + UnixDomainSocket *SdsUnixDomainSocketSource `locationName:"unixDomainSocket" type:"structure"` +} + +// String returns the string representation +func (s SdsSource) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SdsSource) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SdsSource) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SdsSource"} + if s.UnixDomainSocket != nil { + if err := s.UnixDomainSocket.Validate(); err != nil { + invalidParams.AddNested("UnixDomainSocket", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetUnixDomainSocket sets the UnixDomainSocket field's value. +func (s *SdsSource) SetUnixDomainSocket(v *SdsUnixDomainSocketSource) *SdsSource { + s.UnixDomainSocket = v + return s +} + +type SdsUnixDomainSocketSource struct { + _ struct{} `type:"structure"` + + // Path is a required field + Path *string `locationName:"path" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s SdsUnixDomainSocketSource) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s SdsUnixDomainSocketSource) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SdsUnixDomainSocketSource) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "SdsUnixDomainSocketSource"} + if s.Path == nil { + invalidParams.Add(request.NewErrParamRequired("Path")) + } + if s.Path != nil && len(*s.Path) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Path", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPath sets the Path field's value. +func (s *SdsUnixDomainSocketSource) SetPath(v string) *SdsUnixDomainSocketSource { + s.Path = &v + return s +} + +type ServiceDiscovery struct { + _ struct{} `type:"structure"` + + AwsCloudMap *AwsCloudMapServiceDiscovery `locationName:"awsCloudMap" type:"structure"` + + Dns *DnsServiceDiscovery `locationName:"dns" type:"structure"` +} + +// String returns the string representation +func (s ServiceDiscovery) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ServiceDiscovery) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ServiceDiscovery) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ServiceDiscovery"} + if s.AwsCloudMap != nil { + if err := s.AwsCloudMap.Validate(); err != nil { + invalidParams.AddNested("AwsCloudMap", err.(request.ErrInvalidParams)) + } + } + if s.Dns != nil { + if err := s.Dns.Validate(); err != nil { + invalidParams.AddNested("Dns", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAwsCloudMap sets the AwsCloudMap field's value. +func (s *ServiceDiscovery) SetAwsCloudMap(v *AwsCloudMapServiceDiscovery) *ServiceDiscovery { + s.AwsCloudMap = v + return s +} + +// SetDns sets the Dns field's value. +func (s *ServiceDiscovery) SetDns(v *DnsServiceDiscovery) *ServiceDiscovery { + s.Dns = v + return s +} + +type ServiceUnavailableException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s ServiceUnavailableException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ServiceUnavailableException) GoString() string { + return s.String() +} + +func newErrorServiceUnavailableException(v protocol.ResponseMetadata) error { + return &ServiceUnavailableException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s ServiceUnavailableException) Code() string { + return "ServiceUnavailableException" +} + +// Message returns the exception's message. +func (s ServiceUnavailableException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s ServiceUnavailableException) OrigErr() error { + return nil +} + +func (s ServiceUnavailableException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s ServiceUnavailableException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s ServiceUnavailableException) RequestID() string { + return s.respMetadata.RequestID +} + +type TcpRoute struct { + _ struct{} `type:"structure"` + + // Action is a required field + Action *TcpRouteAction `locationName:"action" type:"structure" required:"true"` + + Timeout *TcpTimeout `locationName:"timeout" type:"structure"` +} + +// String returns the string representation +func (s TcpRoute) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TcpRoute) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TcpRoute) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TcpRoute"} + if s.Action == nil { + invalidParams.Add(request.NewErrParamRequired("Action")) + } + if s.Action != nil { + if err := s.Action.Validate(); err != nil { + invalidParams.AddNested("Action", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAction sets the Action field's value. +func (s *TcpRoute) SetAction(v *TcpRouteAction) *TcpRoute { + s.Action = v + return s +} + +// SetTimeout sets the Timeout field's value. +func (s *TcpRoute) SetTimeout(v *TcpTimeout) *TcpRoute { + s.Timeout = v + return s +} + +type TcpRouteAction struct { + _ struct{} `type:"structure"` + + // WeightedTargets is a required field + WeightedTargets []*WeightedTarget `locationName:"weightedTargets" min:"1" type:"list" required:"true"` +} + +// String returns the string representation +func (s TcpRouteAction) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TcpRouteAction) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TcpRouteAction) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TcpRouteAction"} + if s.WeightedTargets == nil { + invalidParams.Add(request.NewErrParamRequired("WeightedTargets")) + } + if s.WeightedTargets != nil && len(s.WeightedTargets) < 1 { + invalidParams.Add(request.NewErrParamMinLen("WeightedTargets", 1)) + } + if s.WeightedTargets != nil { + for i, v := range s.WeightedTargets { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "WeightedTargets", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetWeightedTargets sets the WeightedTargets field's value. +func (s *TcpRouteAction) SetWeightedTargets(v []*WeightedTarget) *TcpRouteAction { + s.WeightedTargets = v + return s +} + +type TcpTimeout struct { + _ struct{} `type:"structure"` + + Idle *Duration `locationName:"idle" type:"structure"` +} + +// String returns the string representation +func (s TcpTimeout) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TcpTimeout) GoString() string { + return s.String() +} + +// SetIdle sets the Idle field's value. +func (s *TcpTimeout) SetIdle(v *Duration) *TcpTimeout { + s.Idle = v + return s +} + +type TlsValidationContext struct { + _ struct{} `type:"structure"` + + // Trust is a required field + Trust *TlsValidationContextTrust `locationName:"trust" type:"structure" required:"true"` +} + +// String returns the string representation +func (s TlsValidationContext) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TlsValidationContext) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TlsValidationContext) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TlsValidationContext"} + if s.Trust == nil { + invalidParams.Add(request.NewErrParamRequired("Trust")) + } + if s.Trust != nil { + if err := s.Trust.Validate(); err != nil { + invalidParams.AddNested("Trust", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetTrust sets the Trust field's value. +func (s *TlsValidationContext) SetTrust(v *TlsValidationContextTrust) *TlsValidationContext { + s.Trust = v + return s +} + +type TlsValidationContextAcmTrust struct { + _ struct{} `type:"structure"` + + // CertificateAuthorityArns is a required field + CertificateAuthorityArns []*string `locationName:"certificateAuthorityArns" min:"1" type:"list" required:"true"` +} + +// String returns the string representation +func (s TlsValidationContextAcmTrust) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TlsValidationContextAcmTrust) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TlsValidationContextAcmTrust) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TlsValidationContextAcmTrust"} + if s.CertificateAuthorityArns == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateAuthorityArns")) + } + if s.CertificateAuthorityArns != nil && len(s.CertificateAuthorityArns) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CertificateAuthorityArns", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateAuthorityArns sets the CertificateAuthorityArns field's value. +func (s *TlsValidationContextAcmTrust) SetCertificateAuthorityArns(v []*string) *TlsValidationContextAcmTrust { + s.CertificateAuthorityArns = v + return s +} + +type TlsValidationContextFileTrust struct { + _ struct{} `type:"structure"` + + // CertificateChain is a required field + CertificateChain *string `locationName:"certificateChain" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s TlsValidationContextFileTrust) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TlsValidationContextFileTrust) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TlsValidationContextFileTrust) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TlsValidationContextFileTrust"} + if s.CertificateChain == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateChain")) + } + if s.CertificateChain != nil && len(*s.CertificateChain) < 1 { + invalidParams.Add(request.NewErrParamMinLen("CertificateChain", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateChain sets the CertificateChain field's value. +func (s *TlsValidationContextFileTrust) SetCertificateChain(v string) *TlsValidationContextFileTrust { + s.CertificateChain = &v + return s +} + +type TlsValidationContextSdsTrust struct { + _ struct{} `type:"structure"` + + // SecretName is a required field + SecretName *string `locationName:"secretName" type:"string" required:"true"` + + // Source is a required field + Source *SdsSource `locationName:"source" type:"structure" required:"true"` +} + +// String returns the string representation +func (s TlsValidationContextSdsTrust) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TlsValidationContextSdsTrust) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TlsValidationContextSdsTrust) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TlsValidationContextSdsTrust"} + if s.SecretName == nil { + invalidParams.Add(request.NewErrParamRequired("SecretName")) + } + if s.Source == nil { + invalidParams.Add(request.NewErrParamRequired("Source")) + } + if s.Source != nil { + if err := s.Source.Validate(); err != nil { + invalidParams.AddNested("Source", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetSecretName sets the SecretName field's value. +func (s *TlsValidationContextSdsTrust) SetSecretName(v string) *TlsValidationContextSdsTrust { + s.SecretName = &v + return s +} + +// SetSource sets the Source field's value. +func (s *TlsValidationContextSdsTrust) SetSource(v *SdsSource) *TlsValidationContextSdsTrust { + s.Source = v + return s +} + +type TlsValidationContextTrust struct { + _ struct{} `type:"structure"` + + Acm *TlsValidationContextAcmTrust `locationName:"acm" type:"structure"` + + File *TlsValidationContextFileTrust `locationName:"file" type:"structure"` + + Sds *TlsValidationContextSdsTrust `locationName:"sds" type:"structure"` +} + +// String returns the string representation +func (s TlsValidationContextTrust) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TlsValidationContextTrust) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TlsValidationContextTrust) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "TlsValidationContextTrust"} + if s.Acm != nil { + if err := s.Acm.Validate(); err != nil { + invalidParams.AddNested("Acm", err.(request.ErrInvalidParams)) + } + } + if s.File != nil { + if err := s.File.Validate(); err != nil { + invalidParams.AddNested("File", err.(request.ErrInvalidParams)) + } + } + if s.Sds != nil { + if err := s.Sds.Validate(); err != nil { + invalidParams.AddNested("Sds", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAcm sets the Acm field's value. +func (s *TlsValidationContextTrust) SetAcm(v *TlsValidationContextAcmTrust) *TlsValidationContextTrust { + s.Acm = v + return s +} + +// SetFile sets the File field's value. +func (s *TlsValidationContextTrust) SetFile(v *TlsValidationContextFileTrust) *TlsValidationContextTrust { + s.File = v + return s +} + +// SetSds sets the Sds field's value. +func (s *TlsValidationContextTrust) SetSds(v *TlsValidationContextSdsTrust) *TlsValidationContextTrust { + s.Sds = v + return s +} + +type TooManyRequestsException struct { + _ struct{} `type:"structure"` + respMetadata protocol.ResponseMetadata + + Message_ *string `locationName:"message" type:"string"` +} + +// String returns the string representation +func (s TooManyRequestsException) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s TooManyRequestsException) GoString() string { + return s.String() +} + +func newErrorTooManyRequestsException(v protocol.ResponseMetadata) error { + return &TooManyRequestsException{ + respMetadata: v, + } +} + +// Code returns the exception type name. +func (s TooManyRequestsException) Code() string { + return "TooManyRequestsException" +} + +// Message returns the exception's message. +func (s TooManyRequestsException) Message() string { + if s.Message_ != nil { + return *s.Message_ + } + return "" +} + +// OrigErr always returns nil, satisfies awserr.Error interface. +func (s TooManyRequestsException) OrigErr() error { + return nil +} + +func (s TooManyRequestsException) Error() string { + return fmt.Sprintf("%s: %s", s.Code(), s.Message()) +} + +// Status code returns the HTTP status code for the request's response error. +func (s TooManyRequestsException) StatusCode() int { + return s.respMetadata.StatusCode +} + +// RequestID returns the service's response RequestID for request. +func (s TooManyRequestsException) RequestID() string { + return s.respMetadata.RequestID +} + +type UpdateMeshInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + Spec *MeshSpec `locationName:"spec" type:"structure"` +} + +// String returns the string representation +func (s UpdateMeshInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateMeshInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateMeshInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateMeshInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *UpdateMeshInput) SetClientToken(v string) *UpdateMeshInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *UpdateMeshInput) SetMeshName(v string) *UpdateMeshInput { + s.MeshName = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *UpdateMeshInput) SetSpec(v *MeshSpec) *UpdateMeshInput { + s.Spec = v + return s +} + +type UpdateMeshOutput struct { + _ struct{} `type:"structure" payload:"Mesh"` + + // Mesh is a required field + Mesh *MeshData `locationName:"mesh" type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateMeshOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateMeshOutput) GoString() string { + return s.String() +} + +// SetMesh sets the Mesh field's value. +func (s *UpdateMeshOutput) SetMesh(v *MeshData) *UpdateMeshOutput { + s.Mesh = v + return s +} + +type UpdateRouteInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // RouteName is a required field + RouteName *string `location:"uri" locationName:"routeName" min:"1" type:"string" required:"true"` + + // Spec is a required field + Spec *RouteSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateRouteInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateRouteInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateRouteInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateRouteInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.RouteName == nil { + invalidParams.Add(request.NewErrParamRequired("RouteName")) + } + if s.RouteName != nil && len(*s.RouteName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("RouteName", 1)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *UpdateRouteInput) SetClientToken(v string) *UpdateRouteInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *UpdateRouteInput) SetMeshName(v string) *UpdateRouteInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *UpdateRouteInput) SetMeshOwner(v string) *UpdateRouteInput { + s.MeshOwner = &v + return s +} + +// SetRouteName sets the RouteName field's value. +func (s *UpdateRouteInput) SetRouteName(v string) *UpdateRouteInput { + s.RouteName = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *UpdateRouteInput) SetSpec(v *RouteSpec) *UpdateRouteInput { + s.Spec = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *UpdateRouteInput) SetVirtualRouterName(v string) *UpdateRouteInput { + s.VirtualRouterName = &v + return s +} + +type UpdateRouteOutput struct { + _ struct{} `type:"structure" payload:"Route"` + + // Route is a required field + Route *RouteData `locationName:"route" type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateRouteOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateRouteOutput) GoString() string { + return s.String() +} + +// SetRoute sets the Route field's value. +func (s *UpdateRouteOutput) SetRoute(v *RouteData) *UpdateRouteOutput { + s.Route = v + return s +} + +type UpdateVirtualNodeInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualNodeSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualNodeName is a required field + VirtualNodeName *string `location:"uri" locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualNodeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualNodeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateVirtualNodeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateVirtualNodeInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualNodeName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNodeName")) + } + if s.VirtualNodeName != nil && len(*s.VirtualNodeName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNodeName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *UpdateVirtualNodeInput) SetClientToken(v string) *UpdateVirtualNodeInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *UpdateVirtualNodeInput) SetMeshName(v string) *UpdateVirtualNodeInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *UpdateVirtualNodeInput) SetMeshOwner(v string) *UpdateVirtualNodeInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *UpdateVirtualNodeInput) SetSpec(v *VirtualNodeSpec) *UpdateVirtualNodeInput { + s.Spec = v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *UpdateVirtualNodeInput) SetVirtualNodeName(v string) *UpdateVirtualNodeInput { + s.VirtualNodeName = &v + return s +} + +type UpdateVirtualNodeOutput struct { + _ struct{} `type:"structure" payload:"VirtualNode"` + + // VirtualNode is a required field + VirtualNode *VirtualNodeData `locationName:"virtualNode" type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualNodeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualNodeOutput) GoString() string { + return s.String() +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *UpdateVirtualNodeOutput) SetVirtualNode(v *VirtualNodeData) *UpdateVirtualNodeOutput { + s.VirtualNode = v + return s +} + +type UpdateVirtualRouterInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualRouterSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `location:"uri" locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualRouterInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualRouterInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateVirtualRouterInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateVirtualRouterInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *UpdateVirtualRouterInput) SetClientToken(v string) *UpdateVirtualRouterInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *UpdateVirtualRouterInput) SetMeshName(v string) *UpdateVirtualRouterInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *UpdateVirtualRouterInput) SetMeshOwner(v string) *UpdateVirtualRouterInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *UpdateVirtualRouterInput) SetSpec(v *VirtualRouterSpec) *UpdateVirtualRouterInput { + s.Spec = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *UpdateVirtualRouterInput) SetVirtualRouterName(v string) *UpdateVirtualRouterInput { + s.VirtualRouterName = &v + return s +} + +type UpdateVirtualRouterOutput struct { + _ struct{} `type:"structure" payload:"VirtualRouter"` + + // VirtualRouter is a required field + VirtualRouter *VirtualRouterData `locationName:"virtualRouter" type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualRouterOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualRouterOutput) GoString() string { + return s.String() +} + +// SetVirtualRouter sets the VirtualRouter field's value. +func (s *UpdateVirtualRouterOutput) SetVirtualRouter(v *VirtualRouterData) *UpdateVirtualRouterOutput { + s.VirtualRouter = v + return s +} + +type UpdateVirtualServiceInput struct { + _ struct{} `type:"structure"` + + ClientToken *string `locationName:"clientToken" type:"string" idempotencyToken:"true"` + + // MeshName is a required field + MeshName *string `location:"uri" locationName:"meshName" min:"1" type:"string" required:"true"` + + MeshOwner *string `location:"querystring" locationName:"meshOwner" min:"12" type:"string"` + + // Spec is a required field + Spec *VirtualServiceSpec `locationName:"spec" type:"structure" required:"true"` + + // VirtualServiceName is a required field + VirtualServiceName *string `location:"uri" locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualServiceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualServiceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateVirtualServiceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateVirtualServiceInput"} + if s.MeshName == nil { + invalidParams.Add(request.NewErrParamRequired("MeshName")) + } + if s.MeshName != nil && len(*s.MeshName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("MeshName", 1)) + } + if s.MeshOwner != nil && len(*s.MeshOwner) < 12 { + invalidParams.Add(request.NewErrParamMinLen("MeshOwner", 12)) + } + if s.Spec == nil { + invalidParams.Add(request.NewErrParamRequired("Spec")) + } + if s.VirtualServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualServiceName")) + } + if s.VirtualServiceName != nil && len(*s.VirtualServiceName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualServiceName", 1)) + } + if s.Spec != nil { + if err := s.Spec.Validate(); err != nil { + invalidParams.AddNested("Spec", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientToken sets the ClientToken field's value. +func (s *UpdateVirtualServiceInput) SetClientToken(v string) *UpdateVirtualServiceInput { + s.ClientToken = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *UpdateVirtualServiceInput) SetMeshName(v string) *UpdateVirtualServiceInput { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *UpdateVirtualServiceInput) SetMeshOwner(v string) *UpdateVirtualServiceInput { + s.MeshOwner = &v + return s +} + +// SetSpec sets the Spec field's value. +func (s *UpdateVirtualServiceInput) SetSpec(v *VirtualServiceSpec) *UpdateVirtualServiceInput { + s.Spec = v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *UpdateVirtualServiceInput) SetVirtualServiceName(v string) *UpdateVirtualServiceInput { + s.VirtualServiceName = &v + return s +} + +type UpdateVirtualServiceOutput struct { + _ struct{} `type:"structure" payload:"VirtualService"` + + // VirtualService is a required field + VirtualService *VirtualServiceData `locationName:"virtualService" type:"structure" required:"true"` +} + +// String returns the string representation +func (s UpdateVirtualServiceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateVirtualServiceOutput) GoString() string { + return s.String() +} + +// SetVirtualService sets the VirtualService field's value. +func (s *UpdateVirtualServiceOutput) SetVirtualService(v *VirtualServiceData) *UpdateVirtualServiceOutput { + s.VirtualService = v + return s +} + +type VirtualNodeData struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // Metadata is a required field + Metadata *ResourceMetadata `locationName:"metadata" type:"structure" required:"true"` + + // Spec is a required field + Spec *VirtualNodeSpec `locationName:"spec" type:"structure" required:"true"` + + // Status is a required field + Status *VirtualNodeStatus `locationName:"status" type:"structure" required:"true"` + + // VirtualNodeName is a required field + VirtualNodeName *string `locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualNodeData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualNodeData) GoString() string { + return s.String() +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualNodeData) SetMeshName(v string) *VirtualNodeData { + s.MeshName = &v + return s +} + +// SetMetadata sets the Metadata field's value. +func (s *VirtualNodeData) SetMetadata(v *ResourceMetadata) *VirtualNodeData { + s.Metadata = v + return s +} + +// SetSpec sets the Spec field's value. +func (s *VirtualNodeData) SetSpec(v *VirtualNodeSpec) *VirtualNodeData { + s.Spec = v + return s +} + +// SetStatus sets the Status field's value. +func (s *VirtualNodeData) SetStatus(v *VirtualNodeStatus) *VirtualNodeData { + s.Status = v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *VirtualNodeData) SetVirtualNodeName(v string) *VirtualNodeData { + s.VirtualNodeName = &v + return s +} + +type VirtualNodeRef struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` + + // VirtualNodeName is a required field + VirtualNodeName *string `locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualNodeRef) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualNodeRef) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *VirtualNodeRef) SetArn(v string) *VirtualNodeRef { + s.Arn = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualNodeRef) SetMeshName(v string) *VirtualNodeRef { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *VirtualNodeRef) SetMeshOwner(v string) *VirtualNodeRef { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *VirtualNodeRef) SetResourceOwner(v string) *VirtualNodeRef { + s.ResourceOwner = &v + return s +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *VirtualNodeRef) SetVirtualNodeName(v string) *VirtualNodeRef { + s.VirtualNodeName = &v + return s +} + +type VirtualNodeServiceProvider struct { + _ struct{} `type:"structure"` + + // VirtualNodeName is a required field + VirtualNodeName *string `locationName:"virtualNodeName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualNodeServiceProvider) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualNodeServiceProvider) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualNodeServiceProvider) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualNodeServiceProvider"} + if s.VirtualNodeName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNodeName")) + } + if s.VirtualNodeName != nil && len(*s.VirtualNodeName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNodeName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetVirtualNodeName sets the VirtualNodeName field's value. +func (s *VirtualNodeServiceProvider) SetVirtualNodeName(v string) *VirtualNodeServiceProvider { + s.VirtualNodeName = &v + return s +} + +type VirtualNodeSpec struct { + _ struct{} `type:"structure"` + + BackendDefaults *BackendDefaults `locationName:"backendDefaults" type:"structure"` + + Backends []*Backend `locationName:"backends" type:"list"` + + Listeners []*Listener `locationName:"listeners" type:"list"` + + Logging *Logging `locationName:"logging" type:"structure"` + + ServiceDiscovery *ServiceDiscovery `locationName:"serviceDiscovery" type:"structure"` +} + +// String returns the string representation +func (s VirtualNodeSpec) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualNodeSpec) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualNodeSpec) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualNodeSpec"} + if s.BackendDefaults != nil { + if err := s.BackendDefaults.Validate(); err != nil { + invalidParams.AddNested("BackendDefaults", err.(request.ErrInvalidParams)) + } + } + if s.Backends != nil { + for i, v := range s.Backends { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Backends", i), err.(request.ErrInvalidParams)) + } + } + } + if s.Listeners != nil { + for i, v := range s.Listeners { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Listeners", i), err.(request.ErrInvalidParams)) + } + } + } + if s.Logging != nil { + if err := s.Logging.Validate(); err != nil { + invalidParams.AddNested("Logging", err.(request.ErrInvalidParams)) + } + } + if s.ServiceDiscovery != nil { + if err := s.ServiceDiscovery.Validate(); err != nil { + invalidParams.AddNested("ServiceDiscovery", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetBackendDefaults sets the BackendDefaults field's value. +func (s *VirtualNodeSpec) SetBackendDefaults(v *BackendDefaults) *VirtualNodeSpec { + s.BackendDefaults = v + return s +} + +// SetBackends sets the Backends field's value. +func (s *VirtualNodeSpec) SetBackends(v []*Backend) *VirtualNodeSpec { + s.Backends = v + return s +} + +// SetListeners sets the Listeners field's value. +func (s *VirtualNodeSpec) SetListeners(v []*Listener) *VirtualNodeSpec { + s.Listeners = v + return s +} + +// SetLogging sets the Logging field's value. +func (s *VirtualNodeSpec) SetLogging(v *Logging) *VirtualNodeSpec { + s.Logging = v + return s +} + +// SetServiceDiscovery sets the ServiceDiscovery field's value. +func (s *VirtualNodeSpec) SetServiceDiscovery(v *ServiceDiscovery) *VirtualNodeSpec { + s.ServiceDiscovery = v + return s +} + +type VirtualNodeStatus struct { + _ struct{} `type:"structure"` + + // Status is a required field + Status *string `locationName:"status" type:"string" required:"true" enum:"VirtualNodeStatusCode"` +} + +// String returns the string representation +func (s VirtualNodeStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualNodeStatus) GoString() string { + return s.String() +} + +// SetStatus sets the Status field's value. +func (s *VirtualNodeStatus) SetStatus(v string) *VirtualNodeStatus { + s.Status = &v + return s +} + +type VirtualRouterData struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // Metadata is a required field + Metadata *ResourceMetadata `locationName:"metadata" type:"structure" required:"true"` + + // Spec is a required field + Spec *VirtualRouterSpec `locationName:"spec" type:"structure" required:"true"` + + // Status is a required field + Status *VirtualRouterStatus `locationName:"status" type:"structure" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualRouterData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterData) GoString() string { + return s.String() +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualRouterData) SetMeshName(v string) *VirtualRouterData { + s.MeshName = &v + return s +} + +// SetMetadata sets the Metadata field's value. +func (s *VirtualRouterData) SetMetadata(v *ResourceMetadata) *VirtualRouterData { + s.Metadata = v + return s +} + +// SetSpec sets the Spec field's value. +func (s *VirtualRouterData) SetSpec(v *VirtualRouterSpec) *VirtualRouterData { + s.Spec = v + return s +} + +// SetStatus sets the Status field's value. +func (s *VirtualRouterData) SetStatus(v *VirtualRouterStatus) *VirtualRouterData { + s.Status = v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *VirtualRouterData) SetVirtualRouterName(v string) *VirtualRouterData { + s.VirtualRouterName = &v + return s +} + +type VirtualRouterListener struct { + _ struct{} `type:"structure"` + + // PortMapping is a required field + PortMapping *PortMapping `locationName:"portMapping" type:"structure" required:"true"` +} + +// String returns the string representation +func (s VirtualRouterListener) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterListener) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualRouterListener) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualRouterListener"} + if s.PortMapping == nil { + invalidParams.Add(request.NewErrParamRequired("PortMapping")) + } + if s.PortMapping != nil { + if err := s.PortMapping.Validate(); err != nil { + invalidParams.AddNested("PortMapping", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPortMapping sets the PortMapping field's value. +func (s *VirtualRouterListener) SetPortMapping(v *PortMapping) *VirtualRouterListener { + s.PortMapping = v + return s +} + +type VirtualRouterRef struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualRouterRef) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterRef) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *VirtualRouterRef) SetArn(v string) *VirtualRouterRef { + s.Arn = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualRouterRef) SetMeshName(v string) *VirtualRouterRef { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *VirtualRouterRef) SetMeshOwner(v string) *VirtualRouterRef { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *VirtualRouterRef) SetResourceOwner(v string) *VirtualRouterRef { + s.ResourceOwner = &v + return s +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *VirtualRouterRef) SetVirtualRouterName(v string) *VirtualRouterRef { + s.VirtualRouterName = &v + return s +} + +type VirtualRouterServiceProvider struct { + _ struct{} `type:"structure"` + + // VirtualRouterName is a required field + VirtualRouterName *string `locationName:"virtualRouterName" min:"1" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualRouterServiceProvider) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterServiceProvider) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualRouterServiceProvider) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualRouterServiceProvider"} + if s.VirtualRouterName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualRouterName")) + } + if s.VirtualRouterName != nil && len(*s.VirtualRouterName) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualRouterName", 1)) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetVirtualRouterName sets the VirtualRouterName field's value. +func (s *VirtualRouterServiceProvider) SetVirtualRouterName(v string) *VirtualRouterServiceProvider { + s.VirtualRouterName = &v + return s +} + +type VirtualRouterSpec struct { + _ struct{} `type:"structure"` + + Listeners []*VirtualRouterListener `locationName:"listeners" min:"1" type:"list"` +} + +// String returns the string representation +func (s VirtualRouterSpec) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterSpec) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualRouterSpec) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualRouterSpec"} + if s.Listeners != nil && len(s.Listeners) < 1 { + invalidParams.Add(request.NewErrParamMinLen("Listeners", 1)) + } + if s.Listeners != nil { + for i, v := range s.Listeners { + if v == nil { + continue + } + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Listeners", i), err.(request.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetListeners sets the Listeners field's value. +func (s *VirtualRouterSpec) SetListeners(v []*VirtualRouterListener) *VirtualRouterSpec { + s.Listeners = v + return s +} + +type VirtualRouterStatus struct { + _ struct{} `type:"structure"` + + // Status is a required field + Status *string `locationName:"status" type:"string" required:"true" enum:"VirtualRouterStatusCode"` +} + +// String returns the string representation +func (s VirtualRouterStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualRouterStatus) GoString() string { + return s.String() +} + +// SetStatus sets the Status field's value. +func (s *VirtualRouterStatus) SetStatus(v string) *VirtualRouterStatus { + s.Status = &v + return s +} + +type VirtualServiceBackend struct { + _ struct{} `type:"structure"` + + ClientPolicy *ClientPolicy `locationName:"clientPolicy" type:"structure"` + + // VirtualServiceName is a required field + VirtualServiceName *string `locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualServiceBackend) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceBackend) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualServiceBackend) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualServiceBackend"} + if s.VirtualServiceName == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualServiceName")) + } + if s.ClientPolicy != nil { + if err := s.ClientPolicy.Validate(); err != nil { + invalidParams.AddNested("ClientPolicy", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetClientPolicy sets the ClientPolicy field's value. +func (s *VirtualServiceBackend) SetClientPolicy(v *ClientPolicy) *VirtualServiceBackend { + s.ClientPolicy = v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *VirtualServiceBackend) SetVirtualServiceName(v string) *VirtualServiceBackend { + s.VirtualServiceName = &v + return s +} + +type VirtualServiceData struct { + _ struct{} `type:"structure"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // Metadata is a required field + Metadata *ResourceMetadata `locationName:"metadata" type:"structure" required:"true"` + + // Spec is a required field + Spec *VirtualServiceSpec `locationName:"spec" type:"structure" required:"true"` + + // Status is a required field + Status *VirtualServiceStatus `locationName:"status" type:"structure" required:"true"` + + // VirtualServiceName is a required field + VirtualServiceName *string `locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualServiceData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceData) GoString() string { + return s.String() +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualServiceData) SetMeshName(v string) *VirtualServiceData { + s.MeshName = &v + return s +} + +// SetMetadata sets the Metadata field's value. +func (s *VirtualServiceData) SetMetadata(v *ResourceMetadata) *VirtualServiceData { + s.Metadata = v + return s +} + +// SetSpec sets the Spec field's value. +func (s *VirtualServiceData) SetSpec(v *VirtualServiceSpec) *VirtualServiceData { + s.Spec = v + return s +} + +// SetStatus sets the Status field's value. +func (s *VirtualServiceData) SetStatus(v *VirtualServiceStatus) *VirtualServiceData { + s.Status = v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *VirtualServiceData) SetVirtualServiceName(v string) *VirtualServiceData { + s.VirtualServiceName = &v + return s +} + +type VirtualServiceProvider struct { + _ struct{} `type:"structure"` + + VirtualNode *VirtualNodeServiceProvider `locationName:"virtualNode" type:"structure"` + + VirtualRouter *VirtualRouterServiceProvider `locationName:"virtualRouter" type:"structure"` +} + +// String returns the string representation +func (s VirtualServiceProvider) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceProvider) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualServiceProvider) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualServiceProvider"} + if s.VirtualNode != nil { + if err := s.VirtualNode.Validate(); err != nil { + invalidParams.AddNested("VirtualNode", err.(request.ErrInvalidParams)) + } + } + if s.VirtualRouter != nil { + if err := s.VirtualRouter.Validate(); err != nil { + invalidParams.AddNested("VirtualRouter", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *VirtualServiceProvider) SetVirtualNode(v *VirtualNodeServiceProvider) *VirtualServiceProvider { + s.VirtualNode = v + return s +} + +// SetVirtualRouter sets the VirtualRouter field's value. +func (s *VirtualServiceProvider) SetVirtualRouter(v *VirtualRouterServiceProvider) *VirtualServiceProvider { + s.VirtualRouter = v + return s +} + +type VirtualServiceRef struct { + _ struct{} `type:"structure"` + + // Arn is a required field + Arn *string `locationName:"arn" type:"string" required:"true"` + + // MeshName is a required field + MeshName *string `locationName:"meshName" min:"1" type:"string" required:"true"` + + // MeshOwner is a required field + MeshOwner *string `locationName:"meshOwner" min:"12" type:"string" required:"true"` + + // ResourceOwner is a required field + ResourceOwner *string `locationName:"resourceOwner" min:"12" type:"string" required:"true"` + + // VirtualServiceName is a required field + VirtualServiceName *string `locationName:"virtualServiceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s VirtualServiceRef) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceRef) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *VirtualServiceRef) SetArn(v string) *VirtualServiceRef { + s.Arn = &v + return s +} + +// SetMeshName sets the MeshName field's value. +func (s *VirtualServiceRef) SetMeshName(v string) *VirtualServiceRef { + s.MeshName = &v + return s +} + +// SetMeshOwner sets the MeshOwner field's value. +func (s *VirtualServiceRef) SetMeshOwner(v string) *VirtualServiceRef { + s.MeshOwner = &v + return s +} + +// SetResourceOwner sets the ResourceOwner field's value. +func (s *VirtualServiceRef) SetResourceOwner(v string) *VirtualServiceRef { + s.ResourceOwner = &v + return s +} + +// SetVirtualServiceName sets the VirtualServiceName field's value. +func (s *VirtualServiceRef) SetVirtualServiceName(v string) *VirtualServiceRef { + s.VirtualServiceName = &v + return s +} + +type VirtualServiceSpec struct { + _ struct{} `type:"structure"` + + Provider *VirtualServiceProvider `locationName:"provider" type:"structure"` +} + +// String returns the string representation +func (s VirtualServiceSpec) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceSpec) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *VirtualServiceSpec) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "VirtualServiceSpec"} + if s.Provider != nil { + if err := s.Provider.Validate(); err != nil { + invalidParams.AddNested("Provider", err.(request.ErrInvalidParams)) + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetProvider sets the Provider field's value. +func (s *VirtualServiceSpec) SetProvider(v *VirtualServiceProvider) *VirtualServiceSpec { + s.Provider = v + return s +} + +type VirtualServiceStatus struct { + _ struct{} `type:"structure"` + + // Status is a required field + Status *string `locationName:"status" type:"string" required:"true" enum:"VirtualServiceStatusCode"` +} + +// String returns the string representation +func (s VirtualServiceStatus) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s VirtualServiceStatus) GoString() string { + return s.String() +} + +// SetStatus sets the Status field's value. +func (s *VirtualServiceStatus) SetStatus(v string) *VirtualServiceStatus { + s.Status = &v + return s +} + +type WeightedTarget struct { + _ struct{} `type:"structure"` + + // VirtualNode is a required field + VirtualNode *string `locationName:"virtualNode" min:"1" type:"string" required:"true"` + + // Weight is a required field + Weight *int64 `locationName:"weight" type:"integer" required:"true"` +} + +// String returns the string representation +func (s WeightedTarget) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s WeightedTarget) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *WeightedTarget) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "WeightedTarget"} + if s.VirtualNode == nil { + invalidParams.Add(request.NewErrParamRequired("VirtualNode")) + } + if s.VirtualNode != nil && len(*s.VirtualNode) < 1 { + invalidParams.Add(request.NewErrParamMinLen("VirtualNode", 1)) + } + if s.Weight == nil { + invalidParams.Add(request.NewErrParamRequired("Weight")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetVirtualNode sets the VirtualNode field's value. +func (s *WeightedTarget) SetVirtualNode(v string) *WeightedTarget { + s.VirtualNode = &v + return s +} + +// SetWeight sets the Weight field's value. +func (s *WeightedTarget) SetWeight(v int64) *WeightedTarget { + s.Weight = &v + return s +} + +const ( + // DurationUnitMs is a DurationUnit enum value + DurationUnitMs = "ms" + + // DurationUnitS is a DurationUnit enum value + DurationUnitS = "s" +) + +const ( + // EgressFilterTypeAllowAll is a EgressFilterType enum value + EgressFilterTypeAllowAll = "ALLOW_ALL" + + // EgressFilterTypeDropAll is a EgressFilterType enum value + EgressFilterTypeDropAll = "DROP_ALL" +) + +const ( + // GrpcRetryPolicyEventCancelled is a GrpcRetryPolicyEvent enum value + GrpcRetryPolicyEventCancelled = "cancelled" + + // GrpcRetryPolicyEventDeadlineExceeded is a GrpcRetryPolicyEvent enum value + GrpcRetryPolicyEventDeadlineExceeded = "deadline-exceeded" + + // GrpcRetryPolicyEventInternal is a GrpcRetryPolicyEvent enum value + GrpcRetryPolicyEventInternal = "internal" + + // GrpcRetryPolicyEventResourceExhausted is a GrpcRetryPolicyEvent enum value + GrpcRetryPolicyEventResourceExhausted = "resource-exhausted" + + // GrpcRetryPolicyEventUnavailable is a GrpcRetryPolicyEvent enum value + GrpcRetryPolicyEventUnavailable = "unavailable" +) + +const ( + // HttpMethodConnect is a HttpMethod enum value + HttpMethodConnect = "CONNECT" + + // HttpMethodDelete is a HttpMethod enum value + HttpMethodDelete = "DELETE" + + // HttpMethodGet is a HttpMethod enum value + HttpMethodGet = "GET" + + // HttpMethodHead is a HttpMethod enum value + HttpMethodHead = "HEAD" + + // HttpMethodOptions is a HttpMethod enum value + HttpMethodOptions = "OPTIONS" + + // HttpMethodPatch is a HttpMethod enum value + HttpMethodPatch = "PATCH" + + // HttpMethodPost is a HttpMethod enum value + HttpMethodPost = "POST" + + // HttpMethodPut is a HttpMethod enum value + HttpMethodPut = "PUT" + + // HttpMethodTrace is a HttpMethod enum value + HttpMethodTrace = "TRACE" +) + +const ( + // HttpSchemeHttp is a HttpScheme enum value + HttpSchemeHttp = "http" + + // HttpSchemeHttps is a HttpScheme enum value + HttpSchemeHttps = "https" +) + +const ( + // ListenerTlsModeDisabled is a ListenerTlsMode enum value + ListenerTlsModeDisabled = "DISABLED" + + // ListenerTlsModePermissive is a ListenerTlsMode enum value + ListenerTlsModePermissive = "PERMISSIVE" + + // ListenerTlsModeStrict is a ListenerTlsMode enum value + ListenerTlsModeStrict = "STRICT" +) + +const ( + // MeshStatusCodeActive is a MeshStatusCode enum value + MeshStatusCodeActive = "ACTIVE" + + // MeshStatusCodeDeleted is a MeshStatusCode enum value + MeshStatusCodeDeleted = "DELETED" + + // MeshStatusCodeInactive is a MeshStatusCode enum value + MeshStatusCodeInactive = "INACTIVE" +) + +const ( + // PortProtocolGrpc is a PortProtocol enum value + PortProtocolGrpc = "grpc" + + // PortProtocolHttp is a PortProtocol enum value + PortProtocolHttp = "http" + + // PortProtocolHttp2 is a PortProtocol enum value + PortProtocolHttp2 = "http2" + + // PortProtocolTcp is a PortProtocol enum value + PortProtocolTcp = "tcp" +) + +const ( + // RouteStatusCodeActive is a RouteStatusCode enum value + RouteStatusCodeActive = "ACTIVE" + + // RouteStatusCodeDeleted is a RouteStatusCode enum value + RouteStatusCodeDeleted = "DELETED" + + // RouteStatusCodeInactive is a RouteStatusCode enum value + RouteStatusCodeInactive = "INACTIVE" +) + +const ( + // TcpRetryPolicyEventConnectionError is a TcpRetryPolicyEvent enum value + TcpRetryPolicyEventConnectionError = "connection-error" +) + +const ( + // VirtualNodeStatusCodeActive is a VirtualNodeStatusCode enum value + VirtualNodeStatusCodeActive = "ACTIVE" + + // VirtualNodeStatusCodeDeleted is a VirtualNodeStatusCode enum value + VirtualNodeStatusCodeDeleted = "DELETED" + + // VirtualNodeStatusCodeInactive is a VirtualNodeStatusCode enum value + VirtualNodeStatusCodeInactive = "INACTIVE" +) + +const ( + // VirtualRouterStatusCodeActive is a VirtualRouterStatusCode enum value + VirtualRouterStatusCodeActive = "ACTIVE" + + // VirtualRouterStatusCodeDeleted is a VirtualRouterStatusCode enum value + VirtualRouterStatusCodeDeleted = "DELETED" + + // VirtualRouterStatusCodeInactive is a VirtualRouterStatusCode enum value + VirtualRouterStatusCodeInactive = "INACTIVE" +) + +const ( + // VirtualServiceStatusCodeActive is a VirtualServiceStatusCode enum value + VirtualServiceStatusCodeActive = "ACTIVE" + + // VirtualServiceStatusCodeDeleted is a VirtualServiceStatusCode enum value + VirtualServiceStatusCodeDeleted = "DELETED" + + // VirtualServiceStatusCodeInactive is a VirtualServiceStatusCode enum value + VirtualServiceStatusCodeInactive = "INACTIVE" +) diff --git a/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/appmeshpreviewiface/interface.go b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/appmeshpreviewiface/interface.go new file mode 100644 index 000000000000..991313c2f4bc --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/appmeshpreviewiface/interface.go @@ -0,0 +1,164 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +// Package appmeshpreviewiface provides an interface to enable mocking the AWS App Mesh Preview service client +// for testing your code. +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. +package appmeshpreviewiface + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/service/appmeshpreview" +) + +// AppMeshPreviewAPI provides an interface to enable mocking the +// appmeshpreview.AppMeshPreview service client's API operation, +// paginators, and waiters. This make unit testing your code that calls out +// to the SDK's service client's calls easier. +// +// The best way to use this interface is so the SDK's service client's calls +// can be stubbed out for unit testing your code with the SDK without needing +// to inject custom request handlers into the SDK's request pipeline. +// +// // myFunc uses an SDK service client to make a request to +// // AWS App Mesh Preview. +// func myFunc(svc appmeshpreviewiface.AppMeshPreviewAPI) bool { +// // Make svc.CreateMesh request +// } +// +// func main() { +// sess := session.New() +// svc := appmeshpreview.New(sess) +// +// myFunc(svc) +// } +// +// In your _test.go file: +// +// // Define a mock struct to be used in your unit tests of myFunc. +// type mockAppMeshPreviewClient struct { +// appmeshpreviewiface.AppMeshPreviewAPI +// } +// func (m *mockAppMeshPreviewClient) CreateMesh(input *appmeshpreview.CreateMeshInput) (*appmeshpreview.CreateMeshOutput, error) { +// // mock response/functionality +// } +// +// func TestMyFunc(t *testing.T) { +// // Setup Test +// mockSvc := &mockAppMeshPreviewClient{} +// +// myfunc(mockSvc) +// +// // Verify myFunc's functionality +// } +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. Its suggested to use the pattern above for testing, or using +// tooling to generate mocks to satisfy the interfaces. +type AppMeshPreviewAPI interface { + CreateMesh(*appmeshpreview.CreateMeshInput) (*appmeshpreview.CreateMeshOutput, error) + CreateMeshWithContext(aws.Context, *appmeshpreview.CreateMeshInput, ...request.Option) (*appmeshpreview.CreateMeshOutput, error) + CreateMeshRequest(*appmeshpreview.CreateMeshInput) (*request.Request, *appmeshpreview.CreateMeshOutput) + + CreateRoute(*appmeshpreview.CreateRouteInput) (*appmeshpreview.CreateRouteOutput, error) + CreateRouteWithContext(aws.Context, *appmeshpreview.CreateRouteInput, ...request.Option) (*appmeshpreview.CreateRouteOutput, error) + CreateRouteRequest(*appmeshpreview.CreateRouteInput) (*request.Request, *appmeshpreview.CreateRouteOutput) + + CreateVirtualNode(*appmeshpreview.CreateVirtualNodeInput) (*appmeshpreview.CreateVirtualNodeOutput, error) + CreateVirtualNodeWithContext(aws.Context, *appmeshpreview.CreateVirtualNodeInput, ...request.Option) (*appmeshpreview.CreateVirtualNodeOutput, error) + CreateVirtualNodeRequest(*appmeshpreview.CreateVirtualNodeInput) (*request.Request, *appmeshpreview.CreateVirtualNodeOutput) + + CreateVirtualRouter(*appmeshpreview.CreateVirtualRouterInput) (*appmeshpreview.CreateVirtualRouterOutput, error) + CreateVirtualRouterWithContext(aws.Context, *appmeshpreview.CreateVirtualRouterInput, ...request.Option) (*appmeshpreview.CreateVirtualRouterOutput, error) + CreateVirtualRouterRequest(*appmeshpreview.CreateVirtualRouterInput) (*request.Request, *appmeshpreview.CreateVirtualRouterOutput) + + CreateVirtualService(*appmeshpreview.CreateVirtualServiceInput) (*appmeshpreview.CreateVirtualServiceOutput, error) + CreateVirtualServiceWithContext(aws.Context, *appmeshpreview.CreateVirtualServiceInput, ...request.Option) (*appmeshpreview.CreateVirtualServiceOutput, error) + CreateVirtualServiceRequest(*appmeshpreview.CreateVirtualServiceInput) (*request.Request, *appmeshpreview.CreateVirtualServiceOutput) + + DeleteMesh(*appmeshpreview.DeleteMeshInput) (*appmeshpreview.DeleteMeshOutput, error) + DeleteMeshWithContext(aws.Context, *appmeshpreview.DeleteMeshInput, ...request.Option) (*appmeshpreview.DeleteMeshOutput, error) + DeleteMeshRequest(*appmeshpreview.DeleteMeshInput) (*request.Request, *appmeshpreview.DeleteMeshOutput) + + DeleteRoute(*appmeshpreview.DeleteRouteInput) (*appmeshpreview.DeleteRouteOutput, error) + DeleteRouteWithContext(aws.Context, *appmeshpreview.DeleteRouteInput, ...request.Option) (*appmeshpreview.DeleteRouteOutput, error) + DeleteRouteRequest(*appmeshpreview.DeleteRouteInput) (*request.Request, *appmeshpreview.DeleteRouteOutput) + + DeleteVirtualNode(*appmeshpreview.DeleteVirtualNodeInput) (*appmeshpreview.DeleteVirtualNodeOutput, error) + DeleteVirtualNodeWithContext(aws.Context, *appmeshpreview.DeleteVirtualNodeInput, ...request.Option) (*appmeshpreview.DeleteVirtualNodeOutput, error) + DeleteVirtualNodeRequest(*appmeshpreview.DeleteVirtualNodeInput) (*request.Request, *appmeshpreview.DeleteVirtualNodeOutput) + + DeleteVirtualRouter(*appmeshpreview.DeleteVirtualRouterInput) (*appmeshpreview.DeleteVirtualRouterOutput, error) + DeleteVirtualRouterWithContext(aws.Context, *appmeshpreview.DeleteVirtualRouterInput, ...request.Option) (*appmeshpreview.DeleteVirtualRouterOutput, error) + DeleteVirtualRouterRequest(*appmeshpreview.DeleteVirtualRouterInput) (*request.Request, *appmeshpreview.DeleteVirtualRouterOutput) + + DeleteVirtualService(*appmeshpreview.DeleteVirtualServiceInput) (*appmeshpreview.DeleteVirtualServiceOutput, error) + DeleteVirtualServiceWithContext(aws.Context, *appmeshpreview.DeleteVirtualServiceInput, ...request.Option) (*appmeshpreview.DeleteVirtualServiceOutput, error) + DeleteVirtualServiceRequest(*appmeshpreview.DeleteVirtualServiceInput) (*request.Request, *appmeshpreview.DeleteVirtualServiceOutput) + + DescribeMesh(*appmeshpreview.DescribeMeshInput) (*appmeshpreview.DescribeMeshOutput, error) + DescribeMeshWithContext(aws.Context, *appmeshpreview.DescribeMeshInput, ...request.Option) (*appmeshpreview.DescribeMeshOutput, error) + DescribeMeshRequest(*appmeshpreview.DescribeMeshInput) (*request.Request, *appmeshpreview.DescribeMeshOutput) + + DescribeRoute(*appmeshpreview.DescribeRouteInput) (*appmeshpreview.DescribeRouteOutput, error) + DescribeRouteWithContext(aws.Context, *appmeshpreview.DescribeRouteInput, ...request.Option) (*appmeshpreview.DescribeRouteOutput, error) + DescribeRouteRequest(*appmeshpreview.DescribeRouteInput) (*request.Request, *appmeshpreview.DescribeRouteOutput) + + DescribeVirtualNode(*appmeshpreview.DescribeVirtualNodeInput) (*appmeshpreview.DescribeVirtualNodeOutput, error) + DescribeVirtualNodeWithContext(aws.Context, *appmeshpreview.DescribeVirtualNodeInput, ...request.Option) (*appmeshpreview.DescribeVirtualNodeOutput, error) + DescribeVirtualNodeRequest(*appmeshpreview.DescribeVirtualNodeInput) (*request.Request, *appmeshpreview.DescribeVirtualNodeOutput) + + DescribeVirtualRouter(*appmeshpreview.DescribeVirtualRouterInput) (*appmeshpreview.DescribeVirtualRouterOutput, error) + DescribeVirtualRouterWithContext(aws.Context, *appmeshpreview.DescribeVirtualRouterInput, ...request.Option) (*appmeshpreview.DescribeVirtualRouterOutput, error) + DescribeVirtualRouterRequest(*appmeshpreview.DescribeVirtualRouterInput) (*request.Request, *appmeshpreview.DescribeVirtualRouterOutput) + + DescribeVirtualService(*appmeshpreview.DescribeVirtualServiceInput) (*appmeshpreview.DescribeVirtualServiceOutput, error) + DescribeVirtualServiceWithContext(aws.Context, *appmeshpreview.DescribeVirtualServiceInput, ...request.Option) (*appmeshpreview.DescribeVirtualServiceOutput, error) + DescribeVirtualServiceRequest(*appmeshpreview.DescribeVirtualServiceInput) (*request.Request, *appmeshpreview.DescribeVirtualServiceOutput) + + ListMeshes(*appmeshpreview.ListMeshesInput) (*appmeshpreview.ListMeshesOutput, error) + ListMeshesWithContext(aws.Context, *appmeshpreview.ListMeshesInput, ...request.Option) (*appmeshpreview.ListMeshesOutput, error) + ListMeshesRequest(*appmeshpreview.ListMeshesInput) (*request.Request, *appmeshpreview.ListMeshesOutput) + + ListRoutes(*appmeshpreview.ListRoutesInput) (*appmeshpreview.ListRoutesOutput, error) + ListRoutesWithContext(aws.Context, *appmeshpreview.ListRoutesInput, ...request.Option) (*appmeshpreview.ListRoutesOutput, error) + ListRoutesRequest(*appmeshpreview.ListRoutesInput) (*request.Request, *appmeshpreview.ListRoutesOutput) + + ListVirtualNodes(*appmeshpreview.ListVirtualNodesInput) (*appmeshpreview.ListVirtualNodesOutput, error) + ListVirtualNodesWithContext(aws.Context, *appmeshpreview.ListVirtualNodesInput, ...request.Option) (*appmeshpreview.ListVirtualNodesOutput, error) + ListVirtualNodesRequest(*appmeshpreview.ListVirtualNodesInput) (*request.Request, *appmeshpreview.ListVirtualNodesOutput) + + ListVirtualRouters(*appmeshpreview.ListVirtualRoutersInput) (*appmeshpreview.ListVirtualRoutersOutput, error) + ListVirtualRoutersWithContext(aws.Context, *appmeshpreview.ListVirtualRoutersInput, ...request.Option) (*appmeshpreview.ListVirtualRoutersOutput, error) + ListVirtualRoutersRequest(*appmeshpreview.ListVirtualRoutersInput) (*request.Request, *appmeshpreview.ListVirtualRoutersOutput) + + ListVirtualServices(*appmeshpreview.ListVirtualServicesInput) (*appmeshpreview.ListVirtualServicesOutput, error) + ListVirtualServicesWithContext(aws.Context, *appmeshpreview.ListVirtualServicesInput, ...request.Option) (*appmeshpreview.ListVirtualServicesOutput, error) + ListVirtualServicesRequest(*appmeshpreview.ListVirtualServicesInput) (*request.Request, *appmeshpreview.ListVirtualServicesOutput) + + UpdateMesh(*appmeshpreview.UpdateMeshInput) (*appmeshpreview.UpdateMeshOutput, error) + UpdateMeshWithContext(aws.Context, *appmeshpreview.UpdateMeshInput, ...request.Option) (*appmeshpreview.UpdateMeshOutput, error) + UpdateMeshRequest(*appmeshpreview.UpdateMeshInput) (*request.Request, *appmeshpreview.UpdateMeshOutput) + + UpdateRoute(*appmeshpreview.UpdateRouteInput) (*appmeshpreview.UpdateRouteOutput, error) + UpdateRouteWithContext(aws.Context, *appmeshpreview.UpdateRouteInput, ...request.Option) (*appmeshpreview.UpdateRouteOutput, error) + UpdateRouteRequest(*appmeshpreview.UpdateRouteInput) (*request.Request, *appmeshpreview.UpdateRouteOutput) + + UpdateVirtualNode(*appmeshpreview.UpdateVirtualNodeInput) (*appmeshpreview.UpdateVirtualNodeOutput, error) + UpdateVirtualNodeWithContext(aws.Context, *appmeshpreview.UpdateVirtualNodeInput, ...request.Option) (*appmeshpreview.UpdateVirtualNodeOutput, error) + UpdateVirtualNodeRequest(*appmeshpreview.UpdateVirtualNodeInput) (*request.Request, *appmeshpreview.UpdateVirtualNodeOutput) + + UpdateVirtualRouter(*appmeshpreview.UpdateVirtualRouterInput) (*appmeshpreview.UpdateVirtualRouterOutput, error) + UpdateVirtualRouterWithContext(aws.Context, *appmeshpreview.UpdateVirtualRouterInput, ...request.Option) (*appmeshpreview.UpdateVirtualRouterOutput, error) + UpdateVirtualRouterRequest(*appmeshpreview.UpdateVirtualRouterInput) (*request.Request, *appmeshpreview.UpdateVirtualRouterOutput) + + UpdateVirtualService(*appmeshpreview.UpdateVirtualServiceInput) (*appmeshpreview.UpdateVirtualServiceOutput, error) + UpdateVirtualServiceWithContext(aws.Context, *appmeshpreview.UpdateVirtualServiceInput, ...request.Option) (*appmeshpreview.UpdateVirtualServiceOutput, error) + UpdateVirtualServiceRequest(*appmeshpreview.UpdateVirtualServiceInput) (*request.Request, *appmeshpreview.UpdateVirtualServiceOutput) +} + +var _ AppMeshPreviewAPI = (*appmeshpreview.AppMeshPreview)(nil) diff --git a/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/doc.go b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/doc.go new file mode 100644 index 000000000000..f8a7b2415a39 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/doc.go @@ -0,0 +1,26 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +// Package appmeshpreview provides the client and types for making API +// requests to AWS App Mesh Preview. +// +// See https://docs.aws.amazon.com/goto/WebAPI/appmesh-preview-2019-01-25 for more information on this service. +// +// See appmeshpreview package documentation for more information. +// https://docs.aws.amazon.com/sdk-for-go/api/service/appmeshpreview/ +// +// Using the Client +// +// To contact AWS App Mesh Preview with the SDK use the New function to create +// a new service client. With that client you can make API requests to the service. +// These clients are safe to use concurrently. +// +// See the SDK's documentation for more information on how to use the SDK. +// https://docs.aws.amazon.com/sdk-for-go/api/ +// +// See aws.Config documentation for more information on configuring SDK clients. +// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config +// +// See the AWS App Mesh Preview client AppMeshPreview for more +// information on creating client for this service. +// https://docs.aws.amazon.com/sdk-for-go/api/service/appmeshpreview/#New +package appmeshpreview diff --git a/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/errors.go b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/errors.go new file mode 100644 index 000000000000..e71726ec0e3b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/errors.go @@ -0,0 +1,58 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package appmeshpreview + +import ( + "github.com/aws/aws-sdk-go/private/protocol" +) + +const ( + + // ErrCodeBadRequestException for service response error code + // "BadRequestException". + ErrCodeBadRequestException = "BadRequestException" + + // ErrCodeConflictException for service response error code + // "ConflictException". + ErrCodeConflictException = "ConflictException" + + // ErrCodeForbiddenException for service response error code + // "ForbiddenException". + ErrCodeForbiddenException = "ForbiddenException" + + // ErrCodeInternalServerErrorException for service response error code + // "InternalServerErrorException". + ErrCodeInternalServerErrorException = "InternalServerErrorException" + + // ErrCodeLimitExceededException for service response error code + // "LimitExceededException". + ErrCodeLimitExceededException = "LimitExceededException" + + // ErrCodeNotFoundException for service response error code + // "NotFoundException". + ErrCodeNotFoundException = "NotFoundException" + + // ErrCodeResourceInUseException for service response error code + // "ResourceInUseException". + ErrCodeResourceInUseException = "ResourceInUseException" + + // ErrCodeServiceUnavailableException for service response error code + // "ServiceUnavailableException". + ErrCodeServiceUnavailableException = "ServiceUnavailableException" + + // ErrCodeTooManyRequestsException for service response error code + // "TooManyRequestsException". + ErrCodeTooManyRequestsException = "TooManyRequestsException" +) + +var exceptionFromCode = map[string]func(protocol.ResponseMetadata) error{ + "BadRequestException": newErrorBadRequestException, + "ConflictException": newErrorConflictException, + "ForbiddenException": newErrorForbiddenException, + "InternalServerErrorException": newErrorInternalServerErrorException, + "LimitExceededException": newErrorLimitExceededException, + "NotFoundException": newErrorNotFoundException, + "ResourceInUseException": newErrorResourceInUseException, + "ServiceUnavailableException": newErrorServiceUnavailableException, + "TooManyRequestsException": newErrorTooManyRequestsException, +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/service.go b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/service.go new file mode 100644 index 000000000000..5d6a4a90741e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/appmeshpreview/service.go @@ -0,0 +1,104 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package appmeshpreview + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/signer/v4" + "github.com/aws/aws-sdk-go/private/protocol" + "github.com/aws/aws-sdk-go/private/protocol/restjson" +) + +// AppMeshPreview provides the API operation methods for making requests to +// AWS App Mesh Preview. See this package's package overview docs +// for details on the service. +// +// AppMeshPreview methods are safe to use concurrently. It is not safe to +// modify mutate any of the struct's properties though. +type AppMeshPreview struct { + *client.Client +} + +// Used for custom client initialization logic +var initClient func(*client.Client) + +// Used for custom request initialization logic +var initRequest func(*request.Request) + +// Service information constants +const ( + ServiceName = "App Mesh Preview" // Name of service. + EndpointsID = "appmesh-preview" // ID to lookup a service endpoint with. + ServiceID = "App Mesh Preview" // ServiceID is a unique identifier of a specific service. +) + +// New creates a new instance of the AppMeshPreview client with a session. +// If additional configuration is needed for the client instance use the optional +// aws.Config parameter to add your extra config. +// +// Example: +// mySession := session.Must(session.NewSession()) +// +// // Create a AppMeshPreview client from just a session. +// svc := appmeshpreview.New(mySession) +// +// // Create a AppMeshPreview client with additional configuration +// svc := appmeshpreview.New(mySession, aws.NewConfig().WithRegion("us-west-2")) +func New(p client.ConfigProvider, cfgs ...*aws.Config) *AppMeshPreview { + c := p.ClientConfig(EndpointsID, cfgs...) + if c.SigningNameDerived || len(c.SigningName) == 0 { + c.SigningName = "appmesh-preview" + } + return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName) +} + +// newClient creates, initializes and returns a new service client instance. +func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *AppMeshPreview { + svc := &AppMeshPreview{ + Client: client.New( + cfg, + metadata.ClientInfo{ + ServiceName: ServiceName, + ServiceID: ServiceID, + SigningName: signingName, + SigningRegion: signingRegion, + PartitionID: partitionID, + Endpoint: endpoint, + APIVersion: "2019-01-25", + }, + handlers, + ), + } + + // Handlers + svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) + svc.Handlers.Build.PushBackNamed(restjson.BuildHandler) + svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler) + svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler) + svc.Handlers.UnmarshalError.PushBackNamed( + protocol.NewUnmarshalErrorHandler(restjson.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(), + ) + + // Run custom client initialization if present + if initClient != nil { + initClient(svc.Client) + } + + return svc +} + +// newRequest creates a new request for a AppMeshPreview operation and runs any +// custom request initialization. +func (c *AppMeshPreview) newRequest(op *request.Operation, params, data interface{}) *request.Request { + req := c.NewRequest(op, params, data) + + // Run custom request initialization if present + if initRequest != nil { + initRequest(req) + } + + return req +} From 1852beddb314ef08f802d888adcb3a4af6ca0b4a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 1 Feb 2020 18:06:59 -0500 Subject: [PATCH 04/17] Add 'GO111MODULE=off' to go commands. --- GNUmakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 543fc32b73d2..06982ce1e6d8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,21 +8,21 @@ TEST_COUNT?=1 default: build build: fmtcheck - go install + GO111MODULE=off go install gen: rm -f aws/internal/keyvaluetags/*_gen.go - go generate ./... + GO111MODULE=off go generate ./... sweep: @echo "WARNING: This will destroy infrastructure. Use only in development accounts." - go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout 60m + GO111MODULE=off go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout 60m test: fmtcheck - go test $(TEST) $(TESTARGS) -timeout=120s -parallel=4 + GO111MODULE=off go test $(TEST) $(TESTARGS) -timeout=120s -parallel=4 testacc: fmtcheck - TF_ACC=1 go test $(TEST) -v -count $(TEST_COUNT) -parallel 20 $(TESTARGS) -timeout 120m + GO111MODULE=off TF_ACC=1 go test $(TEST) -v -count $(TEST_COUNT) -parallel 20 $(TESTARGS) -timeout 120m fmt: @echo "==> Fixing source code with gofmt..." From e9b339d105d76e1eb06641317679896794c15237 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 1 Feb 2020 18:43:35 -0500 Subject: [PATCH 05/17] - Comment out resource tagging - Alias appmeshpreview to appmesh - Remove test sweepers - Correct service in acceptance test arn checking Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualService === RUN TestAccAWSAppmesh/VirtualService/virtualNode === RUN TestAccAWSAppmesh/VirtualService/virtualRouter === RUN TestAccAWSAppmesh/Mesh === RUN TestAccAWSAppmesh/Mesh/basic === RUN TestAccAWSAppmesh/Mesh/egressFilter === RUN TestAccAWSAppmesh/Route === RUN TestAccAWSAppmesh/Route/httpRoute === RUN TestAccAWSAppmesh/Route/tcpRoute === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/listenerHealthChecks === RUN TestAccAWSAppmesh/VirtualNode/logging === RUN TestAccAWSAppmesh/VirtualNode/basic === RUN TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery === RUN TestAccAWSAppmesh/VirtualRouter === RUN TestAccAWSAppmesh/VirtualRouter/basic --- PASS: TestAccAWSAppmesh (504.50s) --- PASS: TestAccAWSAppmesh/VirtualService (85.82s) --- PASS: TestAccAWSAppmesh/VirtualService/virtualNode (45.03s) --- PASS: TestAccAWSAppmesh/VirtualService/virtualRouter (40.78s) --- PASS: TestAccAWSAppmesh/Mesh (69.52s) --- PASS: TestAccAWSAppmesh/Mesh/basic (22.54s) --- PASS: TestAccAWSAppmesh/Mesh/egressFilter (46.98s) --- PASS: TestAccAWSAppmesh/Route (87.39s) --- PASS: TestAccAWSAppmesh/Route/httpRoute (44.00s) --- PASS: TestAccAWSAppmesh/Route/tcpRoute (43.38s) --- PASS: TestAccAWSAppmesh/VirtualNode (221.41s) --- PASS: TestAccAWSAppmesh/VirtualNode/listenerHealthChecks (40.86s) --- PASS: TestAccAWSAppmesh/VirtualNode/logging (41.29s) --- PASS: TestAccAWSAppmesh/VirtualNode/basic (25.50s) --- PASS: TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery (113.76s) --- PASS: TestAccAWSAppmesh/VirtualRouter (40.37s) --- PASS: TestAccAWSAppmesh/VirtualRouter/basic (40.37s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 504.545s --- aws/config.go | 6 +- aws/resource_aws_appmesh_mesh.go | 36 ++-- aws/resource_aws_appmesh_mesh_test.go | 108 +++++----- aws/resource_aws_appmesh_route.go | 36 ++-- aws/resource_aws_appmesh_route_test.go | 184 +++++++++--------- aws/resource_aws_appmesh_test.go | 10 +- aws/resource_aws_appmesh_virtual_node.go | 36 ++-- aws/resource_aws_appmesh_virtual_node_test.go | 140 ++++++------- aws/resource_aws_appmesh_virtual_router.go | 36 ++-- ...esource_aws_appmesh_virtual_router_test.go | 142 +++++++------- aws/resource_aws_appmesh_virtual_service.go | 36 ++-- ...source_aws_appmesh_virtual_service_test.go | 138 ++++++------- aws/structure.go | 2 +- go.sum | 1 + 14 files changed, 456 insertions(+), 455 deletions(-) diff --git a/aws/config.go b/aws/config.go index 962a7658d4e2..5912ea3f511c 100644 --- a/aws/config.go +++ b/aws/config.go @@ -17,7 +17,7 @@ import ( "github.com/aws/aws-sdk-go/service/apigatewayv2" "github.com/aws/aws-sdk-go/service/applicationautoscaling" "github.com/aws/aws-sdk-go/service/applicationinsights" - "github.com/aws/aws-sdk-go/service/appmesh" + "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/aws/aws-sdk-go/service/appstream" "github.com/aws/aws-sdk-go/service/appsync" "github.com/aws/aws-sdk-go/service/athena" @@ -192,7 +192,7 @@ type AWSClient struct { apigatewayv2conn *apigatewayv2.ApiGatewayV2 appautoscalingconn *applicationautoscaling.ApplicationAutoScaling applicationinsightsconn *applicationinsights.ApplicationInsights - appmeshconn *appmesh.AppMesh + appmeshconn *appmeshpreview.AppMeshPreview appstreamconn *appstream.AppStream appsyncconn *appsync.AppSync athenaconn *athena.Athena @@ -397,7 +397,7 @@ func (c *Config) Client() (interface{}, error) { apigatewayv2conn: apigatewayv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["apigateway"])})), appautoscalingconn: applicationautoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["applicationautoscaling"])})), applicationinsightsconn: applicationinsights.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["applicationinsights"])})), - appmeshconn: appmesh.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appmesh"])})), + appmeshconn: appmeshpreview.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appmesh"])})), appstreamconn: appstream.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appstream"])})), appsyncconn: appsync.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appsync"])})), athenaconn: athena.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["athena"])})), diff --git a/aws/resource_aws_appmesh_mesh.go b/aws/resource_aws_appmesh_mesh.go index eabfc0b9b300..e1caea780843 100644 --- a/aws/resource_aws_appmesh_mesh.go +++ b/aws/resource_aws_appmesh_mesh.go @@ -6,10 +6,10 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + // "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsAppmeshMesh() *schema.Resource { @@ -76,7 +76,7 @@ func resourceAwsAppmeshMesh() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + // "tags": tagsSchema(), }, } } @@ -88,7 +88,7 @@ func resourceAwsAppmeshMeshCreate(d *schema.ResourceData, meta interface{}) erro req := &appmesh.CreateMeshInput{ MeshName: aws.String(meshName), Spec: expandAppmeshMeshSpec(d.Get("spec").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), + // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } log.Printf("[DEBUG] Creating App Mesh service mesh: %#v", req) @@ -132,15 +132,15 @@ func resourceAwsAppmeshMeshRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error setting spec: %s", err) } - tags, err := keyvaluetags.AppmeshListTags(conn, arn) + // tags, err := keyvaluetags.AppmeshListTags(conn, arn) - if err != nil { - return fmt.Errorf("error listing tags for App Mesh service mesh (%s): %s", arn, err) - } + // if err != nil { + // return fmt.Errorf("error listing tags for App Mesh service mesh (%s): %s", arn, err) + // } - if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) - } + // if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { + // return fmt.Errorf("error setting tags: %s", err) + // } return nil } @@ -162,14 +162,14 @@ func resourceAwsAppmeshMeshUpdate(d *schema.ResourceData, meta interface{}) erro } } - arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + // arn := d.Get("arn").(string) + // if d.HasChange("tags") { + // o, n := d.GetChange("tags") - if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { - return fmt.Errorf("error updating App Mesh service mesh (%s) tags: %s", arn, err) - } - } + // if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { + // return fmt.Errorf("error updating App Mesh service mesh (%s) tags: %s", arn, err) + // } + // } return resourceAwsAppmeshMeshRead(d, meta) } diff --git a/aws/resource_aws_appmesh_mesh_test.go b/aws/resource_aws_appmesh_mesh_test.go index 0849a8ccac22..b8491bbe4306 100644 --- a/aws/resource_aws_appmesh_mesh_test.go +++ b/aws/resource_aws_appmesh_mesh_test.go @@ -2,68 +2,68 @@ package aws import ( "fmt" - "log" + // "log" "regexp" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func init() { - resource.AddTestSweepers("aws_appmesh_mesh", &resource.Sweeper{ - Name: "aws_appmesh_mesh", - F: testSweepAppmeshMeshes, - Dependencies: []string{ - "aws_appmesh_virtual_service", - "aws_appmesh_virtual_router", - "aws_appmesh_virtual_node", - }, - }) -} - -func testSweepAppmeshMeshes(region string) error { - client, err := sharedClientForRegion(region) - if err != nil { - return fmt.Errorf("error getting client: %s", err) - } - conn := client.(*AWSClient).appmeshconn - - err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, mesh := range page.Meshes { - name := aws.StringValue(mesh.MeshName) - - input := &appmesh.DeleteMeshInput{ - MeshName: aws.String(name), - } - - log.Printf("[INFO] Deleting Appmesh Mesh: %s", name) - _, err := conn.DeleteMesh(input) - - if err != nil { - log.Printf("[ERROR] Error deleting Appmesh Mesh (%s): %s", name, err) - } - } - - return !isLast - }) - if err != nil { - if testSweepSkipSweepError(err) { - log.Printf("[WARN] Skipping Appmesh Mesh sweep for %s: %s", region, err) - return nil - } - return fmt.Errorf("error retrieving Appmesh Meshes: %s", err) - } - - return nil -} +// func init() { +// resource.AddTestSweepers("aws_appmesh_mesh", &resource.Sweeper{ +// Name: "aws_appmesh_mesh", +// F: testSweepAppmeshMeshes, +// Dependencies: []string{ +// "aws_appmesh_virtual_service", +// "aws_appmesh_virtual_router", +// "aws_appmesh_virtual_node", +// }, +// }) +// } + +// func testSweepAppmeshMeshes(region string) error { +// client, err := sharedClientForRegion(region) +// if err != nil { +// return fmt.Errorf("error getting client: %s", err) +// } +// conn := client.(*AWSClient).appmeshconn + +// err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, mesh := range page.Meshes { +// name := aws.StringValue(mesh.MeshName) + +// input := &appmesh.DeleteMeshInput{ +// MeshName: aws.String(name), +// } + +// log.Printf("[INFO] Deleting Appmesh Mesh: %s", name) +// _, err := conn.DeleteMesh(input) + +// if err != nil { +// log.Printf("[ERROR] Error deleting Appmesh Mesh (%s): %s", name, err) +// } +// } + +// return !isLast +// }) +// if err != nil { +// if testSweepSkipSweepError(err) { +// log.Printf("[WARN] Skipping Appmesh Mesh sweep for %s: %s", region, err) +// return nil +// } +// return fmt.Errorf("error retrieving Appmesh Meshes: %s", err) +// } + +// return nil +// } func testAccAwsAppmeshMesh_basic(t *testing.T) { var mesh appmesh.MeshData @@ -82,7 +82,7 @@ func testAccAwsAppmeshMesh_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccMatchResourceAttrRegionalARN(resourceName, "arn", "appmesh", regexp.MustCompile(`mesh/.+`)), + testAccMatchResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", regexp.MustCompile(`mesh/.+`)), ), }, { diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index 04e5ee35e9d8..5bce25652865 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -9,11 +9,11 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + // "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsAppmeshRoute() *schema.Resource { @@ -340,7 +340,7 @@ func resourceAwsAppmeshRoute() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + // "tags": tagsSchema(), }, } } @@ -572,7 +572,7 @@ func resourceAwsAppmeshRouteCreate(d *schema.ResourceData, meta interface{}) err RouteName: aws.String(d.Get("name").(string)), VirtualRouterName: aws.String(d.Get("virtual_router_name").(string)), Spec: expandAppmeshRouteSpec(d.Get("spec").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), + // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } log.Printf("[DEBUG] Creating App Mesh route: %#v", req) @@ -620,15 +620,15 @@ func resourceAwsAppmeshRouteRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("error setting spec: %s", err) } - tags, err := keyvaluetags.AppmeshListTags(conn, arn) + // tags, err := keyvaluetags.AppmeshListTags(conn, arn) - if err != nil { - return fmt.Errorf("error listing tags for App Mesh route (%s): %s", arn, err) - } + // if err != nil { + // return fmt.Errorf("error listing tags for App Mesh route (%s): %s", arn, err) + // } - if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) - } + // if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { + // return fmt.Errorf("error setting tags: %s", err) + // } return nil } @@ -652,14 +652,14 @@ func resourceAwsAppmeshRouteUpdate(d *schema.ResourceData, meta interface{}) err } } - arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + // arn := d.Get("arn").(string) + // if d.HasChange("tags") { + // o, n := d.GetChange("tags") - if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { - return fmt.Errorf("error updating App Mesh route (%s) tags: %s", arn, err) - } - } + // if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { + // return fmt.Errorf("error updating App Mesh route (%s) tags: %s", arn, err) + // } + // } return resourceAwsAppmeshRouteRead(d, meta) } diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index de4207081822..71c900ede495 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -2,102 +2,102 @@ package aws import ( "fmt" - "log" + // "log" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func init() { - resource.AddTestSweepers("aws_appmesh_route", &resource.Sweeper{ - Name: "aws_appmesh_route", - F: testSweepAppmeshRoutes, - }) -} - -func testSweepAppmeshRoutes(region string) error { - client, err := sharedClientForRegion(region) - if err != nil { - return fmt.Errorf("error getting client: %s", err) - } - conn := client.(*AWSClient).appmeshconn - - err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, mesh := range page.Meshes { - listVirtualRoutersInput := &appmesh.ListVirtualRoutersInput{ - MeshName: mesh.MeshName, - } - meshName := aws.StringValue(mesh.MeshName) - - err := conn.ListVirtualRoutersPages(listVirtualRoutersInput, func(page *appmesh.ListVirtualRoutersOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, virtualRouter := range page.VirtualRouters { - listRoutesInput := &appmesh.ListRoutesInput{ - MeshName: mesh.MeshName, - VirtualRouterName: virtualRouter.VirtualRouterName, - } - virtualRouterName := aws.StringValue(virtualRouter.VirtualRouterName) - - err := conn.ListRoutesPages(listRoutesInput, func(page *appmesh.ListRoutesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, route := range page.Routes { - input := &appmesh.DeleteRouteInput{ - MeshName: mesh.MeshName, - RouteName: route.RouteName, - VirtualRouterName: virtualRouter.VirtualRouterName, - } - routeName := aws.StringValue(route.RouteName) - - log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Router (%s) Route: %s", meshName, virtualRouterName, routeName) - _, err := conn.DeleteRoute(input) - - if err != nil { - log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Router (%s) Route (%s): %s", meshName, virtualRouterName, routeName, err) - } - } - - return !isLast - }) - - if err != nil { - log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Router (%s) Routes: %s", meshName, virtualRouterName, err) - } - } - - return !isLast - }) - - if err != nil { - log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Routers: %s", meshName, err) - } - } - - return !isLast - }) - if err != nil { - if testSweepSkipSweepError(err) { - log.Printf("[WARN] Skipping Appmesh Mesh sweep for %s: %s", region, err) - return nil - } - return fmt.Errorf("error retrieving Appmesh Meshes: %s", err) - } - - return nil -} +// func init() { +// resource.AddTestSweepers("aws_appmesh_route", &resource.Sweeper{ +// Name: "aws_appmesh_route", +// F: testSweepAppmeshRoutes, +// }) +// } + +// func testSweepAppmeshRoutes(region string) error { +// client, err := sharedClientForRegion(region) +// if err != nil { +// return fmt.Errorf("error getting client: %s", err) +// } +// conn := client.(*AWSClient).appmeshconn + +// err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, mesh := range page.Meshes { +// listVirtualRoutersInput := &appmesh.ListVirtualRoutersInput{ +// MeshName: mesh.MeshName, +// } +// meshName := aws.StringValue(mesh.MeshName) + +// err := conn.ListVirtualRoutersPages(listVirtualRoutersInput, func(page *appmesh.ListVirtualRoutersOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, virtualRouter := range page.VirtualRouters { +// listRoutesInput := &appmesh.ListRoutesInput{ +// MeshName: mesh.MeshName, +// VirtualRouterName: virtualRouter.VirtualRouterName, +// } +// virtualRouterName := aws.StringValue(virtualRouter.VirtualRouterName) + +// err := conn.ListRoutesPages(listRoutesInput, func(page *appmesh.ListRoutesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, route := range page.Routes { +// input := &appmesh.DeleteRouteInput{ +// MeshName: mesh.MeshName, +// RouteName: route.RouteName, +// VirtualRouterName: virtualRouter.VirtualRouterName, +// } +// routeName := aws.StringValue(route.RouteName) + +// log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Router (%s) Route: %s", meshName, virtualRouterName, routeName) +// _, err := conn.DeleteRoute(input) + +// if err != nil { +// log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Router (%s) Route (%s): %s", meshName, virtualRouterName, routeName, err) +// } +// } + +// return !isLast +// }) + +// if err != nil { +// log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Router (%s) Routes: %s", meshName, virtualRouterName, err) +// } +// } + +// return !isLast +// }) + +// if err != nil { +// log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Routers: %s", meshName, err) +// } +// } + +// return !isLast +// }) +// if err != nil { +// if testSweepSkipSweepError(err) { +// log.Printf("[WARN] Skipping Appmesh Mesh sweep for %s: %s", region, err) +// return nil +// } +// return fmt.Errorf("error retrieving Appmesh Meshes: %s", err) +// } + +// return nil +// } func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { var r appmesh.RouteData @@ -356,7 +356,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -383,7 +383,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -428,7 +428,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -449,7 +449,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index d637b467f316..b9e0e9bfcf7a 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -9,7 +9,7 @@ func TestAccAWSAppmesh(t *testing.T) { "Mesh": { "basic": testAccAwsAppmeshMesh_basic, "egressFilter": testAccAwsAppmeshMesh_egressFilter, - "tags": testAccAwsAppmeshMesh_tags, + // "tags": testAccAwsAppmeshMesh_tags, }, "Route": { "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, @@ -19,23 +19,23 @@ func TestAccAWSAppmesh(t *testing.T) { "httpRoute": testAccAwsAppmeshRoute_httpRoute, "routePriority": testAccAwsAppmeshRoute_routePriority, "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, - "tags": testAccAwsAppmeshRoute_tags, + // "tags": testAccAwsAppmeshRoute_tags, }, "VirtualNode": { "basic": testAccAwsAppmeshVirtualNode_basic, "cloudMapServiceDiscovery": testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery, "listenerHealthChecks": testAccAwsAppmeshVirtualNode_listenerHealthChecks, "logging": testAccAwsAppmeshVirtualNode_logging, - "tags": testAccAwsAppmeshVirtualNode_tags, + // "tags": testAccAwsAppmeshVirtualNode_tags, }, "VirtualRouter": { "basic": testAccAwsAppmeshVirtualRouter_basic, - "tags": testAccAwsAppmeshVirtualRouter_tags, + // "tags": testAccAwsAppmeshVirtualRouter_tags, }, "VirtualService": { "virtualNode": testAccAwsAppmeshVirtualService_virtualNode, "virtualRouter": testAccAwsAppmeshVirtualService_virtualRouter, - "tags": testAccAwsAppmeshVirtualService_tags, + // "tags": testAccAwsAppmeshVirtualService_tags, }, } diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index 69fdc3e881c5..998b24af5ad5 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -8,11 +8,11 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + // "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsAppmeshVirtualNode() *schema.Resource { @@ -293,7 +293,7 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + // "tags": tagsSchema(), }, } } @@ -305,7 +305,7 @@ func resourceAwsAppmeshVirtualNodeCreate(d *schema.ResourceData, meta interface{ MeshName: aws.String(d.Get("mesh_name").(string)), VirtualNodeName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualNodeSpec(d.Get("spec").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), + // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } log.Printf("[DEBUG] Creating App Mesh virtual node: %#v", req) @@ -351,15 +351,15 @@ func resourceAwsAppmeshVirtualNodeRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("error setting spec: %s", err) } - tags, err := keyvaluetags.AppmeshListTags(conn, arn) + // tags, err := keyvaluetags.AppmeshListTags(conn, arn) - if err != nil { - return fmt.Errorf("error listing tags for App Mesh virtual node (%s): %s", arn, err) - } + // if err != nil { + // return fmt.Errorf("error listing tags for App Mesh virtual node (%s): %s", arn, err) + // } - if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) - } + // if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { + // return fmt.Errorf("error setting tags: %s", err) + // } return nil } @@ -382,14 +382,14 @@ func resourceAwsAppmeshVirtualNodeUpdate(d *schema.ResourceData, meta interface{ } } - arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + // arn := d.Get("arn").(string) + // if d.HasChange("tags") { + // o, n := d.GetChange("tags") - if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { - return fmt.Errorf("error updating App Mesh virtual node (%s) tags: %s", arn, err) - } - } + // if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { + // return fmt.Errorf("error updating App Mesh virtual node (%s) tags: %s", arn, err) + // } + // } return resourceAwsAppmeshVirtualNodeRead(d, meta) } diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index f6ea0eac6f51..e2a8c4283e5b 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -2,81 +2,81 @@ package aws import ( "fmt" - "log" + // "log" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func init() { - resource.AddTestSweepers("aws_appmesh_virtual_node", &resource.Sweeper{ - Name: "aws_appmesh_virtual_node", - F: testSweepAppmeshVirtualNodes, - }) -} - -func testSweepAppmeshVirtualNodes(region string) error { - client, err := sharedClientForRegion(region) - if err != nil { - return fmt.Errorf("error getting client: %s", err) - } - conn := client.(*AWSClient).appmeshconn - - err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, mesh := range page.Meshes { - listVirtualNodesInput := &appmesh.ListVirtualNodesInput{ - MeshName: mesh.MeshName, - } - meshName := aws.StringValue(mesh.MeshName) - - err := conn.ListVirtualNodesPages(listVirtualNodesInput, func(page *appmesh.ListVirtualNodesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, virtualNode := range page.VirtualNodes { - input := &appmesh.DeleteVirtualNodeInput{ - MeshName: mesh.MeshName, - VirtualNodeName: virtualNode.VirtualNodeName, - } - virtualNodeName := aws.StringValue(virtualNode.VirtualNodeName) - - log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Node: %s", meshName, virtualNodeName) - _, err := conn.DeleteVirtualNode(input) - - if err != nil { - log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Node (%s): %s", meshName, virtualNodeName, err) - } - } - - return !isLast - }) - - if err != nil { - log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Nodes: %s", meshName, err) - } - } - - return !isLast - }) - if err != nil { - if testSweepSkipSweepError(err) { - log.Printf("[WARN] Skipping Appmesh Virtual Node sweep for %s: %s", region, err) - return nil - } - return fmt.Errorf("error retrieving Appmesh Virtual Nodes: %s", err) - } - - return nil -} +// func init() { +// resource.AddTestSweepers("aws_appmesh_virtual_node", &resource.Sweeper{ +// Name: "aws_appmesh_virtual_node", +// F: testSweepAppmeshVirtualNodes, +// }) +// } + +// func testSweepAppmeshVirtualNodes(region string) error { +// client, err := sharedClientForRegion(region) +// if err != nil { +// return fmt.Errorf("error getting client: %s", err) +// } +// conn := client.(*AWSClient).appmeshconn + +// err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, mesh := range page.Meshes { +// listVirtualNodesInput := &appmesh.ListVirtualNodesInput{ +// MeshName: mesh.MeshName, +// } +// meshName := aws.StringValue(mesh.MeshName) + +// err := conn.ListVirtualNodesPages(listVirtualNodesInput, func(page *appmesh.ListVirtualNodesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, virtualNode := range page.VirtualNodes { +// input := &appmesh.DeleteVirtualNodeInput{ +// MeshName: mesh.MeshName, +// VirtualNodeName: virtualNode.VirtualNodeName, +// } +// virtualNodeName := aws.StringValue(virtualNode.VirtualNodeName) + +// log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Node: %s", meshName, virtualNodeName) +// _, err := conn.DeleteVirtualNode(input) + +// if err != nil { +// log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Node (%s): %s", meshName, virtualNodeName, err) +// } +// } + +// return !isLast +// }) + +// if err != nil { +// log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Nodes: %s", meshName, err) +// } +// } + +// return !isLast +// }) +// if err != nil { +// if testSweepSkipSweepError(err) { +// log.Printf("[WARN] Skipping Appmesh Virtual Node sweep for %s: %s", region, err) +// return nil +// } +// return fmt.Errorf("error retrieving Appmesh Virtual Nodes: %s", err) +// } + +// return nil +// } func testAccAwsAppmeshVirtualNode_basic(t *testing.T) { var vn appmesh.VirtualNodeData @@ -102,7 +102,7 @@ func testAccAwsAppmeshVirtualNode_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, { @@ -208,7 +208,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, { @@ -240,7 +240,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb1.simpleapp.local"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, { diff --git a/aws/resource_aws_appmesh_virtual_router.go b/aws/resource_aws_appmesh_virtual_router.go index 9081e50667b5..66f62133dd18 100644 --- a/aws/resource_aws_appmesh_virtual_router.go +++ b/aws/resource_aws_appmesh_virtual_router.go @@ -8,11 +8,11 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + // "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsAppmeshVirtualRouter() *schema.Resource { @@ -112,7 +112,7 @@ func resourceAwsAppmeshVirtualRouter() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + // "tags": tagsSchema(), }, } } @@ -124,7 +124,7 @@ func resourceAwsAppmeshVirtualRouterCreate(d *schema.ResourceData, meta interfac MeshName: aws.String(d.Get("mesh_name").(string)), VirtualRouterName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualRouterSpec(d.Get("spec").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), + // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } log.Printf("[DEBUG] Creating App Mesh virtual router: %#v", req) @@ -170,15 +170,15 @@ func resourceAwsAppmeshVirtualRouterRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("error setting spec: %s", err) } - tags, err := keyvaluetags.AppmeshListTags(conn, arn) + // tags, err := keyvaluetags.AppmeshListTags(conn, arn) - if err != nil { - return fmt.Errorf("error listing tags for App Mesh virtual router (%s): %s", arn, err) - } + // if err != nil { + // return fmt.Errorf("error listing tags for App Mesh virtual router (%s): %s", arn, err) + // } - if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) - } + // if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { + // return fmt.Errorf("error setting tags: %s", err) + // } return nil } @@ -201,14 +201,14 @@ func resourceAwsAppmeshVirtualRouterUpdate(d *schema.ResourceData, meta interfac } } - arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + // arn := d.Get("arn").(string) + // if d.HasChange("tags") { + // o, n := d.GetChange("tags") - if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { - return fmt.Errorf("error updating App Mesh virtual router (%s) tags: %s", arn, err) - } - } + // if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { + // return fmt.Errorf("error updating App Mesh virtual router (%s) tags: %s", arn, err) + // } + // } return resourceAwsAppmeshVirtualRouterRead(d, meta) } diff --git a/aws/resource_aws_appmesh_virtual_router_test.go b/aws/resource_aws_appmesh_virtual_router_test.go index 46d1d2d922c8..a7a329d770b1 100644 --- a/aws/resource_aws_appmesh_virtual_router_test.go +++ b/aws/resource_aws_appmesh_virtual_router_test.go @@ -2,84 +2,84 @@ package aws import ( "fmt" - "log" + // "log" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func init() { - resource.AddTestSweepers("aws_appmesh_virtual_router", &resource.Sweeper{ - Name: "aws_appmesh_virtual_router", - F: testSweepAppmeshVirtualRouters, - Dependencies: []string{ - "aws_appmesh_route", - }, - }) -} - -func testSweepAppmeshVirtualRouters(region string) error { - client, err := sharedClientForRegion(region) - if err != nil { - return fmt.Errorf("error getting client: %s", err) - } - conn := client.(*AWSClient).appmeshconn - - err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, mesh := range page.Meshes { - listVirtualRoutersInput := &appmesh.ListVirtualRoutersInput{ - MeshName: mesh.MeshName, - } - meshName := aws.StringValue(mesh.MeshName) - - err := conn.ListVirtualRoutersPages(listVirtualRoutersInput, func(page *appmesh.ListVirtualRoutersOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, virtualRouter := range page.VirtualRouters { - input := &appmesh.DeleteVirtualRouterInput{ - MeshName: mesh.MeshName, - VirtualRouterName: virtualRouter.VirtualRouterName, - } - virtualRouterName := aws.StringValue(virtualRouter.VirtualRouterName) - - log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Router: %s", meshName, virtualRouterName) - _, err := conn.DeleteVirtualRouter(input) - - if err != nil { - log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Router (%s): %s", meshName, virtualRouterName, err) - } - } - - return !isLast - }) - - if err != nil { - log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Routers: %s", meshName, err) - } - } - - return !isLast - }) - if err != nil { - if testSweepSkipSweepError(err) { - log.Printf("[WARN] Skipping Appmesh Virtual Router sweep for %s: %s", region, err) - return nil - } - return fmt.Errorf("error retrieving Appmesh Virtual Routers: %s", err) - } - - return nil -} +// func init() { +// resource.AddTestSweepers("aws_appmesh_virtual_router", &resource.Sweeper{ +// Name: "aws_appmesh_virtual_router", +// F: testSweepAppmeshVirtualRouters, +// Dependencies: []string{ +// "aws_appmesh_route", +// }, +// }) +// } + +// func testSweepAppmeshVirtualRouters(region string) error { +// client, err := sharedClientForRegion(region) +// if err != nil { +// return fmt.Errorf("error getting client: %s", err) +// } +// conn := client.(*AWSClient).appmeshconn + +// err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, mesh := range page.Meshes { +// listVirtualRoutersInput := &appmesh.ListVirtualRoutersInput{ +// MeshName: mesh.MeshName, +// } +// meshName := aws.StringValue(mesh.MeshName) + +// err := conn.ListVirtualRoutersPages(listVirtualRoutersInput, func(page *appmesh.ListVirtualRoutersOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, virtualRouter := range page.VirtualRouters { +// input := &appmesh.DeleteVirtualRouterInput{ +// MeshName: mesh.MeshName, +// VirtualRouterName: virtualRouter.VirtualRouterName, +// } +// virtualRouterName := aws.StringValue(virtualRouter.VirtualRouterName) + +// log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Router: %s", meshName, virtualRouterName) +// _, err := conn.DeleteVirtualRouter(input) + +// if err != nil { +// log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Router (%s): %s", meshName, virtualRouterName, err) +// } +// } + +// return !isLast +// }) + +// if err != nil { +// log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Routers: %s", meshName, err) +// } +// } + +// return !isLast +// }) +// if err != nil { +// if testSweepSkipSweepError(err) { +// log.Printf("[WARN] Skipping Appmesh Virtual Router sweep for %s: %s", region, err) +// return nil +// } +// return fmt.Errorf("error retrieving Appmesh Virtual Routers: %s", err) +// } + +// return nil +// } func testAccAwsAppmeshVirtualRouter_basic(t *testing.T) { var vr appmesh.VirtualRouterData @@ -116,7 +116,7 @@ func testAccAwsAppmeshVirtualRouter_basic(t *testing.T) { resource.TestCheckResourceAttrSet( resourceName, "last_updated_date"), testAccCheckResourceAttrRegionalARN( - resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s", meshName, vrName)), + resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s", meshName, vrName)), ), }, { diff --git a/aws/resource_aws_appmesh_virtual_service.go b/aws/resource_aws_appmesh_virtual_service.go index 367e5dcb88da..521dff8b55ca 100644 --- a/aws/resource_aws_appmesh_virtual_service.go +++ b/aws/resource_aws_appmesh_virtual_service.go @@ -7,10 +7,10 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + // "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func resourceAwsAppmeshVirtualService() *schema.Resource { @@ -107,7 +107,7 @@ func resourceAwsAppmeshVirtualService() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + // "tags": tagsSchema(), }, } } @@ -119,7 +119,7 @@ func resourceAwsAppmeshVirtualServiceCreate(d *schema.ResourceData, meta interfa MeshName: aws.String(d.Get("mesh_name").(string)), VirtualServiceName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualServiceSpec(d.Get("spec").([]interface{})), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), + // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } log.Printf("[DEBUG] Creating App Mesh virtual service: %#v", req) @@ -165,15 +165,15 @@ func resourceAwsAppmeshVirtualServiceRead(d *schema.ResourceData, meta interface return fmt.Errorf("error setting spec: %s", err) } - tags, err := keyvaluetags.AppmeshListTags(conn, arn) + // tags, err := keyvaluetags.AppmeshListTags(conn, arn) - if err != nil { - return fmt.Errorf("error listing tags for App Mesh virtual service (%s): %s", arn, err) - } + // if err != nil { + // return fmt.Errorf("error listing tags for App Mesh virtual service (%s): %s", arn, err) + // } - if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) - } + // if err := d.Set("tags", tags.IgnoreAws().Map()); err != nil { + // return fmt.Errorf("error setting tags: %s", err) + // } return nil } @@ -196,14 +196,14 @@ func resourceAwsAppmeshVirtualServiceUpdate(d *schema.ResourceData, meta interfa } } - arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + // arn := d.Get("arn").(string) + // if d.HasChange("tags") { + // o, n := d.GetChange("tags") - if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { - return fmt.Errorf("error updating App Mesh virtual service (%s) tags: %s", arn, err) - } - } + // if err := keyvaluetags.AppmeshUpdateTags(conn, arn, o, n); err != nil { + // return fmt.Errorf("error updating App Mesh virtual service (%s) tags: %s", arn, err) + // } + // } return resourceAwsAppmeshVirtualServiceRead(d, meta) } diff --git a/aws/resource_aws_appmesh_virtual_service_test.go b/aws/resource_aws_appmesh_virtual_service_test.go index e520b6aa2c2d..5b49bdef5c43 100644 --- a/aws/resource_aws_appmesh_virtual_service_test.go +++ b/aws/resource_aws_appmesh_virtual_service_test.go @@ -2,81 +2,81 @@ package aws import ( "fmt" - "log" + // "log" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func init() { - resource.AddTestSweepers("aws_appmesh_virtual_service", &resource.Sweeper{ - Name: "aws_appmesh_virtual_service", - F: testSweepAppmeshVirtualServices, - }) -} - -func testSweepAppmeshVirtualServices(region string) error { - client, err := sharedClientForRegion(region) - if err != nil { - return fmt.Errorf("error getting client: %s", err) - } - conn := client.(*AWSClient).appmeshconn - - err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, mesh := range page.Meshes { - listVirtualServicesInput := &appmesh.ListVirtualServicesInput{ - MeshName: mesh.MeshName, - } - meshName := aws.StringValue(mesh.MeshName) - - err := conn.ListVirtualServicesPages(listVirtualServicesInput, func(page *appmesh.ListVirtualServicesOutput, isLast bool) bool { - if page == nil { - return !isLast - } - - for _, virtualService := range page.VirtualServices { - input := &appmesh.DeleteVirtualServiceInput{ - MeshName: mesh.MeshName, - VirtualServiceName: virtualService.VirtualServiceName, - } - virtualServiceName := aws.StringValue(virtualService.VirtualServiceName) - - log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Service: %s", meshName, virtualServiceName) - _, err := conn.DeleteVirtualService(input) - - if err != nil { - log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Service (%s): %s", meshName, virtualServiceName, err) - } - } - - return !isLast - }) - - if err != nil { - log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Services: %s", meshName, err) - } - } - - return !isLast - }) - if err != nil { - if testSweepSkipSweepError(err) { - log.Printf("[WARN] Skipping Appmesh Virtual Service sweep for %s: %s", region, err) - return nil - } - return fmt.Errorf("error retrieving Appmesh Virtual Services: %s", err) - } - - return nil -} +// func init() { +// resource.AddTestSweepers("aws_appmesh_virtual_service", &resource.Sweeper{ +// Name: "aws_appmesh_virtual_service", +// F: testSweepAppmeshVirtualServices, +// }) +// } + +// func testSweepAppmeshVirtualServices(region string) error { +// client, err := sharedClientForRegion(region) +// if err != nil { +// return fmt.Errorf("error getting client: %s", err) +// } +// conn := client.(*AWSClient).appmeshconn + +// err = conn.ListMeshesPages(&appmesh.ListMeshesInput{}, func(page *appmesh.ListMeshesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, mesh := range page.Meshes { +// listVirtualServicesInput := &appmesh.ListVirtualServicesInput{ +// MeshName: mesh.MeshName, +// } +// meshName := aws.StringValue(mesh.MeshName) + +// err := conn.ListVirtualServicesPages(listVirtualServicesInput, func(page *appmesh.ListVirtualServicesOutput, isLast bool) bool { +// if page == nil { +// return !isLast +// } + +// for _, virtualService := range page.VirtualServices { +// input := &appmesh.DeleteVirtualServiceInput{ +// MeshName: mesh.MeshName, +// VirtualServiceName: virtualService.VirtualServiceName, +// } +// virtualServiceName := aws.StringValue(virtualService.VirtualServiceName) + +// log.Printf("[INFO] Deleting Appmesh Mesh (%s) Virtual Service: %s", meshName, virtualServiceName) +// _, err := conn.DeleteVirtualService(input) + +// if err != nil { +// log.Printf("[ERROR] Error deleting Appmesh Mesh (%s) Virtual Service (%s): %s", meshName, virtualServiceName, err) +// } +// } + +// return !isLast +// }) + +// if err != nil { +// log.Printf("[ERROR] Error retrieving Appmesh Mesh (%s) Virtual Services: %s", meshName, err) +// } +// } + +// return !isLast +// }) +// if err != nil { +// if testSweepSkipSweepError(err) { +// log.Printf("[WARN] Skipping Appmesh Virtual Service sweep for %s: %s", region, err) +// return nil +// } +// return fmt.Errorf("error retrieving Appmesh Virtual Services: %s", err) +// } + +// return nil +// } func testAccAwsAppmeshVirtualService_virtualNode(t *testing.T) { var vs appmesh.VirtualServiceData @@ -103,7 +103,7 @@ func testAccAwsAppmeshVirtualService_virtualNode(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_node.0.virtual_node_name", vnName1), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName)), ), }, { @@ -153,7 +153,7 @@ func testAccAwsAppmeshVirtualService_virtualRouter(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_router.0.virtual_router_name", vrName1), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName))), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName))), }, { Config: testAccAppmeshVirtualServiceConfig_virtualRouter(meshName, vrName1, vrName2, vsName, "aws_appmesh_virtual_router.bar"), diff --git a/aws/structure.go b/aws/structure.go index 588558d87fa8..eb2b131a8ce2 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -13,7 +13,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/private/protocol/json/jsonutil" "github.com/aws/aws-sdk-go/service/apigateway" - "github.com/aws/aws-sdk-go/service/appmesh" + appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/aws/aws-sdk-go/service/appsync" "github.com/aws/aws-sdk-go/service/autoscaling" "github.com/aws/aws-sdk-go/service/cloudformation" diff --git a/go.sum b/go.sum index b04b7f5fd4c5..347131aa00e0 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,7 @@ github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3A github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.28.9 h1:grIuBQc+p3dTRXerh5+2OxSuWFi0iXuxbFdTSg0jaW0= github.com/aws/aws-sdk-go v1.28.9/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.29.14 h1:NToqC5ZQ2RaxxSPp9szuQimWQWPG++ITwXbklq/FN7c= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= From 0dfbf3b4508adafbf203b94a5fe2001a32a335a0 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 2 Feb 2020 18:26:54 -0500 Subject: [PATCH 06/17] Add 'mesh_owner' and 'resource_owner' attributes in support of cross-account mesh sharing. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/Mesh === RUN TestAccAWSAppmesh/Mesh/basic === RUN TestAccAWSAppmesh/Mesh/egressFilter === RUN TestAccAWSAppmesh/Route === RUN TestAccAWSAppmesh/Route/httpRoute === RUN TestAccAWSAppmesh/Route/tcpRoute === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/basic === RUN TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery === RUN TestAccAWSAppmesh/VirtualNode/listenerHealthChecks === RUN TestAccAWSAppmesh/VirtualNode/logging === RUN TestAccAWSAppmesh/VirtualRouter === RUN TestAccAWSAppmesh/VirtualRouter/basic === RUN TestAccAWSAppmesh/VirtualService === RUN TestAccAWSAppmesh/VirtualService/virtualNode === RUN TestAccAWSAppmesh/VirtualService/virtualRouter --- PASS: TestAccAWSAppmesh (505.56s) --- PASS: TestAccAWSAppmesh/Mesh (69.94s) --- PASS: TestAccAWSAppmesh/Mesh/basic (23.51s) --- PASS: TestAccAWSAppmesh/Mesh/egressFilter (46.43s) --- PASS: TestAccAWSAppmesh/Route (88.69s) --- PASS: TestAccAWSAppmesh/Route/httpRoute (43.76s) --- PASS: TestAccAWSAppmesh/Route/tcpRoute (44.93s) --- PASS: TestAccAWSAppmesh/VirtualNode (221.53s) --- PASS: TestAccAWSAppmesh/VirtualNode/basic (25.11s) --- PASS: TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery (114.29s) --- PASS: TestAccAWSAppmesh/VirtualNode/listenerHealthChecks (41.37s) --- PASS: TestAccAWSAppmesh/VirtualNode/logging (40.76s) --- PASS: TestAccAWSAppmesh/VirtualRouter (41.17s) --- PASS: TestAccAWSAppmesh/VirtualRouter/basic (41.17s) --- PASS: TestAccAWSAppmesh/VirtualService (84.22s) --- PASS: TestAccAWSAppmesh/VirtualService/virtualNode (43.32s) --- PASS: TestAccAWSAppmesh/VirtualService/virtualRouter (40.90s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 505.641s --- aws/resource_aws_appmesh_route.go | 28 +++++++++++++++++-- aws/resource_aws_appmesh_route_test.go | 8 ++++++ aws/resource_aws_appmesh_virtual_node.go | 28 +++++++++++++++++-- aws/resource_aws_appmesh_virtual_node_test.go | 10 +++++++ aws/resource_aws_appmesh_virtual_router.go | 28 +++++++++++++++++-- ...esource_aws_appmesh_virtual_router_test.go | 3 ++ aws/resource_aws_appmesh_virtual_service.go | 28 +++++++++++++++++-- ...source_aws_appmesh_virtual_service_test.go | 6 ++++ website/docs/r/appmesh_route.html.markdown | 4 +++ .../docs/r/appmesh_virtual_node.html.markdown | 4 +++ .../r/appmesh_virtual_router.html.markdown | 4 +++ .../r/appmesh_virtual_service.html.markdown | 4 +++ 12 files changed, 147 insertions(+), 8 deletions(-) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index 5bce25652865..3a25528b075c 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -41,6 +41,14 @@ func resourceAwsAppmeshRoute() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 255), }, + "mesh_owner": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validateAwsAccountId, + }, + "virtual_router_name": { Type: schema.TypeString, Required: true, @@ -340,6 +348,11 @@ func resourceAwsAppmeshRoute() *schema.Resource { Computed: true, }, + "resource_owner": { + Type: schema.TypeString, + Computed: true, + }, + // "tags": tagsSchema(), }, } @@ -574,6 +587,9 @@ func resourceAwsAppmeshRouteCreate(d *schema.ResourceData, meta interface{}) err Spec: expandAppmeshRouteSpec(d.Get("spec").([]interface{})), // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } log.Printf("[DEBUG] Creating App Mesh route: %#v", req) resp, err := conn.CreateRoute(req) @@ -589,11 +605,16 @@ func resourceAwsAppmeshRouteCreate(d *schema.ResourceData, meta interface{}) err func resourceAwsAppmeshRouteRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn - resp, err := conn.DescribeRoute(&appmesh.DescribeRouteInput{ + req := &appmesh.DescribeRouteInput{ MeshName: aws.String(d.Get("mesh_name").(string)), RouteName: aws.String(d.Get("name").(string)), VirtualRouterName: aws.String(d.Get("virtual_router_name").(string)), - }) + } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } + + resp, err := conn.DescribeRoute(req) if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") { log.Printf("[WARN] App Mesh route (%s) not found, removing from state", d.Id()) d.SetId("") @@ -611,10 +632,12 @@ func resourceAwsAppmeshRouteRead(d *schema.ResourceData, meta interface{}) error arn := aws.StringValue(resp.Route.Metadata.Arn) d.Set("name", resp.Route.RouteName) d.Set("mesh_name", resp.Route.MeshName) + d.Set("mesh_owner", resp.Route.Metadata.MeshOwner) d.Set("virtual_router_name", resp.Route.VirtualRouterName) d.Set("arn", arn) d.Set("created_date", resp.Route.Metadata.CreatedAt.Format(time.RFC3339)) d.Set("last_updated_date", resp.Route.Metadata.LastUpdatedAt.Format(time.RFC3339)) + d.Set("resource_owner", resp.Route.Metadata.ResourceOwner) err = d.Set("spec", flattenAppmeshRouteSpec(resp.Route.Spec)) if err != nil { return fmt.Errorf("error setting spec: %s", err) @@ -640,6 +663,7 @@ func resourceAwsAppmeshRouteUpdate(d *schema.ResourceData, meta interface{}) err _, v := d.GetChange("spec") req := &appmesh.UpdateRouteInput{ MeshName: aws.String(d.Get("mesh_name").(string)), + MeshOwner: aws.String(d.Get("mesh_owner").(string)), RouteName: aws.String(d.Get("name").(string)), VirtualRouterName: aws.String(d.Get("virtual_router_name").(string)), Spec: expandAppmeshRouteSpec(v.([]interface{})), diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index 71c900ede495..b4325decda7b 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -338,6 +338,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { testAccCheckAppmeshRouteExists(resourceName, &r), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), @@ -356,6 +357,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, @@ -365,6 +367,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { testAccCheckAppmeshRouteExists(resourceName, &r), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), @@ -383,6 +386,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, @@ -416,6 +420,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { testAccCheckAppmeshRouteExists(resourceName, &r), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), @@ -428,6 +433,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, @@ -437,6 +443,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { testAccCheckAppmeshRouteExists(resourceName, &r), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), @@ -449,6 +456,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index 998b24af5ad5..fd400ab52462 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -43,6 +43,14 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 255), }, + "mesh_owner": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validateAwsAccountId, + }, + "spec": { Type: schema.TypeList, Required: true, @@ -293,6 +301,11 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { Computed: true, }, + "resource_owner": { + Type: schema.TypeString, + Computed: true, + }, + // "tags": tagsSchema(), }, } @@ -307,6 +320,9 @@ func resourceAwsAppmeshVirtualNodeCreate(d *schema.ResourceData, meta interface{ Spec: expandAppmeshVirtualNodeSpec(d.Get("spec").([]interface{})), // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } log.Printf("[DEBUG] Creating App Mesh virtual node: %#v", req) resp, err := conn.CreateVirtualNode(req) @@ -322,10 +338,15 @@ func resourceAwsAppmeshVirtualNodeCreate(d *schema.ResourceData, meta interface{ func resourceAwsAppmeshVirtualNodeRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn - resp, err := conn.DescribeVirtualNode(&appmesh.DescribeVirtualNodeInput{ + req := &appmesh.DescribeVirtualNodeInput{ MeshName: aws.String(d.Get("mesh_name").(string)), VirtualNodeName: aws.String(d.Get("name").(string)), - }) + } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } + + resp, err := conn.DescribeVirtualNode(req) if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") { log.Printf("[WARN] App Mesh virtual node (%s) not found, removing from state", d.Id()) d.SetId("") @@ -343,9 +364,11 @@ func resourceAwsAppmeshVirtualNodeRead(d *schema.ResourceData, meta interface{}) arn := aws.StringValue(resp.VirtualNode.Metadata.Arn) d.Set("name", resp.VirtualNode.VirtualNodeName) d.Set("mesh_name", resp.VirtualNode.MeshName) + d.Set("mesh_owner", resp.VirtualNode.Metadata.MeshOwner) d.Set("arn", arn) d.Set("created_date", resp.VirtualNode.Metadata.CreatedAt.Format(time.RFC3339)) d.Set("last_updated_date", resp.VirtualNode.Metadata.LastUpdatedAt.Format(time.RFC3339)) + d.Set("resource_owner", resp.VirtualNode.Metadata.ResourceOwner) err = d.Set("spec", flattenAppmeshVirtualNodeSpec(resp.VirtualNode.Spec)) if err != nil { return fmt.Errorf("error setting spec: %s", err) @@ -371,6 +394,7 @@ func resourceAwsAppmeshVirtualNodeUpdate(d *schema.ResourceData, meta interface{ _, v := d.GetChange("spec") req := &appmesh.UpdateVirtualNodeInput{ MeshName: aws.String(d.Get("mesh_name").(string)), + MeshOwner: aws.String(d.Get("mesh_owner").(string)), VirtualNodeName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualNodeSpec(v.([]interface{})), } diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index e2a8c4283e5b..9d2e419d16df 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -95,6 +95,7 @@ func testAccAwsAppmeshVirtualNode_basic(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "0"), @@ -102,6 +103,7 @@ func testAccAwsAppmeshVirtualNode_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, @@ -135,6 +137,7 @@ func testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.aws_cloud_map.#", "1"), @@ -150,6 +153,7 @@ func testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.aws_cloud_map.#", "1"), @@ -186,6 +190,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), @@ -208,6 +213,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, @@ -217,6 +223,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "2"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2576932631.virtual_service.#", "1"), @@ -240,6 +247,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb1.simpleapp.local"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, @@ -270,6 +278,7 @@ func testAccAwsAppmeshVirtualNode_logging(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.0.access_log.#", "1"), @@ -283,6 +292,7 @@ func testAccAwsAppmeshVirtualNode_logging(t *testing.T) { testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), resource.TestCheckResourceAttr(resourceName, "name", vnName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.0.access_log.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.0.access_log.0.file.#", "1"), diff --git a/aws/resource_aws_appmesh_virtual_router.go b/aws/resource_aws_appmesh_virtual_router.go index 66f62133dd18..21c22d223c7a 100644 --- a/aws/resource_aws_appmesh_virtual_router.go +++ b/aws/resource_aws_appmesh_virtual_router.go @@ -43,6 +43,14 @@ func resourceAwsAppmeshVirtualRouter() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 255), }, + "mesh_owner": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validateAwsAccountId, + }, + "spec": { Type: schema.TypeList, Required: true, @@ -112,6 +120,11 @@ func resourceAwsAppmeshVirtualRouter() *schema.Resource { Computed: true, }, + "resource_owner": { + Type: schema.TypeString, + Computed: true, + }, + // "tags": tagsSchema(), }, } @@ -126,6 +139,9 @@ func resourceAwsAppmeshVirtualRouterCreate(d *schema.ResourceData, meta interfac Spec: expandAppmeshVirtualRouterSpec(d.Get("spec").([]interface{})), // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } log.Printf("[DEBUG] Creating App Mesh virtual router: %#v", req) resp, err := conn.CreateVirtualRouter(req) @@ -141,10 +157,15 @@ func resourceAwsAppmeshVirtualRouterCreate(d *schema.ResourceData, meta interfac func resourceAwsAppmeshVirtualRouterRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn - resp, err := conn.DescribeVirtualRouter(&appmesh.DescribeVirtualRouterInput{ + req := &appmesh.DescribeVirtualRouterInput{ MeshName: aws.String(d.Get("mesh_name").(string)), VirtualRouterName: aws.String(d.Get("name").(string)), - }) + } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } + + resp, err := conn.DescribeVirtualRouter(req) if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") { log.Printf("[WARN] App Mesh virtual router (%s) not found, removing from state", d.Id()) d.SetId("") @@ -162,9 +183,11 @@ func resourceAwsAppmeshVirtualRouterRead(d *schema.ResourceData, meta interface{ arn := aws.StringValue(resp.VirtualRouter.Metadata.Arn) d.Set("name", resp.VirtualRouter.VirtualRouterName) d.Set("mesh_name", resp.VirtualRouter.MeshName) + d.Set("mesh_owner", resp.VirtualRouter.Metadata.MeshOwner) d.Set("arn", arn) d.Set("created_date", resp.VirtualRouter.Metadata.CreatedAt.Format(time.RFC3339)) d.Set("last_updated_date", resp.VirtualRouter.Metadata.LastUpdatedAt.Format(time.RFC3339)) + d.Set("resource_owner", resp.VirtualRouter.Metadata.ResourceOwner) err = d.Set("spec", flattenAppmeshVirtualRouterSpec(resp.VirtualRouter.Spec)) if err != nil { return fmt.Errorf("error setting spec: %s", err) @@ -190,6 +213,7 @@ func resourceAwsAppmeshVirtualRouterUpdate(d *schema.ResourceData, meta interfac _, v := d.GetChange("spec") req := &appmesh.UpdateVirtualRouterInput{ MeshName: aws.String(d.Get("mesh_name").(string)), + MeshOwner: aws.String(d.Get("mesh_owner").(string)), VirtualRouterName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualRouterSpec(v.([]interface{})), } diff --git a/aws/resource_aws_appmesh_virtual_router_test.go b/aws/resource_aws_appmesh_virtual_router_test.go index a7a329d770b1..5d8ea062540b 100644 --- a/aws/resource_aws_appmesh_virtual_router_test.go +++ b/aws/resource_aws_appmesh_virtual_router_test.go @@ -101,6 +101,7 @@ func testAccAwsAppmeshVirtualRouter_basic(t *testing.T) { resourceName, "name", vrName), resource.TestCheckResourceAttr( resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr( resourceName, "spec.#", "1"), resource.TestCheckResourceAttr( @@ -115,6 +116,7 @@ func testAccAwsAppmeshVirtualRouter_basic(t *testing.T) { resourceName, "created_date"), resource.TestCheckResourceAttrSet( resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN( resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s", meshName, vrName)), ), @@ -128,6 +130,7 @@ func testAccAwsAppmeshVirtualRouter_basic(t *testing.T) { resourceName, "name", vrName), resource.TestCheckResourceAttr( resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr( resourceName, "spec.#", "1"), resource.TestCheckResourceAttr( diff --git a/aws/resource_aws_appmesh_virtual_service.go b/aws/resource_aws_appmesh_virtual_service.go index 521dff8b55ca..ea969309407e 100644 --- a/aws/resource_aws_appmesh_virtual_service.go +++ b/aws/resource_aws_appmesh_virtual_service.go @@ -38,6 +38,14 @@ func resourceAwsAppmeshVirtualService() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 255), }, + "mesh_owner": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validateAwsAccountId, + }, + "spec": { Type: schema.TypeList, Required: true, @@ -107,6 +115,11 @@ func resourceAwsAppmeshVirtualService() *schema.Resource { Computed: true, }, + "resource_owner": { + Type: schema.TypeString, + Computed: true, + }, + // "tags": tagsSchema(), }, } @@ -121,6 +134,9 @@ func resourceAwsAppmeshVirtualServiceCreate(d *schema.ResourceData, meta interfa Spec: expandAppmeshVirtualServiceSpec(d.Get("spec").([]interface{})), // Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppmeshTags(), } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } log.Printf("[DEBUG] Creating App Mesh virtual service: %#v", req) resp, err := conn.CreateVirtualService(req) @@ -136,10 +152,15 @@ func resourceAwsAppmeshVirtualServiceCreate(d *schema.ResourceData, meta interfa func resourceAwsAppmeshVirtualServiceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn - resp, err := conn.DescribeVirtualService(&appmesh.DescribeVirtualServiceInput{ + req := &appmesh.DescribeVirtualServiceInput{ MeshName: aws.String(d.Get("mesh_name").(string)), VirtualServiceName: aws.String(d.Get("name").(string)), - }) + } + if v, ok := d.GetOk("mesh_owner"); ok { + req.MeshOwner = aws.String(v.(string)) + } + + resp, err := conn.DescribeVirtualService(req) if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") { log.Printf("[WARN] App Mesh virtual service (%s) not found, removing from state", d.Id()) d.SetId("") @@ -157,9 +178,11 @@ func resourceAwsAppmeshVirtualServiceRead(d *schema.ResourceData, meta interface arn := aws.StringValue(resp.VirtualService.Metadata.Arn) d.Set("name", resp.VirtualService.VirtualServiceName) d.Set("mesh_name", resp.VirtualService.MeshName) + d.Set("mesh_owner", resp.VirtualService.Metadata.MeshOwner) d.Set("arn", arn) d.Set("created_date", resp.VirtualService.Metadata.CreatedAt.Format(time.RFC3339)) d.Set("last_updated_date", resp.VirtualService.Metadata.LastUpdatedAt.Format(time.RFC3339)) + d.Set("resource_owner", resp.VirtualService.Metadata.ResourceOwner) err = d.Set("spec", flattenAppmeshVirtualServiceSpec(resp.VirtualService.Spec)) if err != nil { return fmt.Errorf("error setting spec: %s", err) @@ -185,6 +208,7 @@ func resourceAwsAppmeshVirtualServiceUpdate(d *schema.ResourceData, meta interfa _, v := d.GetChange("spec") req := &appmesh.UpdateVirtualServiceInput{ MeshName: aws.String(d.Get("mesh_name").(string)), + MeshOwner: aws.String(d.Get("mesh_owner").(string)), VirtualServiceName: aws.String(d.Get("name").(string)), Spec: expandAppmeshVirtualServiceSpec(v.([]interface{})), } diff --git a/aws/resource_aws_appmesh_virtual_service_test.go b/aws/resource_aws_appmesh_virtual_service_test.go index 5b49bdef5c43..1fe986d5ba66 100644 --- a/aws/resource_aws_appmesh_virtual_service_test.go +++ b/aws/resource_aws_appmesh_virtual_service_test.go @@ -97,12 +97,14 @@ func testAccAwsAppmeshVirtualService_virtualNode(t *testing.T) { testAccCheckAppmeshVirtualServiceExists(resourceName, &vs), resource.TestCheckResourceAttr(resourceName, "name", vsName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_node.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_node.0.virtual_node_name", vnName1), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName)), ), }, @@ -112,6 +114,7 @@ func testAccAwsAppmeshVirtualService_virtualNode(t *testing.T) { testAccCheckAppmeshVirtualServiceExists(resourceName, &vs), resource.TestCheckResourceAttr(resourceName, "name", vsName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_node.#", "1"), @@ -147,12 +150,14 @@ func testAccAwsAppmeshVirtualService_virtualRouter(t *testing.T) { testAccCheckAppmeshVirtualServiceExists(resourceName, &vs), resource.TestCheckResourceAttr(resourceName, "name", vsName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_router.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_router.0.virtual_router_name", vrName1), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualService/%s", meshName, vsName))), }, { @@ -161,6 +166,7 @@ func testAccAwsAppmeshVirtualService_virtualRouter(t *testing.T) { testAccCheckAppmeshVirtualServiceExists(resourceName, &vs), resource.TestCheckResourceAttr(resourceName, "name", vsName), resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.provider.0.virtual_router.#", "1"), diff --git a/website/docs/r/appmesh_route.html.markdown b/website/docs/r/appmesh_route.html.markdown index 9a53952b26b9..ddd362f72375 100644 --- a/website/docs/r/appmesh_route.html.markdown +++ b/website/docs/r/appmesh_route.html.markdown @@ -141,6 +141,7 @@ The following arguments are supported: * `name` - (Required) The name to use for the route. * `mesh_name` - (Required) The name of the service mesh in which to create the route. +* `mesh_owner` - (Optional) The AWS account ID of the service mesh's owner. Defaults to the account ID the [AWS provider][1] is currently connected to. * `virtual_router_name` - (Required) The name of the virtual router in which to create the route. * `spec` - (Required) The route specification to apply. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -260,6 +261,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the route. * `created_date` - The creation date of the route. * `last_updated_date` - The last update date of the route. +* `resource_owner` - The resource owner's AWS account ID. ## Import @@ -269,3 +271,5 @@ e.g. ``` $ terraform import aws_appmesh_virtual_route.serviceb simpleapp/serviceB/serviceB-route ``` + +[1]: /docs/providers/aws/index.html diff --git a/website/docs/r/appmesh_virtual_node.html.markdown b/website/docs/r/appmesh_virtual_node.html.markdown index b19183108888..b9d1cf61fb9b 100644 --- a/website/docs/r/appmesh_virtual_node.html.markdown +++ b/website/docs/r/appmesh_virtual_node.html.markdown @@ -175,6 +175,7 @@ The following arguments are supported: * `name` - (Required) The name to use for the virtual node. * `mesh_name` - (Required) The name of the service mesh in which to create the virtual node. +* `mesh_owner` - (Optional) The AWS account ID of the service mesh's owner. Defaults to the account ID the [AWS provider][1] is currently connected to. * `spec` - (Required) The virtual node specification to apply. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -249,6 +250,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the virtual node. * `created_date` - The creation date of the virtual node. * `last_updated_date` - The last update date of the virtual node. +* `resource_owner` - The resource owner's AWS account ID. ## Import @@ -258,3 +260,5 @@ e.g. ``` $ terraform import aws_appmesh_virtual_node.serviceb1 simpleapp/serviceBv1 ``` + +[1]: /docs/providers/aws/index.html diff --git a/website/docs/r/appmesh_virtual_router.html.markdown b/website/docs/r/appmesh_virtual_router.html.markdown index 96c4785cdee6..e3839a05849e 100644 --- a/website/docs/r/appmesh_virtual_router.html.markdown +++ b/website/docs/r/appmesh_virtual_router.html.markdown @@ -46,6 +46,7 @@ The following arguments are supported: * `name` - (Required) The name to use for the virtual router. * `mesh_name` - (Required) The name of the service mesh in which to create the virtual router. +* `mesh_owner` - (Optional) The AWS account ID of the service mesh's owner. Defaults to the account ID the [AWS provider][1] is currently connected to. * `spec` - (Required) The virtual router specification to apply. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -71,6 +72,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the virtual router. * `created_date` - The creation date of the virtual router. * `last_updated_date` - The last update date of the virtual router. +* `resource_owner` - The resource owner's AWS account ID. ## Import @@ -80,3 +82,5 @@ e.g. ``` $ terraform import aws_appmesh_virtual_router.serviceb simpleapp/serviceB ``` + +[1]: /docs/providers/aws/index.html diff --git a/website/docs/r/appmesh_virtual_service.html.markdown b/website/docs/r/appmesh_virtual_service.html.markdown index 3e3c376cc5ff..20bedd398ba8 100644 --- a/website/docs/r/appmesh_virtual_service.html.markdown +++ b/website/docs/r/appmesh_virtual_service.html.markdown @@ -52,6 +52,7 @@ The following arguments are supported: * `name` - (Required) The name to use for the virtual service. * `mesh_name` - (Required) The name of the service mesh in which to create the virtual service. +* `mesh_owner` - (Optional) The AWS account ID of the service mesh's owner. Defaults to the account ID the [AWS provider][1] is currently connected to. * `spec` - (Required) The virtual service specification to apply. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -80,6 +81,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the virtual service. * `created_date` - The creation date of the virtual service. * `last_updated_date` - The last update date of the virtual service. +* `resource_owner` - The resource owner's AWS account ID. ## Import @@ -89,3 +91,5 @@ e.g. ``` $ terraform import aws_appmesh_virtual_service.servicea simpleapp/servicea.simpleapp.local ``` + +[1]: /docs/providers/aws/index.html From d7534923e2d3835e992dbb196c73f75503e6b354 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 29 Feb 2020 17:54:11 -0500 Subject: [PATCH 07/17] r/aws_appmesh_route: Add 'tcp_route.timeout' attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/Route' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/Route -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualRouter === RUN TestAccAWSAppmesh/VirtualRouter/basic === RUN TestAccAWSAppmesh/Route === RUN TestAccAWSAppmesh/Route/grpcRoute === RUN TestAccAWSAppmesh/Route/http2Route === RUN TestAccAWSAppmesh/Route/httpHeader === RUN TestAccAWSAppmesh/Route/httpRetryPolicy === RUN TestAccAWSAppmesh/Route/httpRoute === RUN TestAccAWSAppmesh/Route/routePriority === RUN TestAccAWSAppmesh/Route/tcpRoute === RUN TestAccAWSAppmesh/Route/tcpRouteIdleTimeout --- PASS: TestAccAWSAppmesh (393.96s) --- PASS: TestAccAWSAppmesh/VirtualRouter (40.51s) --- PASS: TestAccAWSAppmesh/VirtualRouter/basic (40.51s) --- PASS: TestAccAWSAppmesh/Route (353.45s) --- PASS: TestAccAWSAppmesh/Route/grpcRoute (44.54s) --- PASS: TestAccAWSAppmesh/Route/http2Route (44.07s) --- PASS: TestAccAWSAppmesh/Route/httpHeader (43.80s) --- PASS: TestAccAWSAppmesh/Route/httpRetryPolicy (44.30s) --- PASS: TestAccAWSAppmesh/Route/httpRoute (43.99s) --- PASS: TestAccAWSAppmesh/Route/routePriority (43.95s) --- PASS: TestAccAWSAppmesh/Route/tcpRoute (43.97s) --- PASS: TestAccAWSAppmesh/Route/tcpRouteIdleTimeout (44.83s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 394.018s --- aws/resource_aws_appmesh_route.go | 34 +++++++ aws/resource_aws_appmesh_route_test.go | 105 +++++++++++++++++++++ aws/resource_aws_appmesh_test.go | 15 +-- aws/structure.go | 38 ++++++++ website/docs/r/appmesh_route.html.markdown | 10 ++ 5 files changed, 195 insertions(+), 7 deletions(-) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index 3a25528b075c..a467253790e7 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -326,6 +326,40 @@ func resourceAwsAppmeshRoute() *schema.Resource { }, }, }, + + "timeout": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "idle": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + }, + }, + }, }, }, }, diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index b4325decda7b..d75d76b5807c 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -430,6 +430,7 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), @@ -453,6 +454,82 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + ResourceName: resourceName, + ImportStateIdFunc: testAccAwsAppmeshRouteImportStateIdFunc(resourceName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccAwsAppmeshRoute_tcpRouteIdleTimeout(t *testing.T) { + var r appmesh.RouteData + resourceName := "aws_appmesh_route.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vrName := acctest.RandomWithPrefix("tf-acc-test") + vn1Name := acctest.RandomWithPrefix("tf-acc-test") + vn2Name := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAppmeshRouteConfig_tcpRoute(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + ), + }, + { + Config: testAccAppmeshRouteConfig_tcpRouteWithIdleTimeout(meshName, vrName, vn1Name, vn2Name, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshRouteExists(resourceName, &r), + resource.TestCheckResourceAttr(resourceName, "name", rName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.0.idle.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.0.idle.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.0.idle.0.value", "15"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), @@ -1200,6 +1277,34 @@ resource "aws_appmesh_route" "test" { `, rName) } +func testAccAppmeshRouteConfig_tcpRouteWithIdleTimeout(meshName, vrName, vn1Name, vn2Name, rName string) string { + return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` +resource "aws_appmesh_route" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + virtual_router_name = "${aws_appmesh_virtual_router.test.name}" + + spec { + tcp_route { + action { + weighted_target { + virtual_node = "${aws_appmesh_virtual_node.foo.name}" + weight = 100 + } + } + + timeout { + idle { + unit = "s" + value = 15 + } + } + } + } +} +`, rName) +} + func testAccAppmeshRouteConfigWithTags(meshName, vrName, vn1Name, vn2Name, rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` resource "aws_appmesh_route" "test" { diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index b9e0e9bfcf7a..29b7fcf9b552 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -12,13 +12,14 @@ func TestAccAWSAppmesh(t *testing.T) { // "tags": testAccAwsAppmeshMesh_tags, }, "Route": { - "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, - "http2Route": testAccAwsAppmeshRoute_http2Route, - "httpHeader": testAccAwsAppmeshRoute_httpHeader, - "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, - "httpRoute": testAccAwsAppmeshRoute_httpRoute, - "routePriority": testAccAwsAppmeshRoute_routePriority, - "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, + "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, + "http2Route": testAccAwsAppmeshRoute_http2Route, + "httpHeader": testAccAwsAppmeshRoute_httpHeader, + "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, + "httpRoute": testAccAwsAppmeshRoute_httpRoute, + "routePriority": testAccAwsAppmeshRoute_routePriority, + "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, + "tcpRouteIdleTimeout": testAccAwsAppmeshRoute_tcpRouteIdleTimeout, // "tags": testAccAwsAppmeshRoute_tags, }, "VirtualNode": { diff --git a/aws/structure.go b/aws/structure.go index eb2b131a8ce2..bf110d16819c 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5705,6 +5705,29 @@ func expandAppmeshTcpRoute(vTcpRoute []interface{}) *appmesh.TcpRoute { } } + if vTcpRouteTimeout, ok := mTcpRoute["timeout"].([]interface{}); ok && len(vTcpRouteTimeout) > 0 && vTcpRouteTimeout[0] != nil { + tcpRouteTimeout := &appmesh.TcpTimeout{} + + mTcpRouteTimeout := vTcpRouteTimeout[0].(map[string]interface{}) + + if vIdleTimeout, ok := mTcpRouteTimeout["idle"].([]interface{}); ok && len(vIdleTimeout) > 0 && vIdleTimeout[0] != nil { + idleTimeout := &appmesh.Duration{} + + mIdleTimeout := vIdleTimeout[0].(map[string]interface{}) + + if vUnit, ok := mIdleTimeout["unit"].(string); ok && vUnit != "" { + idleTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mIdleTimeout["value"].(int); ok { + idleTimeout.Value = aws.Int64(int64(vValue)) + } + + tcpRouteTimeout.Idle = idleTimeout + } + + tcpRoute.Timeout = tcpRouteTimeout + } + return tcpRoute } @@ -5936,6 +5959,21 @@ func flattenAppmeshTcpRoute(tcpRoute *appmesh.TcpRoute) []interface{} { } } + if tcpRouteTimeout := tcpRoute.Timeout; tcpRouteTimeout != nil { + mTcpRouteTimeout := map[string]interface{}{} + + if idleTimeout := tcpRouteTimeout.Idle; idleTimeout != nil { + mIdleTimeout := map[string]interface{}{ + "unit": aws.StringValue(idleTimeout.Unit), + "value": int(aws.Int64Value(idleTimeout.Value)), + } + + mTcpRouteTimeout["idle"] = []interface{}{mIdleTimeout} + } + + mTcpRoute["timeout"] = []interface{}{mTcpRouteTimeout} + } + return []interface{}{mTcpRoute} } diff --git a/website/docs/r/appmesh_route.html.markdown b/website/docs/r/appmesh_route.html.markdown index ddd362f72375..f778e8ff9d52 100644 --- a/website/docs/r/appmesh_route.html.markdown +++ b/website/docs/r/appmesh_route.html.markdown @@ -170,6 +170,7 @@ The `http2_route` and `http_route` objects supports the following: The `tcp_route` object supports the following: * `action` - (Required) The action to take if a match is determined. +* `timeout` - (Optional) The route timeout. The `action` object supports the following: @@ -253,6 +254,15 @@ The `range` object supports the following: * `end` - (Required) The end of the range. * `start` - (Requited) The start of the range. +The `tcp_route`'s `timeout` object supports the following: + +* `idle` - (Optional) Bounds the amount of time a connection may be idle. The default value is none. + +The `idle` object supports the following: + +* `unit` - (Required) A time unit. Valid values: `s`, `ms`. +* `value` - (Required) The number of time units. Specifying `0` disables the timeout. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: From 2d80402d8bfb35f5057c608dfbe932d8465d1116 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 29 Feb 2020 18:47:11 -0500 Subject: [PATCH 08/17] Correct service in acceptance test arn checking after rebase. --- aws/resource_aws_appmesh_route_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index d75d76b5807c..e42055ac8bd5 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -148,7 +148,7 @@ func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -197,7 +197,7 @@ func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -257,7 +257,7 @@ func testAccAwsAppmeshRoute_http2Route(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -305,7 +305,7 @@ func testAccAwsAppmeshRoute_http2Route(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -637,7 +637,7 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -677,7 +677,7 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -728,7 +728,7 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -755,7 +755,7 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -812,7 +812,7 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { @@ -847,7 +847,7 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), ), }, { From 5de4b5e59bca8b1068d2065d36ed66b98016cc7f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 1 Mar 2020 17:12:46 -0500 Subject: [PATCH 09/17] Test TCP route timeout in existing acceptance test. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/Route' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/Route -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/Route === RUN TestAccAWSAppmesh/Route/httpRoute === RUN TestAccAWSAppmesh/Route/routePriority === RUN TestAccAWSAppmesh/Route/tcpRoute === RUN TestAccAWSAppmesh/Route/grpcRoute === RUN TestAccAWSAppmesh/Route/http2Route === RUN TestAccAWSAppmesh/Route/httpHeader === RUN TestAccAWSAppmesh/Route/httpRetryPolicy === RUN TestAccAWSAppmesh/VirtualRouter === RUN TestAccAWSAppmesh/VirtualRouter/basic --- PASS: TestAccAWSAppmesh (349.43s) --- PASS: TestAccAWSAppmesh/Route (308.84s) --- PASS: TestAccAWSAppmesh/Route/httpRoute (45.42s) --- PASS: TestAccAWSAppmesh/Route/routePriority (44.00s) --- PASS: TestAccAWSAppmesh/Route/tcpRoute (44.08s) --- PASS: TestAccAWSAppmesh/Route/grpcRoute (44.20s) --- PASS: TestAccAWSAppmesh/Route/http2Route (43.12s) --- PASS: TestAccAWSAppmesh/Route/httpHeader (44.36s) --- PASS: TestAccAWSAppmesh/Route/httpRetryPolicy (43.64s) --- PASS: TestAccAWSAppmesh/VirtualRouter (40.59s) --- PASS: TestAccAWSAppmesh/VirtualRouter/basic (40.59s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 349.504s --- aws/resource_aws_appmesh_route.go | 4 +- aws/resource_aws_appmesh_route_test.go | 93 -------------------------- aws/resource_aws_appmesh_test.go | 15 ++--- 3 files changed, 9 insertions(+), 103 deletions(-) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index a467253790e7..5dedb3f2330d 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -336,8 +336,8 @@ func resourceAwsAppmeshRoute() *schema.Resource { Schema: map[string]*schema.Schema{ "idle": { Type: schema.TypeList, - Required: true, - MinItems: 1, + Optional: true, + MinItems: 0, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index e42055ac8bd5..d64f01fe90e6 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -454,78 +454,6 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "2"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "0"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttrSet(resourceName, "created_date"), - resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), - ), - }, - { - ResourceName: resourceName, - ImportStateIdFunc: testAccAwsAppmeshRouteImportStateIdFunc(resourceName), - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccAwsAppmeshRoute_tcpRouteIdleTimeout(t *testing.T) { - var r appmesh.RouteData - resourceName := "aws_appmesh_route.test" - meshName := acctest.RandomWithPrefix("tf-acc-test") - vrName := acctest.RandomWithPrefix("tf-acc-test") - vn1Name := acctest.RandomWithPrefix("tf-acc-test") - vn2Name := acctest.RandomWithPrefix("tf-acc-test") - rName := acctest.RandomWithPrefix("tf-acc-test") - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAppmeshRouteDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAppmeshRouteConfig_tcpRoute(meshName, vrName, vn1Name, vn2Name, rName), - Check: resource.ComposeTestCheckFunc( - testAccCheckAppmeshRouteExists(resourceName, &r), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), - testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), - resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), - resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "0"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttrSet(resourceName, "created_date"), - resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), - testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", meshName, vrName, rName)), - ), - }, - { - Config: testAccAppmeshRouteConfig_tcpRouteWithIdleTimeout(meshName, vrName, vn1Name, vn2Name, rName), - Check: resource.ComposeTestCheckFunc( - testAccCheckAppmeshRouteExists(resourceName, &r), - resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), - testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), - resource.TestCheckResourceAttr(resourceName, "virtual_router_name", vrName), - resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.#", "1"), - resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.action.0.weighted_target.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.0.idle.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.0.timeout.0.idle.0.unit", "s"), @@ -1271,27 +1199,6 @@ resource "aws_appmesh_route" "test" { weight = 10 } } - } - } -} -`, rName) -} - -func testAccAppmeshRouteConfig_tcpRouteWithIdleTimeout(meshName, vrName, vn1Name, vn2Name, rName string) string { - return testAccAppmeshRouteConfigBase(meshName, vrName, vn1Name, vn2Name) + fmt.Sprintf(` -resource "aws_appmesh_route" "test" { - name = %[1]q - mesh_name = "${aws_appmesh_mesh.test.id}" - virtual_router_name = "${aws_appmesh_virtual_router.test.name}" - - spec { - tcp_route { - action { - weighted_target { - virtual_node = "${aws_appmesh_virtual_node.foo.name}" - weight = 100 - } - } timeout { idle { diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index 29b7fcf9b552..b9e0e9bfcf7a 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -12,14 +12,13 @@ func TestAccAWSAppmesh(t *testing.T) { // "tags": testAccAwsAppmeshMesh_tags, }, "Route": { - "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, - "http2Route": testAccAwsAppmeshRoute_http2Route, - "httpHeader": testAccAwsAppmeshRoute_httpHeader, - "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, - "httpRoute": testAccAwsAppmeshRoute_httpRoute, - "routePriority": testAccAwsAppmeshRoute_routePriority, - "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, - "tcpRouteIdleTimeout": testAccAwsAppmeshRoute_tcpRouteIdleTimeout, + "grpcRoute": testAccAwsAppmeshRoute_grpcRoute, + "http2Route": testAccAwsAppmeshRoute_http2Route, + "httpHeader": testAccAwsAppmeshRoute_httpHeader, + "httpRetryPolicy": testAccAwsAppmeshRoute_httpRetryPolicy, + "httpRoute": testAccAwsAppmeshRoute_httpRoute, + "routePriority": testAccAwsAppmeshRoute_routePriority, + "tcpRoute": testAccAwsAppmeshRoute_tcpRoute, // "tags": testAccAwsAppmeshRoute_tags, }, "VirtualNode": { From 7e346007c6ece57c75f855a79f34e48b8a883547 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 1 Mar 2020 18:11:57 -0500 Subject: [PATCH 10/17] r/aws_appmesh_route: Add grpc_route, http2_route and http_route timeout attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/Route' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/Route -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/Route === RUN TestAccAWSAppmesh/Route/routePriority === RUN TestAccAWSAppmesh/Route/tcpRoute === RUN TestAccAWSAppmesh/Route/grpcRoute === RUN TestAccAWSAppmesh/Route/http2Route === RUN TestAccAWSAppmesh/Route/httpHeader === RUN TestAccAWSAppmesh/Route/httpRetryPolicy === RUN TestAccAWSAppmesh/Route/httpRoute === RUN TestAccAWSAppmesh/VirtualRouter === RUN TestAccAWSAppmesh/VirtualRouter/basic --- PASS: TestAccAWSAppmesh (351.38s) --- PASS: TestAccAWSAppmesh/Route (310.90s) --- PASS: TestAccAWSAppmesh/Route/routePriority (44.54s) --- PASS: TestAccAWSAppmesh/Route/tcpRoute (44.65s) --- PASS: TestAccAWSAppmesh/Route/grpcRoute (44.90s) --- PASS: TestAccAWSAppmesh/Route/http2Route (44.58s) --- PASS: TestAccAWSAppmesh/Route/httpHeader (44.16s) --- PASS: TestAccAWSAppmesh/Route/httpRetryPolicy (43.95s) --- PASS: TestAccAWSAppmesh/Route/httpRoute (44.11s) --- PASS: TestAccAWSAppmesh/VirtualRouter (40.48s) --- PASS: TestAccAWSAppmesh/VirtualRouter/basic (40.48s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 351.473s --- aws/resource_aws_appmesh_route.go | 116 +++++++++++++++++++ aws/resource_aws_appmesh_route_test.go | 74 ++++++++++++ aws/structure.go | 124 +++++++++++++++++++++ website/docs/r/appmesh_route.html.markdown | 22 ++++ 4 files changed, 336 insertions(+) diff --git a/aws/resource_aws_appmesh_route.go b/aws/resource_aws_appmesh_route.go index 5dedb3f2330d..4465fbbbec89 100644 --- a/aws/resource_aws_appmesh_route.go +++ b/aws/resource_aws_appmesh_route.go @@ -264,6 +264,64 @@ func resourceAwsAppmeshRoute() *schema.Resource { }, }, }, + + "timeout": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "idle": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "per_request": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + }, + }, + }, }, }, }, @@ -606,6 +664,64 @@ func appmeshRouteHttpRouteSchema() *schema.Schema { }, }, }, + + "timeout": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "idle": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "per_request": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.DurationUnitMs, + appmesh.DurationUnitS, + }, false), + }, + + "value": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + }, + }, + }, }, }, } diff --git a/aws/resource_aws_appmesh_route_test.go b/aws/resource_aws_appmesh_route_test.go index d64f01fe90e6..ba6a0dc3e3d5 100644 --- a/aws/resource_aws_appmesh_route_test.go +++ b/aws/resource_aws_appmesh_route_test.go @@ -142,6 +142,11 @@ func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.idle.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.idle.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.idle.0.value", "10000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.per_request.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), @@ -191,6 +196,11 @@ func testAccAwsAppmeshRoute_grpcRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.idle.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.per_request.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.per_request.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.grpc_route.0.timeout.0.per_request.0.value", "20"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), @@ -252,6 +262,11 @@ func testAccAwsAppmeshRoute_http2Route(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.idle.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.per_request.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.per_request.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.per_request.0.value", "20"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -300,6 +315,11 @@ func testAccAwsAppmeshRoute_http2Route(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.idle.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.idle.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.idle.0.value", "10000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http2_route.0.timeout.0.per_request.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -352,6 +372,7 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -381,6 +402,13 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/path"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.idle.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.idle.0.unit", "ms"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.idle.0.value", "10000"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.per_request.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.per_request.0.unit", "s"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.0.per_request.0.value", "20"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -560,6 +588,7 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", "http"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -600,6 +629,7 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/path"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", "https"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -651,6 +681,7 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "42"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -678,6 +709,7 @@ func testAccAwsAppmeshRoute_routePriority(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.prefix", "/"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.match.0.scheme", ""), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.priority", "1000"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -736,6 +768,7 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.unit", "s"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.value", "15"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), @@ -771,6 +804,7 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout.0.value", "250000"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.3724400910", "connection-error"), + resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.timeout.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttrSet(resourceName, "created_date"), @@ -926,6 +960,13 @@ resource "aws_appmesh_route" "test" { weight = 100 } } + + timeout { + idle { + unit = "ms" + value = 10000 + } + } } } } @@ -991,6 +1032,13 @@ resource "aws_appmesh_route" "test" { weight = 100 } } + + timeout { + per_request { + unit = "s" + value = 20 + } + } } } } @@ -1035,6 +1083,13 @@ resource "aws_appmesh_route" "test" { weight = 100 } } + + timeout { + per_request { + unit = "s" + value = 20 + } + } } } } @@ -1097,6 +1152,13 @@ resource "aws_appmesh_route" "test" { weight = 100 } } + + timeout { + idle { + unit = "ms" + value = 10000 + } + } } } } @@ -1152,6 +1214,18 @@ resource "aws_appmesh_route" "test" { weight = 10 } } + + timeout { + idle { + unit = "ms" + value = 10000 + } + + per_request { + unit = "s" + value = 20 + } + } } } } diff --git a/aws/structure.go b/aws/structure.go index bf110d16819c..259935072a75 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5521,6 +5521,44 @@ func expandAppmeshGrpcRoute(vGrpcRoute []interface{}) *appmesh.GrpcRoute { grpcRoute.RetryPolicy = grpcRetryPolicy } + if vGrpcRouteTimeout, ok := mGrpcRoute["timeout"].([]interface{}); ok && len(vGrpcRouteTimeout) > 0 && vGrpcRouteTimeout[0] != nil { + grpcRouteTimeout := &appmesh.GrpcTimeout{} + + mGrpcRouteTimeout := vGrpcRouteTimeout[0].(map[string]interface{}) + + if vIdleTimeout, ok := mGrpcRouteTimeout["idle"].([]interface{}); ok && len(vIdleTimeout) > 0 && vIdleTimeout[0] != nil { + idleTimeout := &appmesh.Duration{} + + mIdleTimeout := vIdleTimeout[0].(map[string]interface{}) + + if vUnit, ok := mIdleTimeout["unit"].(string); ok && vUnit != "" { + idleTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mIdleTimeout["value"].(int); ok { + idleTimeout.Value = aws.Int64(int64(vValue)) + } + + grpcRouteTimeout.Idle = idleTimeout + } + + if vPerRequestTimeout, ok := mGrpcRouteTimeout["per_request"].([]interface{}); ok && len(vPerRequestTimeout) > 0 && vPerRequestTimeout[0] != nil { + perRequestTimeout := &appmesh.Duration{} + + mPerRequestTimeout := vPerRequestTimeout[0].(map[string]interface{}) + + if vUnit, ok := mPerRequestTimeout["unit"].(string); ok && vUnit != "" { + perRequestTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mPerRequestTimeout["value"].(int); ok { + perRequestTimeout.Value = aws.Int64(int64(vValue)) + } + + grpcRouteTimeout.PerRequest = perRequestTimeout + } + + grpcRoute.Timeout = grpcRouteTimeout + } + return grpcRoute } @@ -5666,6 +5704,44 @@ func expandAppmeshHttpRoute(vHttpRoute []interface{}) *appmesh.HttpRoute { httpRoute.RetryPolicy = httpRetryPolicy } + if vHttpRouteTimeout, ok := mHttpRoute["timeout"].([]interface{}); ok && len(vHttpRouteTimeout) > 0 && vHttpRouteTimeout[0] != nil { + httpRouteTimeout := &appmesh.HttpTimeout{} + + mHttpRouteTimeout := vHttpRouteTimeout[0].(map[string]interface{}) + + if vIdleTimeout, ok := mHttpRouteTimeout["idle"].([]interface{}); ok && len(vIdleTimeout) > 0 && vIdleTimeout[0] != nil { + idleTimeout := &appmesh.Duration{} + + mIdleTimeout := vIdleTimeout[0].(map[string]interface{}) + + if vUnit, ok := mIdleTimeout["unit"].(string); ok && vUnit != "" { + idleTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mIdleTimeout["value"].(int); ok { + idleTimeout.Value = aws.Int64(int64(vValue)) + } + + httpRouteTimeout.Idle = idleTimeout + } + + if vPerRequestTimeout, ok := mHttpRouteTimeout["per_request"].([]interface{}); ok && len(vPerRequestTimeout) > 0 && vPerRequestTimeout[0] != nil { + perRequestTimeout := &appmesh.Duration{} + + mPerRequestTimeout := vPerRequestTimeout[0].(map[string]interface{}) + + if vUnit, ok := mPerRequestTimeout["unit"].(string); ok && vUnit != "" { + perRequestTimeout.Unit = aws.String(vUnit) + } + if vValue, ok := mPerRequestTimeout["value"].(int); ok { + perRequestTimeout.Value = aws.Int64(int64(vValue)) + } + + httpRouteTimeout.PerRequest = perRequestTimeout + } + + httpRoute.Timeout = httpRouteTimeout + } + return httpRoute } @@ -5836,6 +5912,30 @@ func flattenAppmeshGrpcRoute(grpcRoute *appmesh.GrpcRoute) []interface{} { mGrpcRoute["retry_policy"] = []interface{}{mGrpcRetryPolicy} } + if grpcRouteTimeout := grpcRoute.Timeout; grpcRouteTimeout != nil { + mGrpcRouteTimeout := map[string]interface{}{} + + if idleTimeout := grpcRouteTimeout.Idle; idleTimeout != nil { + mIdleTimeout := map[string]interface{}{ + "unit": aws.StringValue(idleTimeout.Unit), + "value": int(aws.Int64Value(idleTimeout.Value)), + } + + mGrpcRouteTimeout["idle"] = []interface{}{mIdleTimeout} + } + + if perRequestTimeout := grpcRouteTimeout.PerRequest; perRequestTimeout != nil { + mPerRequestTimeout := map[string]interface{}{ + "unit": aws.StringValue(perRequestTimeout.Unit), + "value": int(aws.Int64Value(perRequestTimeout.Value)), + } + + mGrpcRouteTimeout["per_request"] = []interface{}{mPerRequestTimeout} + } + + mGrpcRoute["timeout"] = []interface{}{mGrpcRouteTimeout} + } + return []interface{}{mGrpcRoute} } @@ -5928,6 +6028,30 @@ func flattenAppmeshHttpRoute(httpRoute *appmesh.HttpRoute) []interface{} { mHttpRoute["retry_policy"] = []interface{}{mHttpRetryPolicy} } + if httpRouteTimeout := httpRoute.Timeout; httpRouteTimeout != nil { + mHttpRouteTimeout := map[string]interface{}{} + + if idleTimeout := httpRouteTimeout.Idle; idleTimeout != nil { + mIdleTimeout := map[string]interface{}{ + "unit": aws.StringValue(idleTimeout.Unit), + "value": int(aws.Int64Value(idleTimeout.Value)), + } + + mHttpRouteTimeout["idle"] = []interface{}{mIdleTimeout} + } + + if perRequestTimeout := httpRouteTimeout.PerRequest; perRequestTimeout != nil { + mPerRequestTimeout := map[string]interface{}{ + "unit": aws.StringValue(perRequestTimeout.Unit), + "value": int(aws.Int64Value(perRequestTimeout.Value)), + } + + mHttpRouteTimeout["per_request"] = []interface{}{mPerRequestTimeout} + } + + mHttpRoute["timeout"] = []interface{}{mHttpRouteTimeout} + } + return []interface{}{mHttpRoute} } diff --git a/website/docs/r/appmesh_route.html.markdown b/website/docs/r/appmesh_route.html.markdown index f778e8ff9d52..16cfbabe7fb8 100644 --- a/website/docs/r/appmesh_route.html.markdown +++ b/website/docs/r/appmesh_route.html.markdown @@ -160,12 +160,14 @@ The `grpc_route` object supports the following: * `action` - (Required) The action to take if a match is determined. * `match` - (Required) The criteria for determining an gRPC request match. * `rety_policy` - (Optional) The retry policy. +* `timeout` - (Optional) The route timeout. The `http2_route` and `http_route` objects supports the following: * `action` - (Required) The action to take if a match is determined. * `match` - (Required) The criteria for determining an HTTP request match. * `retry_policy` - (Optional) The retry policy. +* `timeout` - (Optional) The route timeout. The `tcp_route` object supports the following: @@ -207,6 +209,16 @@ Valid values: `client-error` (HTTP status code 409), `gateway-error` (HTTP statu * `per_retry_timeout` - (Required) The per-retry timeout. * `tcp_retry_events` - (Optional) List of TCP retry events. The only valid value is `connection-error`. +The `grpc_route`'s `timeout` object supports the following: + +* `idle` - (Optional) Bounds the amount of time a connection may be idle. The default value is none. +* `per_request` - (Optional) The amount of time that a requester will wait for an upstream target to complete a response. The default value is 15 seconds. + +The `idle` and `per_request` objects support the following: + +* `unit` - (Required) A time unit. Valid values: `s`, `ms`. +* `value` - (Required) The number of time units. Specifying `0` disables the timeout. + The `http2_route` and `http_route`'s `match` object supports the following: * `prefix` - (Required) Specifies the path with which to match requests. @@ -254,6 +266,16 @@ The `range` object supports the following: * `end` - (Required) The end of the range. * `start` - (Requited) The start of the range. +The `http2_route` and `http_route`'s `timeout` object supports the following: + +* `idle` - (Optional) Bounds the amount of time a connection may be idle. The default value is none. +* `per_request` - (Optional) The amount of time that a requester will wait for an upstream target to complete a response. The default value is 15 seconds. + +The `idle` and `per_request` objects support the following: + +* `unit` - (Required) A time unit. Valid values: `s`, `ms`. +* `value` - (Required) The number of time units. Specifying `0` disables the timeout. + The `tcp_route`'s `timeout` object supports the following: * `idle` - (Optional) Bounds the amount of time a connection may be idle. The default value is none. From 4d2137de7e434489f4fb788033176e85332fa978 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 7 Mar 2020 18:45:10 -0500 Subject: [PATCH 11/17] r/aws_appmesh_virtual_node: Add listener.tls attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery === RUN TestAccAWSAppmesh/VirtualNode/listenerHealthChecks === RUN TestAccAWSAppmesh/VirtualNode/logging === RUN TestAccAWSAppmesh/VirtualNode/basic --- PASS: TestAccAWSAppmesh (221.62s) --- PASS: TestAccAWSAppmesh/VirtualNode (221.62s) --- PASS: TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery (114.06s) --- PASS: TestAccAWSAppmesh/VirtualNode/listenerHealthChecks (40.76s) --- PASS: TestAccAWSAppmesh/VirtualNode/logging (41.45s) --- PASS: TestAccAWSAppmesh/VirtualNode/basic (25.35s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 221.667s --- aws/resource_aws_appmesh_virtual_node.go | 147 +++++++++ aws/resource_aws_appmesh_virtual_node_test.go | 2 + aws/structure.go | 290 ++++++++++++++---- .../docs/r/appmesh_virtual_node.html.markdown | 34 ++ 4 files changed, 407 insertions(+), 66 deletions(-) diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index fd400ab52462..ae91e56445cb 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -179,6 +179,114 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { }, }, }, + + "tls": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "acm": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validateArn, + }, + }, + }, + }, + + "file": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_chain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "private_key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + }, + }, + }, + + "sds": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secret_name": { + Type: schema.TypeString, + Required: true, + }, + + "source": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unix_domain_socket": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "path": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + + "mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + appmesh.ListenerTlsModeDisabled, + appmesh.ListenerTlsModePermissive, + appmesh.ListenerTlsModeStrict, + }, false), + }, + }, + }, + }, }, }, Set: appmeshVirtualNodeListenerHash, @@ -510,5 +618,44 @@ func appmeshVirtualNodeListenerHash(vListener interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v)) } } + if vTls, ok := mListener["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { + mTls := vTls[0].(map[string]interface{}) + if v, ok := mTls["mode"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if vCertificate, ok := mTls["certificate"].([]interface{}); ok && len(vCertificate) > 0 && vCertificate[0] != nil { + mCertificate := vCertificate[0].(map[string]interface{}) + if vAcm, ok := mCertificate["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { + mAcm := vAcm[0].(map[string]interface{}) + if v, ok := mAcm["certificate_arn"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + if vFile, ok := mCertificate["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + mFile := vFile[0].(map[string]interface{}) + if v, ok := mFile["certificate_chain"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if v, ok := mFile["private_key"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + mSds := vSds[0].(map[string]interface{}) + if v, ok := mSds["secret_name"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + mSource := vSource[0].(map[string]interface{}) + if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + if v, ok := mUnixDomainSocket["path"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + } + } + } + } return hashcode.String(buf.String()) } diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index 9d2e419d16df..8b09af585be6 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -207,6 +207,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.port_mapping.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.port_mapping.0.port", "8080"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.tls.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), @@ -241,6 +242,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.port_mapping.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.port_mapping.0.port", "8081"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.tls.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), diff --git a/aws/structure.go b/aws/structure.go index 259935072a75..1f0bf79bdb82 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5033,14 +5033,17 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec mBackend := vBackend.(map[string]interface{}) if vVirtualService, ok := mBackend["virtual_service"].([]interface{}); ok && len(vVirtualService) > 0 && vVirtualService[0] != nil { - mVirtualService := vVirtualService[0].(map[string]interface{}) + virtualService := &appmesh.VirtualServiceBackend{} - backend.VirtualService = &appmesh.VirtualServiceBackend{} + mVirtualService := vVirtualService[0].(map[string]interface{}) if vVirtualServiceName, ok := mVirtualService["virtual_service_name"].(string); ok { - backend.VirtualService.VirtualServiceName = aws.String(vVirtualServiceName) + virtualService.VirtualServiceName = aws.String(vVirtualServiceName) } + + backend.VirtualService = virtualService } + backends = append(backends, backend) } @@ -5056,44 +5059,127 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec mListener := vListener.(map[string]interface{}) if vHealthCheck, ok := mListener["health_check"].([]interface{}); ok && len(vHealthCheck) > 0 && vHealthCheck[0] != nil { - mHealthCheck := vHealthCheck[0].(map[string]interface{}) + healthCheck := &appmesh.HealthCheckPolicy{} - listener.HealthCheck = &appmesh.HealthCheckPolicy{} + mHealthCheck := vHealthCheck[0].(map[string]interface{}) if vHealthyThreshold, ok := mHealthCheck["healthy_threshold"].(int); ok && vHealthyThreshold > 0 { - listener.HealthCheck.HealthyThreshold = aws.Int64(int64(vHealthyThreshold)) + healthCheck.HealthyThreshold = aws.Int64(int64(vHealthyThreshold)) } if vIntervalMillis, ok := mHealthCheck["interval_millis"].(int); ok && vIntervalMillis > 0 { - listener.HealthCheck.IntervalMillis = aws.Int64(int64(vIntervalMillis)) + healthCheck.IntervalMillis = aws.Int64(int64(vIntervalMillis)) } if vPath, ok := mHealthCheck["path"].(string); ok && vPath != "" { - listener.HealthCheck.Path = aws.String(vPath) + healthCheck.Path = aws.String(vPath) } if vPort, ok := mHealthCheck["port"].(int); ok && vPort > 0 { - listener.HealthCheck.Port = aws.Int64(int64(vPort)) + healthCheck.Port = aws.Int64(int64(vPort)) } if vProtocol, ok := mHealthCheck["protocol"].(string); ok && vProtocol != "" { - listener.HealthCheck.Protocol = aws.String(vProtocol) + healthCheck.Protocol = aws.String(vProtocol) } if vTimeoutMillis, ok := mHealthCheck["timeout_millis"].(int); ok && vTimeoutMillis > 0 { - listener.HealthCheck.TimeoutMillis = aws.Int64(int64(vTimeoutMillis)) + healthCheck.TimeoutMillis = aws.Int64(int64(vTimeoutMillis)) } if vUnhealthyThreshold, ok := mHealthCheck["unhealthy_threshold"].(int); ok && vUnhealthyThreshold > 0 { - listener.HealthCheck.UnhealthyThreshold = aws.Int64(int64(vUnhealthyThreshold)) + healthCheck.UnhealthyThreshold = aws.Int64(int64(vUnhealthyThreshold)) } + + listener.HealthCheck = healthCheck } if vPortMapping, ok := mListener["port_mapping"].([]interface{}); ok && len(vPortMapping) > 0 && vPortMapping[0] != nil { - mPortMapping := vPortMapping[0].(map[string]interface{}) + portMapping := &appmesh.PortMapping{} - listener.PortMapping = &appmesh.PortMapping{} + mPortMapping := vPortMapping[0].(map[string]interface{}) if vPort, ok := mPortMapping["port"].(int); ok && vPort > 0 { - listener.PortMapping.Port = aws.Int64(int64(vPort)) + portMapping.Port = aws.Int64(int64(vPort)) } if vProtocol, ok := mPortMapping["protocol"].(string); ok && vProtocol != "" { - listener.PortMapping.Protocol = aws.String(vProtocol) + portMapping.Protocol = aws.String(vProtocol) + } + + listener.PortMapping = portMapping + } + + if vTls, ok := mListener["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { + tls := &appmesh.ListenerTls{} + + mTls := vTls[0].(map[string]interface{}) + + if vMode, ok := mTls["mode"].(string); ok && vMode != "" { + tls.Mode = aws.String(vMode) + } + + if vCertificate, ok := mTls["certificate"].([]interface{}); ok && len(vCertificate) > 0 && vCertificate[0] != nil { + certificate := &appmesh.ListenerTlsCertificate{} + + mCertificate := vCertificate[0].(map[string]interface{}) + + if vAcm, ok := mCertificate["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { + acm := &appmesh.ListenerTlsAcmCertificate{} + + mAcm := vAcm[0].(map[string]interface{}) + + if vCertificateArn, ok := mAcm["certificate_arn"].(string); ok && vCertificateArn != "" { + acm.CertificateArn = aws.String(vCertificateArn) + } + + certificate.Acm = acm + } + + if vFile, ok := mCertificate["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + file := &appmesh.ListenerTlsFileCertificate{} + + mFile := vFile[0].(map[string]interface{}) + + if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { + file.CertificateChain = aws.String(vCertificateChain) + } + if vPrivateKey, ok := mFile["private_key"].(string); ok && vPrivateKey != "" { + file.PrivateKey = aws.String(vPrivateKey) + } + + certificate.File = file + } + + if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + sds := &appmesh.ListenerTlsSdsCertificate{} + + mSds := vSds[0].(map[string]interface{}) + + if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { + sds.SecretName = aws.String(vSecretName) + } + + if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + source := &appmesh.SdsSource{} + + mSource := vSource[0].(map[string]interface{}) + + if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} + + mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + + if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { + unixDomainSocket.Path = aws.String(vPath) + } + + source.UnixDomainSocket = unixDomainSocket + } + + sds.Source = source + } + + certificate.Sds = sds + } + + tls.Certificate = certificate } + + listener.Tls = tls } listeners = append(listeners, listener) @@ -5103,34 +5189,40 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec } if vLogging, ok := mSpec["logging"].([]interface{}); ok && len(vLogging) > 0 && vLogging[0] != nil { + logging := &appmesh.Logging{} + mLogging := vLogging[0].(map[string]interface{}) if vAccessLog, ok := mLogging["access_log"].([]interface{}); ok && len(vAccessLog) > 0 && vAccessLog[0] != nil { + accessLog := &appmesh.AccessLog{} + mAccessLog := vAccessLog[0].(map[string]interface{}) if vFile, ok := mAccessLog["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + file := &appmesh.FileAccessLog{} + mFile := vFile[0].(map[string]interface{}) if vPath, ok := mFile["path"].(string); ok && vPath != "" { - spec.Logging = &appmesh.Logging{ - AccessLog: &appmesh.AccessLog{ - File: &appmesh.FileAccessLog{ - Path: aws.String(vPath), - }, - }, - } + file.Path = aws.String(vPath) } + + accessLog.File = file } + + logging.AccessLog = accessLog } + + spec.Logging = logging } if vServiceDiscovery, ok := mSpec["service_discovery"].([]interface{}); ok && len(vServiceDiscovery) > 0 && vServiceDiscovery[0] != nil { - spec.ServiceDiscovery = &appmesh.ServiceDiscovery{} + serviceDiscovery := &appmesh.ServiceDiscovery{} mServiceDiscovery := vServiceDiscovery[0].(map[string]interface{}) if vAwsCloudMap, ok := mServiceDiscovery["aws_cloud_map"].([]interface{}); ok && len(vAwsCloudMap) > 0 && vAwsCloudMap[0] != nil { - spec.ServiceDiscovery.AwsCloudMap = &appmesh.AwsCloudMapServiceDiscovery{} + awsCloudMap := &appmesh.AwsCloudMapServiceDiscovery{} mAwsCloudMap := vAwsCloudMap[0].(map[string]interface{}) @@ -5144,25 +5236,31 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec }) } - spec.ServiceDiscovery.AwsCloudMap.Attributes = attributes + awsCloudMap.Attributes = attributes } if vNamespaceName, ok := mAwsCloudMap["namespace_name"].(string); ok && vNamespaceName != "" { - spec.ServiceDiscovery.AwsCloudMap.NamespaceName = aws.String(vNamespaceName) + awsCloudMap.NamespaceName = aws.String(vNamespaceName) } if vServiceName, ok := mAwsCloudMap["service_name"].(string); ok && vServiceName != "" { - spec.ServiceDiscovery.AwsCloudMap.ServiceName = aws.String(vServiceName) + awsCloudMap.ServiceName = aws.String(vServiceName) } + + serviceDiscovery.AwsCloudMap = awsCloudMap } if vDns, ok := mServiceDiscovery["dns"].([]interface{}); ok && len(vDns) > 0 && vDns[0] != nil { + dns := &appmesh.DnsServiceDiscovery{} + mDns := vDns[0].(map[string]interface{}) if vHostname, ok := mDns["hostname"].(string); ok && vHostname != "" { - spec.ServiceDiscovery.Dns = &appmesh.DnsServiceDiscovery{ - Hostname: aws.String(vHostname), - } + dns.Hostname = aws.String(vHostname) } + + serviceDiscovery.Dns = dns } + + spec.ServiceDiscovery = serviceDiscovery } return spec @@ -5175,16 +5273,17 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} mSpec := map[string]interface{}{} - if spec.Backends != nil { + if backends := spec.Backends; backends != nil { vBackends := []interface{}{} - for _, backend := range spec.Backends { + for _, backend := range backends { mBackend := map[string]interface{}{} - if backend.VirtualService != nil { + if virtualService := backend.VirtualService; virtualService != nil { mVirtualService := map[string]interface{}{ - "virtual_service_name": aws.StringValue(backend.VirtualService.VirtualServiceName), + "virtual_service_name": aws.StringValue(virtualService.VirtualServiceName), } + mBackend["virtual_service"] = []interface{}{mVirtualService} } @@ -5194,78 +5293,137 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} mSpec["backend"] = schema.NewSet(appmeshVirtualNodeBackendHash, vBackends) } - if spec.Listeners != nil { + if listeners := spec.Listeners; listeners != nil { vListeners := []interface{}{} - for _, listener := range spec.Listeners { + for _, listener := range listeners { mListener := map[string]interface{}{} - if listener.HealthCheck != nil { + if healthCheck := listener.HealthCheck; healthCheck != nil { mHealthCheck := map[string]interface{}{ - "healthy_threshold": int(aws.Int64Value(listener.HealthCheck.HealthyThreshold)), - "interval_millis": int(aws.Int64Value(listener.HealthCheck.IntervalMillis)), - "path": aws.StringValue(listener.HealthCheck.Path), - "port": int(aws.Int64Value(listener.HealthCheck.Port)), - "protocol": aws.StringValue(listener.HealthCheck.Protocol), - "timeout_millis": int(aws.Int64Value(listener.HealthCheck.TimeoutMillis)), - "unhealthy_threshold": int(aws.Int64Value(listener.HealthCheck.UnhealthyThreshold)), + "healthy_threshold": int(aws.Int64Value(healthCheck.HealthyThreshold)), + "interval_millis": int(aws.Int64Value(healthCheck.IntervalMillis)), + "path": aws.StringValue(healthCheck.Path), + "port": int(aws.Int64Value(healthCheck.Port)), + "protocol": aws.StringValue(healthCheck.Protocol), + "timeout_millis": int(aws.Int64Value(healthCheck.TimeoutMillis)), + "unhealthy_threshold": int(aws.Int64Value(healthCheck.UnhealthyThreshold)), } + mListener["health_check"] = []interface{}{mHealthCheck} } - if listener.PortMapping != nil { + if portMapping := listener.PortMapping; portMapping != nil { mPortMapping := map[string]interface{}{ - "port": int(aws.Int64Value(listener.PortMapping.Port)), - "protocol": aws.StringValue(listener.PortMapping.Protocol), + "port": int(aws.Int64Value(portMapping.Port)), + "protocol": aws.StringValue(portMapping.Protocol), } + mListener["port_mapping"] = []interface{}{mPortMapping} } + if tls := listener.Tls; tls != nil { + mTls := map[string]interface{}{ + "mode": aws.StringValue(tls.Mode), + } + + if certificate := tls.Certificate; certificate != nil { + mCertificate := map[string]interface{}{} + + if acm := certificate.Acm; acm != nil { + mAcm := map[string]interface{}{ + "certificate_arn": aws.StringValue(acm.CertificateArn), + } + + mCertificate["acm"] = []interface{}{mAcm} + } + + if file := certificate.File; file != nil { + mFile := map[string]interface{}{ + "certificate_chain": aws.StringValue(file.CertificateChain), + "private_key": aws.StringValue(file.PrivateKey), + } + + mCertificate["file"] = []interface{}{mFile} + } + + if sds := certificate.Sds; sds != nil { + mSds := map[string]interface{}{ + "secret_name": aws.StringValue(sds.SecretName), + } + + if source := sds.Source; source != nil { + mSource := map[string]interface{}{} + + if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { + mUnixDomainSocket := map[string]interface{}{ + "path": aws.StringValue(unixDomainSocket.Path), + } + + mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} + } + + mSds["source"] = []interface{}{mSource} + } + + mCertificate["sds"] = []interface{}{mSds} + } + + mTls["certificate"] = []interface{}{mCertificate} + } + + mListener["tls"] = []interface{}{mTls} + } + vListeners = append(vListeners, mListener) } mSpec["listener"] = schema.NewSet(appmeshVirtualNodeListenerHash, vListeners) } - if spec.Logging != nil && spec.Logging.AccessLog != nil && spec.Logging.AccessLog.File != nil { - mSpec["logging"] = []interface{}{ - map[string]interface{}{ - "access_log": []interface{}{ + if logging := spec.Logging; logging != nil { + mLogging := map[string]interface{}{} + + if accessLog := logging.AccessLog; accessLog != nil { + mAccessLog := map[string]interface{}{} + + if file := accessLog.File; file != nil { + mAccessLog["file"] = []interface{}{ map[string]interface{}{ - "file": []interface{}{ - map[string]interface{}{ - "path": aws.StringValue(spec.Logging.AccessLog.File.Path), - }, - }, + "path": aws.StringValue(file.Path), }, - }, - }, + } + } + + mLogging["access_log"] = []interface{}{mAccessLog} } + + mSpec["logging"] = []interface{}{mLogging} } - if spec.ServiceDiscovery != nil { + if serviceDiscovery := spec.ServiceDiscovery; serviceDiscovery != nil { mServiceDiscovery := map[string]interface{}{} - if spec.ServiceDiscovery.AwsCloudMap != nil { + if awsCloudMap := serviceDiscovery.AwsCloudMap; awsCloudMap != nil { vAttributes := map[string]interface{}{} - for _, attribute := range spec.ServiceDiscovery.AwsCloudMap.Attributes { + for _, attribute := range awsCloudMap.Attributes { vAttributes[aws.StringValue(attribute.Key)] = aws.StringValue(attribute.Value) } mServiceDiscovery["aws_cloud_map"] = []interface{}{ map[string]interface{}{ "attributes": vAttributes, - "namespace_name": aws.StringValue(spec.ServiceDiscovery.AwsCloudMap.NamespaceName), - "service_name": aws.StringValue(spec.ServiceDiscovery.AwsCloudMap.ServiceName), + "namespace_name": aws.StringValue(awsCloudMap.NamespaceName), + "service_name": aws.StringValue(awsCloudMap.ServiceName), }, } } - if spec.ServiceDiscovery.Dns != nil { + if dns := serviceDiscovery.Dns; dns != nil { mServiceDiscovery["dns"] = []interface{}{ map[string]interface{}{ - "hostname": aws.StringValue(spec.ServiceDiscovery.Dns.Hostname), + "hostname": aws.StringValue(dns.Hostname), }, } } diff --git a/website/docs/r/appmesh_virtual_node.html.markdown b/website/docs/r/appmesh_virtual_node.html.markdown index b9d1cf61fb9b..d6a2d2ac4eec 100644 --- a/website/docs/r/appmesh_virtual_node.html.markdown +++ b/website/docs/r/appmesh_virtual_node.html.markdown @@ -198,6 +198,7 @@ The `listener` object supports the following: * `port_mapping` - (Required) The port mapping information for the listener. * `health_check` - (Optional) The health check information for the listener. +* `tls` - (Optional) The Transport Layer Security (TLS) properties for the listener The `logging` object supports the following: @@ -242,6 +243,39 @@ The `health_check` object supports the following: * `path` - (Optional) The destination path for the health check request. This is only required if the specified protocol is `http`. * `port` - (Optional) The destination port for the health check request. This port must match the port defined in the `port_mapping` for the listener. +The `tls` object supports the following: + +* `certificate` - (Required) The listener's TLS certificate. +* `mode`- (Required) The listener's TLS mode. Valid values: `DISABLED`, `PERMISSIVE`, `STRICT`. + +The `certificate` object supports the following: + +* `acm` - (Optional) An AWS Certicate Manager (ACM) certificate. +* `file` - (optional) A local file certificate. +* `sds` - (Optional) A [secret discovery service](https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret) (SDS) secret. + +The `acm` object supports the following: + +* `certificate_arn` - (Required) The Amazon Resource Name (ARN) for the certificate. + +The `file` object supports the following: + +* `certificate_chain` - (Required) The certificate chain for the certificate. +* `private_key` - (Required) The private key for a certificate stored on the file system of the virtual node that the proxy is running on. + +The `sds` object supports the following: + +* `secret_name` - (Required) The secret name. +* `source` - (Required) The secret source. + +The `source` object supports the following: + +* `unix_domain_socket` - (Required) The Unix domain socket source location. + +The `unix_domain_socket` object supports the following: + +* `path` - (Required) file system path for the socket. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: From 88b29388d26360bfc6dab311a427600eeb41277e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 8 Mar 2020 18:11:20 -0400 Subject: [PATCH 12/17] r/aws_appmesh_virtual_node: Test listener.tls attribute. Disable SDS support (ForbiddenException: TLS Certificates from SDS are not supported). Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode/tls' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode/tls -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/tls --- PASS: TestAccAWSAppmesh (56.32s) --- PASS: TestAccAWSAppmesh/VirtualNode (56.32s) --- PASS: TestAccAWSAppmesh/VirtualNode/tls (56.32s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 56.365s --- aws/resource_aws_appmesh_test.go | 1 + aws/resource_aws_appmesh_virtual_node.go | 110 +++---- aws/resource_aws_appmesh_virtual_node_test.go | 268 ++++++++++++++++++ aws/structure.go | 76 ++--- .../docs/r/appmesh_virtual_node.html.markdown | 14 - 5 files changed, 364 insertions(+), 105 deletions(-) diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index b9e0e9bfcf7a..e0b49152822d 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -26,6 +26,7 @@ func TestAccAWSAppmesh(t *testing.T) { "cloudMapServiceDiscovery": testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery, "listenerHealthChecks": testAccAwsAppmeshVirtualNode_listenerHealthChecks, "logging": testAccAwsAppmeshVirtualNode_logging, + "tls": testAccAwsAppmeshVirtualNode_tls, // "tags": testAccAwsAppmeshVirtualNode_tags, }, "VirtualRouter": { diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index ae91e56445cb..52a23ae759f4 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -232,45 +232,46 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { }, }, - "sds": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "secret_name": { - Type: schema.TypeString, - Required: true, - }, - - "source": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "unix_domain_socket": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "path": { - Type: schema.TypeString, - Required: true, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, + // ForbiddenException: TLS Certificates from SDS are not supported. + // "sds": { + // Type: schema.TypeList, + // Optional: true, + // MinItems: 0, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "secret_name": { + // Type: schema.TypeString, + // Required: true, + // }, + + // "source": { + // Type: schema.TypeList, + // Required: true, + // MinItems: 1, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "unix_domain_socket": { + // Type: schema.TypeList, + // Required: true, + // MinItems: 1, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "path": { + // Type: schema.TypeString, + // Required: true, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, }, }, }, @@ -640,21 +641,22 @@ func appmeshVirtualNodeListenerHash(vListener interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v)) } } - if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { - mSds := vSds[0].(map[string]interface{}) - if v, ok := mSds["secret_name"].(string); ok { - buf.WriteString(fmt.Sprintf("%s-", v)) - } - if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { - mSource := vSource[0].(map[string]interface{}) - if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { - mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) - if v, ok := mUnixDomainSocket["path"].(string); ok { - buf.WriteString(fmt.Sprintf("%s-", v)) - } - } - } - } + // ForbiddenException: TLS Certificates from SDS are not supported. + // if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + // mSds := vSds[0].(map[string]interface{}) + // if v, ok := mSds["secret_name"].(string); ok { + // buf.WriteString(fmt.Sprintf("%s-", v)) + // } + // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + // mSource := vSource[0].(map[string]interface{}) + // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + // if v, ok := mUnixDomainSocket["path"].(string); ok { + // buf.WriteString(fmt.Sprintf("%s-", v)) + // } + // } + // } + // } } } return hashcode.String(buf.String()) diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index 8b09af585be6..ce59ffae15e0 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -357,6 +357,122 @@ func testAccAwsAppmeshVirtualNode_tags(t *testing.T) { }) } +func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { + var vn appmesh.VirtualNodeData + resourceName := "aws_appmesh_virtual_node.test" + acmCertificateResourceName := "aws_acm_certificate.cert" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vnName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshVirtualNodeDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAppmeshVirtualNodeConfig_tlsFile(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.health_check.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.port_mapping.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.port_mapping.0.port", "8080"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.0.acm.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.0.file.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.0.file.0.certificate_chain", "/cert_chain.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.0.file.0.private_key", "/key.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.certificate.0.sds.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.tls.0.mode", "PERMISSIVE"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + // ForbiddenException: TLS Certificates from SDS are not supported. + // { + // Config: testAccAppmeshVirtualNodeConfig_tlsSds(meshName, vnName), + // Check: resource.ComposeTestCheckFunc( + // testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + // resource.TestCheckResourceAttr(resourceName, "name", vnName), + // resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + // testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + // resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.health_check.#", "0"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.port_mapping.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.port_mapping.0.port", "8080"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.port_mapping.0.protocol", "http"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.acm.#", "0"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.file.#", "0"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.sds.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.sds.0.secret_name", "secret"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.sds.0.source.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.sds.0.source.0.unix_domain_socket.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.certificate.0.sds.0.source.0.unix_domain_socket.0.path", "/sds-server.sock"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.tls.0.mode", "DISABLED"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + // resource.TestCheckResourceAttrSet(resourceName, "created_date"), + // resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + // testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + // testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + // ), + // }, + { + Config: testAccAppmeshVirtualNodeConfig_tlsAcm(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(acmCertificateResourceName, "arn", &vn), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + { + ResourceName: resourceName, + ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAppmeshVirtualNodeDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appmeshconn @@ -407,6 +523,31 @@ func testAccCheckAppmeshVirtualNodeExists(name string, v *appmesh.VirtualNodeDat } } +// testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(acmCertificateResourceName, "arn", &vn), +func testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(name, key string, v *appmesh.VirtualNodeData) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + expected, ok := rs.Primary.Attributes[key] + if !ok { + return fmt.Errorf("Key not found: %s", key) + } + if v.Spec == nil || v.Spec.Listeners == nil || len(v.Spec.Listeners) != 1 || v.Spec.Listeners[0].Tls == nil || + v.Spec.Listeners[0].Tls.Certificate == nil || v.Spec.Listeners[0].Tls.Certificate.Acm == nil { + return fmt.Errorf("Not found: v.Spec.Listeners[0].Tls.Certificate.Acm") + } + got := aws.StringValue(v.Spec.Listeners[0].Tls.Certificate.Acm.CertificateArn) + if got != expected { + return fmt.Errorf("Expected ACM certificate ARN %q, got %q", expected, got) + } + + return nil + } +} + func testAccAppmeshVirtualNodeConfig_mesh(rName string) string { return fmt.Sprintf(` resource "aws_appmesh_mesh" "test" { @@ -602,3 +743,130 @@ resource "aws_appmesh_virtual_node" "test" { } `, vnName, tagKey1, tagValue1, tagKey2, tagValue2) } + +func testAccAppmeshVirtualNodeConfig_tlsFile(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + + tls { + certificate { + file { + certificate_chain = "/cert_chain.pem" + private_key = "/key.pem" + } + } + + mode = "PERMISSIVE" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} + +func testAccAppmeshVirtualNodeConfig_tlsSds(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + + tls { + certificate { + sds { + secret_name = "secret" + + source { + unix_domain_socket { + path = "/sds-server.sock" + } + } + } + } + + mode = "DISABLED" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} + +func testAccAppmeshVirtualNodeConfig_tlsAcm(meshName, vnName string) string { + return testAccAcmCertificateConfig_privateCert(meshName) + testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + + tls { + certificate { + acm { + certificate_arn = "${aws_acm_certificate.cert.arn}" + } + } + + mode = "STRICT" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} diff --git a/aws/structure.go b/aws/structure.go index 1f0bf79bdb82..b89c264b3a18 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5144,37 +5144,38 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec certificate.File = file } - if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { - sds := &appmesh.ListenerTlsSdsCertificate{} + // ForbiddenException: TLS Certificates from SDS are not supported. + // if vSds, ok := mCertificate["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + // sds := &appmesh.ListenerTlsSdsCertificate{} - mSds := vSds[0].(map[string]interface{}) + // mSds := vSds[0].(map[string]interface{}) - if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { - sds.SecretName = aws.String(vSecretName) - } + // if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { + // sds.SecretName = aws.String(vSecretName) + // } - if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { - source := &appmesh.SdsSource{} + // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + // source := &appmesh.SdsSource{} - mSource := vSource[0].(map[string]interface{}) + // mSource := vSource[0].(map[string]interface{}) - if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { - unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} + // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + // unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} - mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) - if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { - unixDomainSocket.Path = aws.String(vPath) - } + // if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { + // unixDomainSocket.Path = aws.String(vPath) + // } - source.UnixDomainSocket = unixDomainSocket - } + // source.UnixDomainSocket = unixDomainSocket + // } - sds.Source = source - } + // sds.Source = source + // } - certificate.Sds = sds - } + // certificate.Sds = sds + // } tls.Certificate = certificate } @@ -5347,27 +5348,28 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} mCertificate["file"] = []interface{}{mFile} } - if sds := certificate.Sds; sds != nil { - mSds := map[string]interface{}{ - "secret_name": aws.StringValue(sds.SecretName), - } + // ForbiddenException: TLS Certificates from SDS are not supported. + // if sds := certificate.Sds; sds != nil { + // mSds := map[string]interface{}{ + // "secret_name": aws.StringValue(sds.SecretName), + // } - if source := sds.Source; source != nil { - mSource := map[string]interface{}{} + // if source := sds.Source; source != nil { + // mSource := map[string]interface{}{} - if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { - mUnixDomainSocket := map[string]interface{}{ - "path": aws.StringValue(unixDomainSocket.Path), - } + // if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { + // mUnixDomainSocket := map[string]interface{}{ + // "path": aws.StringValue(unixDomainSocket.Path), + // } - mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} - } + // mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} + // } - mSds["source"] = []interface{}{mSource} - } + // mSds["source"] = []interface{}{mSource} + // } - mCertificate["sds"] = []interface{}{mSds} - } + // mCertificate["sds"] = []interface{}{mSds} + // } mTls["certificate"] = []interface{}{mCertificate} } diff --git a/website/docs/r/appmesh_virtual_node.html.markdown b/website/docs/r/appmesh_virtual_node.html.markdown index d6a2d2ac4eec..83e6ca7d3294 100644 --- a/website/docs/r/appmesh_virtual_node.html.markdown +++ b/website/docs/r/appmesh_virtual_node.html.markdown @@ -252,7 +252,6 @@ The `certificate` object supports the following: * `acm` - (Optional) An AWS Certicate Manager (ACM) certificate. * `file` - (optional) A local file certificate. -* `sds` - (Optional) A [secret discovery service](https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret) (SDS) secret. The `acm` object supports the following: @@ -263,19 +262,6 @@ The `file` object supports the following: * `certificate_chain` - (Required) The certificate chain for the certificate. * `private_key` - (Required) The private key for a certificate stored on the file system of the virtual node that the proxy is running on. -The `sds` object supports the following: - -* `secret_name` - (Required) The secret name. -* `source` - (Required) The secret source. - -The `source` object supports the following: - -* `unix_domain_socket` - (Required) The Unix domain socket source location. - -The `unix_domain_socket` object supports the following: - -* `path` - (Required) file system path for the socket. - ## Attributes Reference In addition to all arguments above, the following attributes are exported: From 7e01dac589a82f1cd2d4e40d71b794dd9b8e348f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sun, 22 Mar 2020 21:37:50 -0400 Subject: [PATCH 13/17] r/aws_appmesh_virtual_node: Add backend.virtual_service.client_policy attribute. TODO: Enabled acceptance tests. Acceptance testing output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/tls === RUN TestAccAWSAppmesh/VirtualNode/basic === RUN TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery === RUN TestAccAWSAppmesh/VirtualNode/listenerHealthChecks === RUN TestAccAWSAppmesh/VirtualNode/logging --- PASS: TestAccAWSAppmesh (283.47s) --- PASS: TestAccAWSAppmesh/VirtualNode (283.47s) --- PASS: TestAccAWSAppmesh/VirtualNode/tls (56.13s) --- PASS: TestAccAWSAppmesh/VirtualNode/basic (26.08s) --- PASS: TestAccAWSAppmesh/VirtualNode/cloudMapServiceDiscovery (115.83s) --- PASS: TestAccAWSAppmesh/VirtualNode/listenerHealthChecks (43.04s) --- PASS: TestAccAWSAppmesh/VirtualNode/logging (42.39s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 283.517s --- aws/resource_aws_appmesh_virtual_node.go | 176 ++++++++++++++ aws/resource_aws_appmesh_virtual_node_test.go | 230 +++++++++++++++++- aws/structure.go | 191 +++++++++++++++ .../docs/r/appmesh_virtual_node.html.markdown | 28 +++ 4 files changed, 624 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index 52a23ae759f4..31cf000852cb 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -85,6 +85,133 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, + + "client_policy": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tls": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enforce": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "ports": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeInt}, + Set: schema.HashInt, + }, + + "validation": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trust": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "acm": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_authority_arns": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + }, + }, + }, + + "file": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_chain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + }, + }, + }, + + "sds": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secret_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + + "source": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "unix_domain_socket": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "path": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, }, }, }, @@ -580,6 +707,55 @@ func appmeshVirtualNodeBackendHash(vBackend interface{}) int { if v, ok := mVirtualService["virtual_service_name"].(string); ok { buf.WriteString(fmt.Sprintf("%s-", v)) } + if vClientPolicy, ok := mVirtualService["client_policy"].([]interface{}); ok && len(vClientPolicy) > 0 && vClientPolicy[0] != nil { + mClientPolicy := vClientPolicy[0].(map[string]interface{}) + if vTls, ok := mClientPolicy["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { + mTls := vTls[0].(map[string]interface{}) + if v, ok := mTls["enforce"].(bool); ok { + buf.WriteString(fmt.Sprintf("%t-", v)) + } + if v, ok := mTls["ports"].(*schema.Set); ok && v.Len() > 0 { + for _, port := range v.List() { + buf.WriteString(fmt.Sprintf("%d-", port.(int))) + } + } + if vValidation, ok := mTls["validation"].([]interface{}); ok && len(vValidation) > 0 && vValidation[0] != nil { + mValidation := vValidation[0].(map[string]interface{}) + if vTrust, ok := mValidation["trust"].([]interface{}); ok && len(vTrust) > 0 && vTrust[0] != nil { + mTrust := vTrust[0].(map[string]interface{}) + if vAcm, ok := mTrust["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { + mAcm := vAcm[0].(map[string]interface{}) + if v, ok := mAcm["certificate_authority_arns"].(*schema.Set); ok && v.Len() > 0 { + for _, arn := range v.List() { + buf.WriteString(fmt.Sprintf("%s-", arn.(string))) + } + } + } + if vFile, ok := mTrust["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + mFile := vFile[0].(map[string]interface{}) + if v, ok := mFile["certificate_chain"].(string); ok { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + // if vSds, ok := mTrust["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + // mSds := vSds[0].(map[string]interface{}) + // if v, ok := mSds["secret_name"].(string); ok { + // buf.WriteString(fmt.Sprintf("%s-", v)) + // } + // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + // mSource := vSource[0].(map[string]interface{}) + // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + // if v, ok := mUnixDomainSocket["path"].(string); ok { + // buf.WriteString(fmt.Sprintf("%s-", v)) + // } + // } + // } + // } + } + } + } + } } return hashcode.String(buf.String()) } diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index ce59ffae15e0..8eac2d9be497 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -193,6 +193,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), @@ -227,8 +228,10 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2576932631.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2576932631.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2576932631.virtual_service.0.virtual_service_name", "servicec.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.0.virtual_service_name", "serviced.simpleapp.local"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), @@ -378,6 +381,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), @@ -413,6 +417,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { // testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), // resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), @@ -449,6 +454,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), @@ -473,6 +479,114 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { }) } +func testAccAwsAppmeshVirtualNode_clientPolicyFile(t *testing.T) { + var vn appmesh.VirtualNodeData + resourceName := "aws_appmesh_virtual_node.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vnName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshVirtualNodeDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAppmeshVirtualNodeConfig_clientPolicyFile(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.enforce", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.ports.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.ports.860082431", "8443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.acm.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/cert_chain.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.sds.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.port", "8080"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.tls.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + { + ResourceName: resourceName, + ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccAwsAppmeshVirtualNode_clientPolicyAcm(t *testing.T) { + var vn appmesh.VirtualNodeData + resourceName := "aws_appmesh_virtual_node.test" + acmCAResourceName := "aws_acmpca_certificate_authority.cert" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vnName := acctest.RandomWithPrefix("tf-acc-test") + + t.Skip("Requires an active ACM PCA") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshVirtualNodeDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + testAccCheckAppmeshVirtualNodeClientPolicyAcmCertificateAuthorityArn(acmCAResourceName, "arn", &vn), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.port", "8080"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.tls.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + { + ResourceName: resourceName, + ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAppmeshVirtualNodeDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appmeshconn @@ -523,7 +637,33 @@ func testAccCheckAppmeshVirtualNodeExists(name string, v *appmesh.VirtualNodeDat } } -// testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(acmCertificateResourceName, "arn", &vn), +func testAccCheckAppmeshVirtualNodeClientPolicyAcmCertificateAuthorityArn(name, key string, v *appmesh.VirtualNodeData) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + expected, ok := rs.Primary.Attributes[key] + if !ok { + return fmt.Errorf("Key not found: %s", key) + } + if v.Spec == nil || len(v.Spec.Backends) != 1 || v.Spec.Backends[0].VirtualService == nil || + v.Spec.Backends[0].VirtualService.ClientPolicy == nil || v.Spec.Backends[0].VirtualService.ClientPolicy.Tls == nil || + v.Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation == nil || v.Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation.Trust == nil || + v.Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation.Trust.Acm == nil || + len(v.Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation.Trust.Acm.CertificateAuthorityArns) != 1 { + return fmt.Errorf("Not found: .Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation.Trust.Acm.CertificateAuthorityArns[0]") + } + got := aws.StringValue(v.Spec.Backends[0].VirtualService.ClientPolicy.Tls.Validation.Trust.Acm.CertificateAuthorityArns[0]) + if got != expected { + return fmt.Errorf("Expected ACM CA ARN %q, got %q", expected, got) + } + + return nil + } +} + func testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(name, key string, v *appmesh.VirtualNodeData) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] @@ -870,3 +1010,91 @@ resource "aws_appmesh_virtual_node" "test" { } `, vnName) } + +func testAccAppmeshVirtualNodeConfig_clientPolicyFile(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + + client_policy { + tls { + ports = [8443] + + validation { + trust { + file { + certificate_chain = "/cert_chain.pem" + } + } + } + } + } + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} + +func testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName string) string { + return testAccAcmCertificateConfig_privateCert(meshName) + testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + + client_policy { + tls { + ports = [443, 8443] + + validation { + trust { + acm { + certificate_authority_arns = ["${aws_acm_certificate.cert.arn}"] + } + } + } + } + } + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} diff --git a/aws/structure.go b/aws/structure.go index b89c264b3a18..53b04576872c 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -984,6 +984,23 @@ func expandStringSet(configured *schema.Set) []*string { return expandStringList(configured.List()) } +// Takes the result of flatmap.Expand for an array of ints +// and returns a []*int64 +func expandIntList(configured []interface{}) []*int64 { + vs := make([]*int64, 0, len(configured)) + for _, v := range configured { + if val, ok := v.(int); ok { + vs = append(vs, aws.Int64(int64(val))) + } + } + return vs +} + +// Takes the result of schema.Set of ints and returns a []*int64 +func expandIntSet(configured *schema.Set) []*int64 { + return expandIntList(configured.List()) +} + // Takes list of pointers to strings. Expand to an array // of raw strings and returns a []interface{} // to keep compatibility w/ schema.NewSetschema.NewSet @@ -999,6 +1016,21 @@ func flattenStringSet(list []*string) *schema.Set { return schema.NewSet(schema.HashString, flattenStringList(list)) } +// Takes list of pointers to int64s. Expand to an array +// of raw ints and returns a []interface{} +// to keep compatibility w/ schema.NewSetschema.NewSet +func flattenIntList(list []*int64) []interface{} { + vs := make([]interface{}, 0, len(list)) + for _, v := range list { + vs = append(vs, int(aws.Int64Value(v))) + } + return vs +} + +func flattenIntSet(list []*int64) *schema.Set { + return schema.NewSet(schema.HashInt, flattenIntList(list)) +} + //Flattens an array of private ip addresses into a []string, where the elements returned are the IP strings e.g. "192.168.0.0" func flattenNetworkInterfacesPrivateIPAddresses(dtos []*ec2.NetworkInterfacePrivateIpAddress) []string { ips := make([]string, 0, len(dtos)) @@ -5041,6 +5073,100 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec virtualService.VirtualServiceName = aws.String(vVirtualServiceName) } + if vClientPolicy, ok := mVirtualService["client_policy"].([]interface{}); ok && len(vClientPolicy) > 0 && vClientPolicy[0] != nil { + clientPolicy := &appmesh.ClientPolicy{} + + mClientPolicy := vClientPolicy[0].(map[string]interface{}) + + if vTls, ok := mClientPolicy["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { + tls := &appmesh.ClientPolicyTls{} + + mTls := vTls[0].(map[string]interface{}) + + if vEnforce, ok := mTls["enforce"].(bool); ok { + tls.Enforce = aws.Bool(vEnforce) + } + + if vPorts, ok := mTls["ports"].(*schema.Set); ok && vPorts.Len() > 0 { + tls.Ports = expandIntSet(vPorts) + } + + if vValidation, ok := mTls["validation"].([]interface{}); ok && len(vValidation) > 0 && vValidation[0] != nil { + validation := &appmesh.TlsValidationContext{} + + mValidation := vValidation[0].(map[string]interface{}) + + if vTrust, ok := mValidation["trust"].([]interface{}); ok && len(vTrust) > 0 && vTrust[0] != nil { + trust := &appmesh.TlsValidationContextTrust{} + + mTrust := vTrust[0].(map[string]interface{}) + + if vAcm, ok := mTrust["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { + acm := &appmesh.TlsValidationContextAcmTrust{} + + mAcm := vAcm[0].(map[string]interface{}) + + if vCertificateAuthorityArns, ok := mAcm["certificate_authority_arns"].(*schema.Set); ok && vCertificateAuthorityArns.Len() > 0 { + acm.CertificateAuthorityArns = expandStringSet(vCertificateAuthorityArns) + } + + trust.Acm = acm + } + + if vFile, ok := mTrust["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + file := &appmesh.TlsValidationContextFileTrust{} + + mFile := vFile[0].(map[string]interface{}) + + if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { + file.CertificateChain = aws.String(vCertificateChain) + } + + trust.File = file + } + + // if vSds, ok := mTrust["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + // sds := &appmesh.TlsValidationContextSdsTrust{} + + // mSds := vSds[0].(map[string]interface{}) + + // if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { + // sds.SecretName = aws.String(vSecretName) + // } + + // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + // source := &appmesh.SdsSource{} + + // mSource := vSource[0].(map[string]interface{}) + + // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + // unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} + + // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + + // if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { + // unixDomainSocket.Path = aws.String(vPath) + // } + + // source.UnixDomainSocket = unixDomainSocket + // } + // } + + // trust.Sds = sds + // } + + validation.Trust = trust + } + + tls.Validation = validation + } + + clientPolicy.Tls = tls + } + + virtualService.ClientPolicy = clientPolicy + } + backend.VirtualService = virtualService } @@ -5285,6 +5411,71 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} "virtual_service_name": aws.StringValue(virtualService.VirtualServiceName), } + if clientPolicy := virtualService.ClientPolicy; clientPolicy != nil { + mClientPolicy := map[string]interface{}{} + + if tls := clientPolicy.Tls; tls != nil { + mTls := map[string]interface{}{ + "enforce": aws.BoolValue(tls.Enforce), + "ports": flattenIntSet(tls.Ports), + } + + if validation := tls.Validation; validation != nil { + mValidation := map[string]interface{}{} + + if trust := validation.Trust; trust != nil { + mTrust := map[string]interface{}{} + + if acm := trust.Acm; acm != nil { + mAcm := map[string]interface{}{ + "certificate_authority_arns": flattenStringSet(acm.CertificateAuthorityArns), + } + + mTrust["acm"] = []interface{}{mAcm} + } + + if file := trust.File; file != nil { + mFile := map[string]interface{}{ + "certificate_chain": aws.StringValue(file.CertificateChain), + } + + mTrust["file"] = []interface{}{mFile} + } + + // if sds := trust.Sds; sds != nil { + // mSds := map[string]interface{}{ + // "secret_name": aws.StringValue(sds.SecretName), + // } + + // if source := sds.Source; source != nil { + // mSource := map[string]interface{}{} + + // if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { + // mUnixDomainSocket := map[string]interface{}{ + // "path": aws.StringValue(unixDomainSocket.Path), + // } + + // mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} + // } + + // mSds["source"] = []interface{}{mSource} + // } + + // mTrust["sds"] = []interface{}{mSds} + // } + + mValidation["trust"] = []interface{}{mTrust} + } + + mTls["validation"] = []interface{}{mValidation} + } + + mClientPolicy["tls"] = []interface{}{mTls} + } + + mVirtualService["client_policy"] = []interface{}{mClientPolicy} + } + mBackend["virtual_service"] = []interface{}{mVirtualService} } diff --git a/website/docs/r/appmesh_virtual_node.html.markdown b/website/docs/r/appmesh_virtual_node.html.markdown index 83e6ca7d3294..20bb637953a3 100644 --- a/website/docs/r/appmesh_virtual_node.html.markdown +++ b/website/docs/r/appmesh_virtual_node.html.markdown @@ -192,8 +192,36 @@ The `backend` object supports the following: The `virtual_service` object supports the following: +* `client_policy` - (Optional) The client policy for the backend. * `virtual_service_name` - (Required) The name of the virtual service that is acting as a virtual node backend. +The `client_policy` object supports the following: + +* `tls` - (Optional) The Transport Layer Security (TLS) client policy. + +The `tls` object supports the following: + +* `enforced` - (Optional) Whether the policy is enforced. Default is `true`. +* `ports` - (Optional) One or more ports that the policy is enforced for. +* `validation` - (Required) The TLS validation context. + +The `validation` object supports the following: + +* `trust` - (Required) The TLS validation context trust. + +The `trust` object supports the following: + +* `acm` - (Optional) The TLS validation context trust for an AWS Certicate Manager (ACM) certificate. +* `file` - (Optional) The TLS validation context trust for a local file. + +The `acm` object supports the following: + +* `certificate_authority_arns` - (Required) One or more ACM Amazon Resource Name (ARN)s. + +The `file` object supports the following: + +* `certificate_chain` - (Required) The certificate trust chain for a certificate stored on the file system of the virtual node that the proxy is running on. + The `listener` object supports the following: * `port_mapping` - (Required) The port mapping information for the listener. From 67239939cd164fc181b535ab8c2be2a3c7c61701 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Mar 2020 15:38:38 -0400 Subject: [PATCH 14/17] r/aws_appmesh_virtual_node: Test backend.virtual_service.client_policy...file attribute. Acceptance testing output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode/clientPolicyFile' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode/clientPolicyFile -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/clientPolicyFile --- PASS: TestAccAWSAppmesh (41.99s) --- PASS: TestAccAWSAppmesh/VirtualNode (41.99s) --- PASS: TestAccAWSAppmesh/VirtualNode/clientPolicyFile (41.99s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 42.027s --- aws/resource_aws_appmesh_test.go | 2 + aws/resource_aws_appmesh_virtual_node_test.go | 82 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index e0b49152822d..a33f28a9d253 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -23,6 +23,8 @@ func TestAccAWSAppmesh(t *testing.T) { }, "VirtualNode": { "basic": testAccAwsAppmeshVirtualNode_basic, + "clientPolicyAcm": testAccAwsAppmeshVirtualNode_clientPolicyAcm, + "clientPolicyFile": testAccAwsAppmeshVirtualNode_clientPolicyFile, "cloudMapServiceDiscovery": testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery, "listenerHealthChecks": testAccAwsAppmeshVirtualNode_listenerHealthChecks, "logging": testAccAwsAppmeshVirtualNode_logging, diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index 8eac2d9be497..8e12bceda8a2 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -527,6 +527,44 @@ func testAccAwsAppmeshVirtualNode_clientPolicyFile(t *testing.T) { testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, + { + Config: testAccAppmeshVirtualNodeConfig_clientPolicyFileUpdated(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.enforce", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.ports.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.ports.3638101695", "443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.ports.860082431", "8443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.acm.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/etc/ssl/certs/cert_chain.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.sds.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.port", "8080"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.0.protocol", "http"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.tls.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.0.dns.0.hostname", "serviceb.simpleapp.local"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, { ResourceName: resourceName, ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), @@ -1055,6 +1093,50 @@ resource "aws_appmesh_virtual_node" "test" { `, vnName) } +func testAccAppmeshVirtualNodeConfig_clientPolicyFileUpdated(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend { + virtual_service { + virtual_service_name = "servicea.simpleapp.local" + + client_policy { + tls { + ports = [443, 8443] + + validation { + trust { + file { + certificate_chain = "/etc/ssl/certs/cert_chain.pem" + } + } + } + } + } + } + } + + listener { + port_mapping { + port = 8080 + protocol = "http" + } + } + + service_discovery { + dns { + hostname = "serviceb.simpleapp.local" + } + } + } +} +`, vnName) +} + func testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName string) string { return testAccAcmCertificateConfig_privateCert(meshName) + testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` resource "aws_appmesh_virtual_node" "test" { From b84b3ee2430b3926a288c6356f2f9bd6677dfbd3 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Mar 2020 17:08:14 -0400 Subject: [PATCH 15/17] r/aws_appmesh_virtual_node: Test backend.virtual_service.client_policy...acm attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode/clientPolicyAcm' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode/clientPolicyAcm -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/clientPolicyAcm --- PASS: TestAccAWSAppmesh (68.09s) --- PASS: TestAccAWSAppmesh/VirtualNode (68.09s) --- PASS: TestAccAWSAppmesh/VirtualNode/clientPolicyAcm (68.09s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 68.124s --- ...e_aws_acmpca_certificate_authority_test.go | 129 ++++++++++++++++-- aws/resource_aws_appmesh_virtual_node_test.go | 27 +++- 2 files changed, 137 insertions(+), 19 deletions(-) diff --git a/aws/resource_aws_acmpca_certificate_authority_test.go b/aws/resource_aws_acmpca_certificate_authority_test.go index 91659c37ed5c..c1a959e6f6d9 100644 --- a/aws/resource_aws_acmpca_certificate_authority_test.go +++ b/aws/resource_aws_acmpca_certificate_authority_test.go @@ -5,9 +5,11 @@ import ( "log" "regexp" "testing" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/acmpca" + "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" @@ -40,24 +42,45 @@ func testSweepAcmpcaCertificateAuthorities(region string) error { return nil } + var sweeperErrs *multierror.Error + for _, certificateAuthority := range certificateAuthorities { arn := aws.StringValue(certificateAuthority.Arn) + + if aws.StringValue(certificateAuthority.Status) == acmpca.CertificateAuthorityStatusActive { + log.Printf("[INFO] Disabling ACMPCA Certificate Authority: %s", arn) + _, err := conn.UpdateCertificateAuthority(&acmpca.UpdateCertificateAuthorityInput{ + CertificateAuthorityArn: aws.String(arn), + Status: aws.String(acmpca.CertificateAuthorityStatusDisabled), + }) + if isAWSErr(err, acmpca.ErrCodeResourceNotFoundException, "") { + continue + } + if err != nil { + sweeperErr := fmt.Errorf("error disabling ACMPCA Certificate Authority (%s): %w", arn, err) + log.Printf("[ERROR] %s", sweeperErr) + sweeperErrs = multierror.Append(sweeperErrs, sweeperErr) + continue + } + } + log.Printf("[INFO] Deleting ACMPCA Certificate Authority: %s", arn) - input := &acmpca.DeleteCertificateAuthorityInput{ + _, err := conn.DeleteCertificateAuthority(&acmpca.DeleteCertificateAuthorityInput{ CertificateAuthorityArn: aws.String(arn), PermanentDeletionTimeInDays: aws.Int64(int64(7)), + }) + if isAWSErr(err, acmpca.ErrCodeResourceNotFoundException, "") { + continue } - - _, err := conn.DeleteCertificateAuthority(input) if err != nil { - if isAWSErr(err, acmpca.ErrCodeResourceNotFoundException, "") { - continue - } - log.Printf("[ERROR] Failed to delete ACMPCA Certificate Authority (%s): %s", arn, err) + sweeperErr := fmt.Errorf("error deleting ACMPCA Certificate Authority (%s): %w", arn, err) + log.Printf("[ERROR] %s", sweeperErr) + sweeperErrs = multierror.Append(sweeperErrs, sweeperErr) + continue } } - return nil + return sweeperErrs.ErrorOrNil() } func TestAccAwsAcmpcaCertificateAuthority_Basic(t *testing.T) { @@ -413,6 +436,7 @@ func TestAccAwsAcmpcaCertificateAuthority_Tags(t *testing.T) { func TestAccAwsAcmpcaCertificateAuthority_Type_Root(t *testing.T) { var certificateAuthority acmpca.CertificateAuthority resourceName := "aws_acmpca_certificate_authority.test" + rName := acctest.RandomWithPrefix("tf-acc-test") resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -420,7 +444,7 @@ func TestAccAwsAcmpcaCertificateAuthority_Type_Root(t *testing.T) { CheckDestroy: testAccCheckAwsAcmpcaCertificateAuthorityDestroy, Steps: []resource.TestStep{ { - Config: testAccAwsAcmpcaCertificateAuthorityConfigType(acmpca.CertificateAuthorityTypeRoot), + Config: testAccAwsAcmpcaCertificateAuthorityConfigType(rName, acmpca.CertificateAuthorityTypeRoot), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAcmpcaCertificateAuthorityExists(resourceName, &certificateAuthority), resource.TestCheckResourceAttr(resourceName, "type", acmpca.CertificateAuthorityTypeRoot), @@ -496,6 +520,85 @@ func testAccCheckAwsAcmpcaCertificateAuthorityExists(resourceName string, certif } } +func testAccCheckAwsAcmpcaCertificateAuthorityActivateCA(certificateAuthority *acmpca.CertificateAuthority) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).acmpcaconn + + arn := aws.StringValue(certificateAuthority.Arn) + + getCsrResp, err := conn.GetCertificateAuthorityCsr(&acmpca.GetCertificateAuthorityCsrInput{ + CertificateAuthorityArn: aws.String(arn), + }) + if err != nil { + return fmt.Errorf("error getting ACMPCA Certificate Authority (%s) CSR: %s", arn, err) + } + + issueCertResp, err := conn.IssueCertificate(&acmpca.IssueCertificateInput{ + CertificateAuthorityArn: aws.String(arn), + Csr: []byte(aws.StringValue(getCsrResp.Csr)), + IdempotencyToken: aws.String(resource.UniqueId()), + SigningAlgorithm: certificateAuthority.CertificateAuthorityConfiguration.SigningAlgorithm, + TemplateArn: aws.String("arn:aws:acm-pca:::template/RootCACertificate/V1"), + Validity: &acmpca.Validity{ + Type: aws.String(acmpca.ValidityPeriodTypeYears), + Value: aws.Int64(1), + }, + }) + if err != nil { + return fmt.Errorf("error issuing ACMPCA Certificate Authority (%s) Root CA certificate from CSR: %s", arn, err) + } + + // Wait for certificate status to become ISSUED. + var getCertResp *acmpca.GetCertificateOutput + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + var err error + getCertResp, err = conn.GetCertificate(&acmpca.GetCertificateInput{ + CertificateAuthorityArn: aws.String(arn), + CertificateArn: issueCertResp.CertificateArn, + }) + if err != nil { + if isAWSErr(err, acmpca.ErrCodeRequestInProgressException, "Try again later") { + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + if isResourceTimeoutError(err) { + getCertResp, err = conn.GetCertificate(&acmpca.GetCertificateInput{ + CertificateAuthorityArn: aws.String(arn), + CertificateArn: issueCertResp.CertificateArn, + }) + } + if err != nil { + return fmt.Errorf("error getting ACMPCA Certificate Authority (%s) issued Root CA certificate: %s", arn, err) + } + + _, err = conn.ImportCertificateAuthorityCertificate(&acmpca.ImportCertificateAuthorityCertificateInput{ + CertificateAuthorityArn: aws.String(arn), + Certificate: []byte(aws.StringValue(getCertResp.Certificate)), + }) + if err != nil { + return fmt.Errorf("error importing ACMPCA Certificate Authority (%s) Root CA certificate: %s", arn, err) + } + + return err + } +} + +func testAccCheckAwsAcmpcaCertificateAuthorityDisableCA(certificateAuthority *acmpca.CertificateAuthority) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).acmpcaconn + + _, err := conn.UpdateCertificateAuthority(&acmpca.UpdateCertificateAuthorityInput{ + CertificateAuthorityArn: certificateAuthority.Arn, + Status: aws.String(acmpca.CertificateAuthorityStatusDisabled), + }) + + return err + } +} + func listAcmpcaCertificateAuthorities(conn *acmpca.ACMPCA) ([]*acmpca.CertificateAuthority, error) { certificateAuthorities := []*acmpca.CertificateAuthority{} input := &acmpca.ListCertificateAuthoritiesInput{} @@ -723,20 +826,20 @@ resource "aws_acmpca_certificate_authority" "test" { } ` -func testAccAwsAcmpcaCertificateAuthorityConfigType(certificateAuthorityType string) string { +func testAccAwsAcmpcaCertificateAuthorityConfigType(rName, certificateAuthorityType string) string { return fmt.Sprintf(` resource "aws_acmpca_certificate_authority" "test" { permanent_deletion_time_in_days = 7 - type = %[1]q + type = %[2]q certificate_authority_configuration { key_algorithm = "RSA_4096" signing_algorithm = "SHA512WITHRSA" subject { - common_name = "terraformtesting.com" + common_name = "%[1]s.com" } } } -`, certificateAuthorityType) +`, rName, certificateAuthorityType) } diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index 8e12bceda8a2..85e5e4e9c35f 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/acmpca" appmesh "github.com/aws/aws-sdk-go/service/appmeshpreview" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -577,18 +578,24 @@ func testAccAwsAppmeshVirtualNode_clientPolicyFile(t *testing.T) { func testAccAwsAppmeshVirtualNode_clientPolicyAcm(t *testing.T) { var vn appmesh.VirtualNodeData + var ca acmpca.CertificateAuthority resourceName := "aws_appmesh_virtual_node.test" - acmCAResourceName := "aws_acmpca_certificate_authority.cert" + acmCAResourceName := "aws_acmpca_certificate_authority.test" meshName := acctest.RandomWithPrefix("tf-acc-test") vnName := acctest.RandomWithPrefix("tf-acc-test") - t.Skip("Requires an active ACM PCA") - resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppmeshVirtualNodeDestroy, Steps: []resource.TestStep{ + { + Config: testAccAwsAcmpcaCertificateAuthorityConfigType(meshName, acmpca.CertificateAuthorityTypeRoot), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAcmpcaCertificateAuthorityExists(acmCAResourceName, &ca), + testAccCheckAwsAcmpcaCertificateAuthorityActivateCA(&ca), + ), + }, { Config: testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName), Check: resource.ComposeTestCheckFunc( @@ -615,6 +622,14 @@ func testAccAwsAppmeshVirtualNode_clientPolicyAcm(t *testing.T) { testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), ), }, + { + Config: testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + // CA must be DISABLED for deletion. + testAccCheckAwsAcmpcaCertificateAuthorityDisableCA(&ca), + ), + ExpectNonEmptyPlan: true, + }, { ResourceName: resourceName, ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), @@ -1138,7 +1153,7 @@ resource "aws_appmesh_virtual_node" "test" { } func testAccAppmeshVirtualNodeConfig_clientPolicyAcm(meshName, vnName string) string { - return testAccAcmCertificateConfig_privateCert(meshName) + testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` + return testAccAwsAcmpcaCertificateAuthorityConfigType(meshName, acmpca.CertificateAuthorityTypeRoot) + testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` resource "aws_appmesh_virtual_node" "test" { name = %[1]q mesh_name = "${aws_appmesh_mesh.test.id}" @@ -1150,12 +1165,12 @@ resource "aws_appmesh_virtual_node" "test" { client_policy { tls { - ports = [443, 8443] + ports = [8443] validation { trust { acm { - certificate_authority_arns = ["${aws_acm_certificate.cert.arn}"] + certificate_authority_arns = ["${aws_acmpca_certificate_authority.test.arn}"] } } } From 2a0231f68a97959be14212f0e20e5b031421f603 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Mar 2020 16:16:02 -0400 Subject: [PATCH 16/17] r/aws_appmesh_virtual_node: Add spec.backend_defaults attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode/clientPolicyFile' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode/clientPolicyFile -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/clientPolicyFile --- PASS: TestAccAWSAppmesh (42.17s) --- PASS: TestAccAWSAppmesh/VirtualNode (42.17s) --- PASS: TestAccAWSAppmesh/VirtualNode/clientPolicyFile (42.17s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 42.221s --- aws/resource_aws_appmesh_virtual_node.go | 269 +++++++------- aws/structure.go | 347 ++++++++++-------- .../docs/r/appmesh_virtual_node.html.markdown | 5 + 3 files changed, 338 insertions(+), 283 deletions(-) diff --git a/aws/resource_aws_appmesh_virtual_node.go b/aws/resource_aws_appmesh_virtual_node.go index 31cf000852cb..a3fcedf287e0 100644 --- a/aws/resource_aws_appmesh_virtual_node.go +++ b/aws/resource_aws_appmesh_virtual_node.go @@ -86,132 +86,7 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 255), }, - "client_policy": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tls": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enforce": { - Type: schema.TypeBool, - Optional: true, - Default: true, - }, - - "ports": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeInt}, - Set: schema.HashInt, - }, - - "validation": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "trust": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "acm": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "certificate_authority_arns": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, - }, - }, - }, - }, - - "file": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "certificate_chain": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 255), - }, - }, - }, - }, - - "sds": { - Type: schema.TypeList, - Optional: true, - MinItems: 0, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "secret_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 255), - }, - - "source": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "unix_domain_socket": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "path": { - Type: schema.TypeString, - Required: true, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, + "client_policy": appmeshVirtualNodeClientPolicySchema(), }, }, }, @@ -220,6 +95,18 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { Set: appmeshVirtualNodeBackendHash, }, + "backend_defaults": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "client_policy": appmeshVirtualNodeClientPolicySchema(), + }, + }, + }, + "listener": { Type: schema.TypeSet, Optional: true, @@ -547,6 +434,136 @@ func resourceAwsAppmeshVirtualNode() *schema.Resource { } } +// appmeshVirtualNodeClientPolicySchema returns the schema for `client_policy` attributes. +func appmeshVirtualNodeClientPolicySchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tls": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enforce": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "ports": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeInt}, + Set: schema.HashInt, + }, + + "validation": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "trust": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "acm": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_authority_arns": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + }, + }, + }, + + "file": { + Type: schema.TypeList, + Optional: true, + MinItems: 0, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_chain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 255), + }, + }, + }, + }, + + // "sds": { + // Type: schema.TypeList, + // Optional: true, + // MinItems: 0, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "secret_name": { + // Type: schema.TypeString, + // Required: true, + // ValidateFunc: validation.StringLenBetween(1, 255), + // }, + + // "source": { + // Type: schema.TypeList, + // Required: true, + // MinItems: 1, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "unix_domain_socket": { + // Type: schema.TypeList, + // Required: true, + // MinItems: 1, + // MaxItems: 1, + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "path": { + // Type: schema.TypeString, + // Required: true, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + func resourceAwsAppmeshVirtualNodeCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appmeshconn diff --git a/aws/structure.go b/aws/structure.go index 53b04576872c..ed2a8e920641 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -5073,98 +5073,8 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec virtualService.VirtualServiceName = aws.String(vVirtualServiceName) } - if vClientPolicy, ok := mVirtualService["client_policy"].([]interface{}); ok && len(vClientPolicy) > 0 && vClientPolicy[0] != nil { - clientPolicy := &appmesh.ClientPolicy{} - - mClientPolicy := vClientPolicy[0].(map[string]interface{}) - - if vTls, ok := mClientPolicy["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { - tls := &appmesh.ClientPolicyTls{} - - mTls := vTls[0].(map[string]interface{}) - - if vEnforce, ok := mTls["enforce"].(bool); ok { - tls.Enforce = aws.Bool(vEnforce) - } - - if vPorts, ok := mTls["ports"].(*schema.Set); ok && vPorts.Len() > 0 { - tls.Ports = expandIntSet(vPorts) - } - - if vValidation, ok := mTls["validation"].([]interface{}); ok && len(vValidation) > 0 && vValidation[0] != nil { - validation := &appmesh.TlsValidationContext{} - - mValidation := vValidation[0].(map[string]interface{}) - - if vTrust, ok := mValidation["trust"].([]interface{}); ok && len(vTrust) > 0 && vTrust[0] != nil { - trust := &appmesh.TlsValidationContextTrust{} - - mTrust := vTrust[0].(map[string]interface{}) - - if vAcm, ok := mTrust["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { - acm := &appmesh.TlsValidationContextAcmTrust{} - - mAcm := vAcm[0].(map[string]interface{}) - - if vCertificateAuthorityArns, ok := mAcm["certificate_authority_arns"].(*schema.Set); ok && vCertificateAuthorityArns.Len() > 0 { - acm.CertificateAuthorityArns = expandStringSet(vCertificateAuthorityArns) - } - - trust.Acm = acm - } - - if vFile, ok := mTrust["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { - file := &appmesh.TlsValidationContextFileTrust{} - - mFile := vFile[0].(map[string]interface{}) - - if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { - file.CertificateChain = aws.String(vCertificateChain) - } - - trust.File = file - } - - // if vSds, ok := mTrust["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { - // sds := &appmesh.TlsValidationContextSdsTrust{} - - // mSds := vSds[0].(map[string]interface{}) - - // if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { - // sds.SecretName = aws.String(vSecretName) - // } - - // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { - // source := &appmesh.SdsSource{} - - // mSource := vSource[0].(map[string]interface{}) - - // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { - // unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} - - // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) - - // if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { - // unixDomainSocket.Path = aws.String(vPath) - // } - - // source.UnixDomainSocket = unixDomainSocket - // } - // } - - // trust.Sds = sds - // } - - validation.Trust = trust - } - - tls.Validation = validation - } - - clientPolicy.Tls = tls - } - - virtualService.ClientPolicy = clientPolicy + if vClientPolicy, ok := mVirtualService["client_policy"].([]interface{}); ok { + virtualService.ClientPolicy = expandAppmeshClientPolicy(vClientPolicy) } backend.VirtualService = virtualService @@ -5176,6 +5086,18 @@ func expandAppmeshVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec spec.Backends = backends } + if vBackendDefaults, ok := mSpec["backend_defaults"].([]interface{}); ok && len(vBackendDefaults) > 0 && vBackendDefaults[0] != nil { + backendDefaults := &appmesh.BackendDefaults{} + + mBackendDefaults := vBackendDefaults[0].(map[string]interface{}) + + if vClientPolicy, ok := mBackendDefaults["client_policy"].([]interface{}); ok { + backendDefaults.ClientPolicy = expandAppmeshClientPolicy(vClientPolicy) + } + + spec.BackendDefaults = backendDefaults + } + if vListeners, ok := mSpec["listener"].(*schema.Set); ok && vListeners.Len() > 0 { listeners := []*appmesh.Listener{} @@ -5408,74 +5330,10 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} if virtualService := backend.VirtualService; virtualService != nil { mVirtualService := map[string]interface{}{ + "client_policy": flattenAppmeshClientPolicy(virtualService.ClientPolicy), "virtual_service_name": aws.StringValue(virtualService.VirtualServiceName), } - if clientPolicy := virtualService.ClientPolicy; clientPolicy != nil { - mClientPolicy := map[string]interface{}{} - - if tls := clientPolicy.Tls; tls != nil { - mTls := map[string]interface{}{ - "enforce": aws.BoolValue(tls.Enforce), - "ports": flattenIntSet(tls.Ports), - } - - if validation := tls.Validation; validation != nil { - mValidation := map[string]interface{}{} - - if trust := validation.Trust; trust != nil { - mTrust := map[string]interface{}{} - - if acm := trust.Acm; acm != nil { - mAcm := map[string]interface{}{ - "certificate_authority_arns": flattenStringSet(acm.CertificateAuthorityArns), - } - - mTrust["acm"] = []interface{}{mAcm} - } - - if file := trust.File; file != nil { - mFile := map[string]interface{}{ - "certificate_chain": aws.StringValue(file.CertificateChain), - } - - mTrust["file"] = []interface{}{mFile} - } - - // if sds := trust.Sds; sds != nil { - // mSds := map[string]interface{}{ - // "secret_name": aws.StringValue(sds.SecretName), - // } - - // if source := sds.Source; source != nil { - // mSource := map[string]interface{}{} - - // if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { - // mUnixDomainSocket := map[string]interface{}{ - // "path": aws.StringValue(unixDomainSocket.Path), - // } - - // mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} - // } - - // mSds["source"] = []interface{}{mSource} - // } - - // mTrust["sds"] = []interface{}{mSds} - // } - - mValidation["trust"] = []interface{}{mTrust} - } - - mTls["validation"] = []interface{}{mValidation} - } - - mClientPolicy["tls"] = []interface{}{mTls} - } - - mVirtualService["client_policy"] = []interface{}{mClientPolicy} - } - mBackend["virtual_service"] = []interface{}{mVirtualService} } @@ -5485,6 +5343,14 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} mSpec["backend"] = schema.NewSet(appmeshVirtualNodeBackendHash, vBackends) } + if backendDefaults := spec.BackendDefaults; backendDefaults != nil { + mBackendDefaults := map[string]interface{}{ + "client_policy": flattenAppmeshClientPolicy(backendDefaults.ClientPolicy), + } + + mSpec["backend_defaults"] = []interface{}{mBackendDefaults} + } + if listeners := spec.Listeners; listeners != nil { vListeners := []interface{}{} @@ -5627,6 +5493,173 @@ func flattenAppmeshVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} return []interface{}{mSpec} } +func expandAppmeshClientPolicy(vClientPolicy []interface{}) *appmesh.ClientPolicy { + if len(vClientPolicy) == 0 || vClientPolicy[0] == nil { + return nil + } + + clientPolicy := &appmesh.ClientPolicy{} + + mClientPolicy := vClientPolicy[0].(map[string]interface{}) + + if vTls, ok := mClientPolicy["tls"].([]interface{}); ok && len(vTls) > 0 && vTls[0] != nil { + tls := &appmesh.ClientPolicyTls{} + + mTls := vTls[0].(map[string]interface{}) + + if vEnforce, ok := mTls["enforce"].(bool); ok { + tls.Enforce = aws.Bool(vEnforce) + } + + if vPorts, ok := mTls["ports"].(*schema.Set); ok && vPorts.Len() > 0 { + tls.Ports = expandIntSet(vPorts) + } + + if vValidation, ok := mTls["validation"].([]interface{}); ok && len(vValidation) > 0 && vValidation[0] != nil { + validation := &appmesh.TlsValidationContext{} + + mValidation := vValidation[0].(map[string]interface{}) + + if vTrust, ok := mValidation["trust"].([]interface{}); ok && len(vTrust) > 0 && vTrust[0] != nil { + trust := &appmesh.TlsValidationContextTrust{} + + mTrust := vTrust[0].(map[string]interface{}) + + if vAcm, ok := mTrust["acm"].([]interface{}); ok && len(vAcm) > 0 && vAcm[0] != nil { + acm := &appmesh.TlsValidationContextAcmTrust{} + + mAcm := vAcm[0].(map[string]interface{}) + + if vCertificateAuthorityArns, ok := mAcm["certificate_authority_arns"].(*schema.Set); ok && vCertificateAuthorityArns.Len() > 0 { + acm.CertificateAuthorityArns = expandStringSet(vCertificateAuthorityArns) + } + + trust.Acm = acm + } + + if vFile, ok := mTrust["file"].([]interface{}); ok && len(vFile) > 0 && vFile[0] != nil { + file := &appmesh.TlsValidationContextFileTrust{} + + mFile := vFile[0].(map[string]interface{}) + + if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { + file.CertificateChain = aws.String(vCertificateChain) + } + + trust.File = file + } + + // if vSds, ok := mTrust["sds"].([]interface{}); ok && len(vSds) > 0 && vSds[0] != nil { + // sds := &appmesh.TlsValidationContextSdsTrust{} + + // mSds := vSds[0].(map[string]interface{}) + + // if vSecretName, ok := mSds["secret_name"].(string); ok && vSecretName != "" { + // sds.SecretName = aws.String(vSecretName) + // } + + // if vSource, ok := mSds["source"].([]interface{}); ok && len(vSource) > 0 && vSource[0] != nil { + // source := &appmesh.SdsSource{} + + // mSource := vSource[0].(map[string]interface{}) + + // if vUnixDomainSocket, ok := mSource["unix_domain_socket"].([]interface{}); ok && len(vUnixDomainSocket) > 0 && vUnixDomainSocket[0] != nil { + // unixDomainSocket := &appmesh.SdsUnixDomainSocketSource{} + + // mUnixDomainSocket := vUnixDomainSocket[0].(map[string]interface{}) + + // if vPath, ok := mUnixDomainSocket["path"].(string); ok && vPath != "" { + // unixDomainSocket.Path = aws.String(vPath) + // } + + // source.UnixDomainSocket = unixDomainSocket + // } + // } + + // trust.Sds = sds + // } + + validation.Trust = trust + } + + tls.Validation = validation + } + + clientPolicy.Tls = tls + } + + return clientPolicy +} + +func flattenAppmeshClientPolicy(clientPolicy *appmesh.ClientPolicy) []interface{} { + if clientPolicy == nil { + return []interface{}{} + } + + mClientPolicy := map[string]interface{}{} + + if tls := clientPolicy.Tls; tls != nil { + mTls := map[string]interface{}{ + "enforce": aws.BoolValue(tls.Enforce), + "ports": flattenIntSet(tls.Ports), + } + + if validation := tls.Validation; validation != nil { + mValidation := map[string]interface{}{} + + if trust := validation.Trust; trust != nil { + mTrust := map[string]interface{}{} + + if acm := trust.Acm; acm != nil { + mAcm := map[string]interface{}{ + "certificate_authority_arns": flattenStringSet(acm.CertificateAuthorityArns), + } + + mTrust["acm"] = []interface{}{mAcm} + } + + if file := trust.File; file != nil { + mFile := map[string]interface{}{ + "certificate_chain": aws.StringValue(file.CertificateChain), + } + + mTrust["file"] = []interface{}{mFile} + } + + // if sds := trust.Sds; sds != nil { + // mSds := map[string]interface{}{ + // "secret_name": aws.StringValue(sds.SecretName), + // } + + // if source := sds.Source; source != nil { + // mSource := map[string]interface{}{} + + // if unixDomainSocket := source.UnixDomainSocket; unixDomainSocket != nil { + // mUnixDomainSocket := map[string]interface{}{ + // "path": aws.StringValue(unixDomainSocket.Path), + // } + + // mSource["unix_domain_socket"] = []interface{}{mUnixDomainSocket} + // } + + // mSds["source"] = []interface{}{mSource} + // } + + // mTrust["sds"] = []interface{}{mSds} + // } + + mValidation["trust"] = []interface{}{mTrust} + } + + mTls["validation"] = []interface{}{mValidation} + } + + mClientPolicy["tls"] = []interface{}{mTls} + } + + return []interface{}{mClientPolicy} +} + func expandAppmeshVirtualServiceSpec(vSpec []interface{}) *appmesh.VirtualServiceSpec { spec := &appmesh.VirtualServiceSpec{} diff --git a/website/docs/r/appmesh_virtual_node.html.markdown b/website/docs/r/appmesh_virtual_node.html.markdown index 20bb637953a3..9f20df1632c0 100644 --- a/website/docs/r/appmesh_virtual_node.html.markdown +++ b/website/docs/r/appmesh_virtual_node.html.markdown @@ -182,6 +182,7 @@ The following arguments are supported: The `spec` object supports the following: * `backend` - (Optional) The backends to which the virtual node is expected to send outbound traffic. +* `backend_defaults` - (Optional) The defaults for backends. * `listener` - (Optional) The listeners from which the virtual node is expected to receive inbound traffic. * `logging` - (Optional) The inbound and outbound access logging information for the virtual node. * `service_discovery` - (Optional) The service discovery information for the virtual node. @@ -222,6 +223,10 @@ The `file` object supports the following: * `certificate_chain` - (Required) The certificate trust chain for a certificate stored on the file system of the virtual node that the proxy is running on. +The `backend_defaults` object supports the following: + +* `client_policy` - (Optional) The default client policy for virtual service backends. See above for details. + The `listener` object supports the following: * `port_mapping` - (Required) The port mapping information for the listener. From b27d089b53946f718a36bea0cf6e35e95e302d93 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Mar 2020 16:40:39 -0400 Subject: [PATCH 17/17] r/aws_appmesh_virtual_node: Test spec.backend_defaults attribute. Acceptance test output: $ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/VirtualNode/backendDefaults' ==> Checking that code complies with gofmt requirements... GO111MODULE=off TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAppmesh/VirtualNode/backendDefaults -timeout 120m === RUN TestAccAWSAppmesh === RUN TestAccAWSAppmesh/VirtualNode === RUN TestAccAWSAppmesh/VirtualNode/backendDefaults --- PASS: TestAccAWSAppmesh (41.99s) --- PASS: TestAccAWSAppmesh/VirtualNode (41.99s) --- PASS: TestAccAWSAppmesh/VirtualNode/backendDefaults (41.99s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 42.047s --- aws/resource_aws_appmesh_test.go | 1 + aws/resource_aws_appmesh_virtual_node_test.go | 143 ++++++++++++++++++ 2 files changed, 144 insertions(+) diff --git a/aws/resource_aws_appmesh_test.go b/aws/resource_aws_appmesh_test.go index a33f28a9d253..a5b975ea8ca6 100644 --- a/aws/resource_aws_appmesh_test.go +++ b/aws/resource_aws_appmesh_test.go @@ -23,6 +23,7 @@ func TestAccAWSAppmesh(t *testing.T) { }, "VirtualNode": { "basic": testAccAwsAppmeshVirtualNode_basic, + "backendDefaults": testAccAwsAppmeshVirtualNode_backendDefaults, "clientPolicyAcm": testAccAwsAppmeshVirtualNode_clientPolicyAcm, "clientPolicyFile": testAccAwsAppmeshVirtualNode_clientPolicyFile, "cloudMapServiceDiscovery": testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery, diff --git a/aws/resource_aws_appmesh_virtual_node_test.go b/aws/resource_aws_appmesh_virtual_node_test.go index 85e5e4e9c35f..b3318836af8d 100644 --- a/aws/resource_aws_appmesh_virtual_node_test.go +++ b/aws/resource_aws_appmesh_virtual_node_test.go @@ -99,6 +99,7 @@ func testAccAwsAppmeshVirtualNode_basic(t *testing.T) { testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "0"), @@ -197,6 +198,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.health_check.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.433446196.health_check.0.healthy_threshold", "3"), @@ -235,6 +237,7 @@ func testAccAwsAppmeshVirtualNode_listenerHealthChecks(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2025248115.virtual_service.0.virtual_service_name", "serviced.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.health_check.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3446683576.health_check.0.healthy_threshold", "4"), @@ -385,6 +388,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.health_check.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.180467016.port_mapping.#", "1"), @@ -421,6 +425,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), // resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + // resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.health_check.#", "0"), // resource.TestCheckResourceAttr(resourceName, "spec.0.listener.3024651324.port_mapping.#", "1"), @@ -458,6 +463,7 @@ func testAccAwsAppmeshVirtualNode_tls(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.client_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.2622272660.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), testAccCheckAppmeshVirtualNodeTlsAcmCertificateArn(acmCertificateResourceName, "arn", &vn), resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), @@ -512,6 +518,7 @@ func testAccAwsAppmeshVirtualNode_clientPolicyFile(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/cert_chain.pem"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.sds.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.906924271.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), @@ -550,6 +557,7 @@ func testAccAwsAppmeshVirtualNode_clientPolicyFile(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/etc/ssl/certs/cert_chain.pem"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.client_policy.0.tls.0.validation.0.trust.0.sds.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.3920410102.virtual_service.0.virtual_service_name", "servicea.simpleapp.local"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), @@ -606,6 +614,7 @@ func testAccAwsAppmeshVirtualNode_clientPolicyAcm(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "1"), testAccCheckAppmeshVirtualNodeClientPolicyAcmCertificateAuthorityArn(acmCAResourceName, "arn", &vn), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "1"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.health_check.#", "0"), resource.TestCheckResourceAttr(resourceName, "spec.0.listener.2279702354.port_mapping.#", "1"), @@ -640,6 +649,86 @@ func testAccAwsAppmeshVirtualNode_clientPolicyAcm(t *testing.T) { }) } +func testAccAwsAppmeshVirtualNode_backendDefaults(t *testing.T) { + var vn appmesh.VirtualNodeData + resourceName := "aws_appmesh_virtual_node.test" + meshName := acctest.RandomWithPrefix("tf-acc-test") + vnName := acctest.RandomWithPrefix("tf-acc-test") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppmeshVirtualNodeDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAppmeshVirtualNodeConfig_backendDefaults(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.enforce", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.ports.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.ports.860082431", "8443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.acm.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.file.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/cert_chain.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + { + Config: testAccAppmeshVirtualNodeConfig_backendDefaultsUpdated(meshName, vnName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAppmeshVirtualNodeExists(resourceName, &vn), + resource.TestCheckResourceAttr(resourceName, "name", vnName), + resource.TestCheckResourceAttr(resourceName, "mesh_name", meshName), + testAccCheckResourceAttrAccountID(resourceName, "mesh_owner"), + resource.TestCheckResourceAttr(resourceName, "spec.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.enforce", "true"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.ports.#", "2"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.ports.3638101695", "443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.ports.860082431", "8443"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.acm.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.file.#", "1"), + resource.TestCheckResourceAttr(resourceName, "spec.0.backend_defaults.0.client_policy.0.tls.0.validation.0.trust.0.file.0.certificate_chain", "/etc/ssl/certs/cert_chain.pem"), + resource.TestCheckResourceAttr(resourceName, "spec.0.listener.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.logging.#", "0"), + resource.TestCheckResourceAttr(resourceName, "spec.0.service_discovery.#", "0"), + resource.TestCheckResourceAttrSet(resourceName, "created_date"), + resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"), + testAccCheckResourceAttrAccountID(resourceName, "resource_owner"), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualNode/%s", meshName, vnName)), + ), + }, + { + ResourceName: resourceName, + ImportStateId: fmt.Sprintf("%s/%s", meshName, vnName), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAppmeshVirtualNodeDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appmeshconn @@ -1195,3 +1284,57 @@ resource "aws_appmesh_virtual_node" "test" { } `, vnName) } + +func testAccAppmeshVirtualNodeConfig_backendDefaults(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend_defaults { + client_policy { + tls { + ports = [8443] + + validation { + trust { + file { + certificate_chain = "/cert_chain.pem" + } + } + } + } + } + } + } +} +`, vnName) +} + +func testAccAppmeshVirtualNodeConfig_backendDefaultsUpdated(meshName, vnName string) string { + return testAccAppmeshVirtualNodeConfig_mesh(meshName) + fmt.Sprintf(` +resource "aws_appmesh_virtual_node" "test" { + name = %[1]q + mesh_name = "${aws_appmesh_mesh.test.id}" + + spec { + backend_defaults { + client_policy { + tls { + ports = [443, 8443] + + validation { + trust { + file { + certificate_chain = "/etc/ssl/certs/cert_chain.pem" + } + } + } + } + } + } + } +} +`, vnName) +}