Skip to content

Commit

Permalink
Merge pull request #29064 from benmurden/vgw-ports
Browse files Browse the repository at this point in the history
Add App Mesh Virtual Gateway Target Ports
  • Loading branch information
ewbankkit authored Mar 27, 2023
2 parents bfe0b0b + cec988d commit bfa0aa5
Show file tree
Hide file tree
Showing 31 changed files with 2,692 additions and 881 deletions.
3 changes: 3 additions & 0 deletions .changelog/26908.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``release-note:new-data-source
aws_appmesh_virtual_router
```
31 changes: 31 additions & 0 deletions .changelog/29064.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
```release-note:enhancement
resource/aws_appmesh_gateway_route: Add `port` to the `spec.grpc_route.action.target`, `spec.http_route.action.target` and `spec.http2_route.action.target` configuration blocks to support Virtual Services with multiple listeners
```

```release-note:new-data-source
aws_appmesh_gateway_route
```

```release-note:enhancement
resource/aws_appmesh_gateway_route: Add `priority` to the `spec` configuration block
```

```release-note:enhancement
resource/aws_appmesh_virtual_node: Add `ip_preference` and `response_type` to the `spec.service_discovery.dns` configuration block
```

```release-note:enhancement
resource/aws_appmesh_route: Add `path` and `query_parameter` to the `spec.http_route.match` and `spec.http2_route.match` configuration blocks
```

```release-note:enhancement
resource/aws_appmesh_route: `spec.http_route.match.prefix` and `spec.http2_route.match.prefix` are Optional
```

```release-note:enhancement
resource/aws_appmesh_gateway_route: Add `header`, `path` and `query_parameter` to the `spec.http_route.match` and `spec.http2_route.match` configuration blocks
```

```release-note:bug
resource/aws_appmesh_virtual_router: `spec.listener` is Optional
```
79 changes: 44 additions & 35 deletions internal/service/appmesh/appmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ func TestAccAppMesh_serial(t *testing.T) {

testCases := map[string]map[string]func(t *testing.T){
"GatewayRoute": {
"basic": testAccGatewayRoute_basic,
"disappears": testAccGatewayRoute_disappears,
"grpcRoute": testAccGatewayRoute_GRPCRoute,
"grpcRouteWithPort": testAccGatewayRoute_GRPCRouteWithPort,
"httpRoute": testAccGatewayRoute_HTTPRoute,
"httpRouteWithPort": testAccGatewayRoute_HTTPRouteWithPort,
"http2Route": testAccGatewayRoute_HTTP2Route,
"http2RouteWithPort": testAccGatewayRoute_HTTP2RouteWithPort,
"tags": testAccGatewayRoute_Tags,
"basic": testAccGatewayRoute_basic,
"disappears": testAccGatewayRoute_disappears,
"grpcRoute": testAccGatewayRoute_grpcRoute,
"grpcRouteTargetPort": testAccGatewayRoute_grpcRouteTargetPort,
"grpcRouteWithPort": testAccGatewayRoute_grpcRouteWithPort,
"httpRoute": testAccGatewayRoute_httpRoute,
"httpRouteTargetPort": testAccGatewayRoute_httpRouteTargetPort,
"httpRouteWithPath": testAccGatewayRoute_httpRouteWithPath,
"httpRouteWithPort": testAccGatewayRoute_httpRouteWithPort,
"http2Route": testAccGatewayRoute_http2Route,
"http2RouteTargetPort": testAccGatewayRoute_http2RouteTargetPort,
"http2RouteWithPort": testAccGatewayRoute_http2RouteWithPort,
"http2RouteWithQueryParameter": testAccGatewayRoute_http2RouteWithQueryParameter,
"tags": testAccGatewayRoute_tags,
"dataSourceBasic": testAccGatewayRouteDataSource_basic,
},
"Mesh": {
"basic": testAccMesh_basic,
Expand All @@ -32,28 +38,30 @@ func TestAccAppMesh_serial(t *testing.T) {
"dataSourceShared": testAccMeshDataSource_shared,
},
"Route": {
"disappears": testAccRoute_disappears,
"grpcRoute": testAccRoute_grpcRoute,
"grpcRouteWithPortMatch": testAccRoute_grpcRouteWithPortMatch,
"grpcRouteEmptyMatch": testAccRoute_grpcRouteEmptyMatch,
"grpcRouteTimeout": testAccRoute_grpcRouteTimeout,
"http2Route": testAccRoute_http2Route,
"http2RouteWithPortMatch": testAccRoute_http2RouteWithPortMatch,
"http2RouteTimeout": testAccRoute_http2RouteTimeout,
"httpHeader": testAccRoute_httpHeader,
"httpRetryPolicy": testAccRoute_httpRetryPolicy,
"httpRoute": testAccRoute_httpRoute,
"httpRouteWithPortMatch": testAccRoute_httpRouteWithPortMatch,
"httpRouteTimeout": testAccRoute_httpRouteTimeout,
"routePriority": testAccRoute_routePriority,
"tcpRoute": testAccRoute_tcpRoute,
"tcpRouteWithPortMatch": testAccRoute_tcpRouteWithPortMatch,
"tcpRouteTimeout": testAccRoute_tcpRouteTimeout,
"tags": testAccRoute_tags,
"dataSourceHTTP2Route": testAccRouteDataSource_http2Route,
"dataSourceHTTPRoute": testAccRouteDataSource_httpRoute,
"dataSourceGRPCRoute": testAccRouteDataSource_grpcRoute,
"dataSourceTCPRoute": testAccRouteDataSource_tcpRoute,
"disappears": testAccRoute_disappears,
"grpcRoute": testAccRoute_grpcRoute,
"grpcRouteWithPortMatch": testAccRoute_grpcRouteWithPortMatch,
"grpcRouteEmptyMatch": testAccRoute_grpcRouteEmptyMatch,
"grpcRouteTimeout": testAccRoute_grpcRouteTimeout,
"http2Route": testAccRoute_http2Route,
"http2RouteWithPathMatch": testAccRoute_http2RouteWithPathMatch,
"http2RouteWithPortMatch": testAccRoute_http2RouteWithPortMatch,
"http2RouteTimeout": testAccRoute_http2RouteTimeout,
"httpHeader": testAccRoute_httpHeader,
"httpRetryPolicy": testAccRoute_httpRetryPolicy,
"httpRoute": testAccRoute_httpRoute,
"httpRouteWithPortMatch": testAccRoute_httpRouteWithPortMatch,
"httpRouteWithQueryParameterMatch": testAccRoute_httpRouteWithQueryParameterMatch,
"httpRouteTimeout": testAccRoute_httpRouteTimeout,
"routePriority": testAccRoute_routePriority,
"tcpRoute": testAccRoute_tcpRoute,
"tcpRouteWithPortMatch": testAccRoute_tcpRouteWithPortMatch,
"tcpRouteTimeout": testAccRoute_tcpRouteTimeout,
"tags": testAccRoute_tags,
"dataSourceHTTP2Route": testAccRouteDataSource_http2Route,
"dataSourceHTTPRoute": testAccRouteDataSource_httpRoute,
"dataSourceGRPCRoute": testAccRouteDataSource_grpcRoute,
"dataSourceTCPRoute": testAccRouteDataSource_tcpRoute,
},
"VirtualGateway": {
"basic": testAccVirtualGateway_basic,
Expand Down Expand Up @@ -89,10 +97,11 @@ func TestAccAppMesh_serial(t *testing.T) {
"dataSourceBasic": testAccVirtualNodeDataSource_basic,
},
"VirtualRouter": {
"basic": testAccVirtualRouter_basic,
"disappears": testAccVirtualRouter_disappears,
"multiListener": testAccVirtualRouter_multiListener,
"tags": testAccVirtualRouter_tags,
"basic": testAccVirtualRouter_basic,
"disappears": testAccVirtualRouter_disappears,
"multiListener": testAccVirtualRouter_multiListener,
"tags": testAccVirtualRouter_tags,
"dataSourceBasic": testAccVirtualRouterDataSource_basic,
},
"VirtualService": {
"disappears": testAccVirtualService_disappears,
Expand Down
32 changes: 0 additions & 32 deletions internal/service/appmesh/find.go

This file was deleted.

103 changes: 93 additions & 10 deletions internal/service/appmesh/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,16 @@ func expandHTTPRoute(vHttpRoute []interface{}) *appmesh.HttpRoute {
if vMethod, ok := mHttpRouteMatch["method"].(string); ok && vMethod != "" {
httpRouteMatch.Method = aws.String(vMethod)
}
if vPort, ok := mHttpRouteMatch["port"].(int); ok && vPort > 0 {
httpRouteMatch.Port = aws.Int64(int64(vPort))
}
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 vPort, ok := mHttpRouteMatch["port"].(int); ok && vPort > 0 {
httpRouteMatch.Port = aws.Int64(int64(vPort))
}

if vHttpRouteHeaders, ok := mHttpRouteMatch["header"].(*schema.Set); ok && vHttpRouteHeaders.Len() > 0 {
httpRouteHeaders := []*appmesh.HttpRouteHeader{}

Expand Down Expand Up @@ -445,6 +444,49 @@ func expandHTTPRoute(vHttpRoute []interface{}) *appmesh.HttpRoute {
httpRouteMatch.Headers = httpRouteHeaders
}

if vHttpRoutePath, ok := mHttpRouteMatch["path"].([]interface{}); ok && len(vHttpRoutePath) > 0 && vHttpRoutePath[0] != nil {
httpRoutePath := &appmesh.HttpPathMatch{}

mHttpRoutePath := vHttpRoutePath[0].(map[string]interface{})

if vExact, ok := mHttpRoutePath["exact"].(string); ok && vExact != "" {
httpRoutePath.Exact = aws.String(vExact)
}
if vRegex, ok := mHttpRoutePath["regex"].(string); ok && vRegex != "" {
httpRoutePath.Regex = aws.String(vRegex)
}

httpRouteMatch.Path = httpRoutePath
}

if vHttpRouteQueryParameters, ok := mHttpRouteMatch["query_parameter"].(*schema.Set); ok && vHttpRouteQueryParameters.Len() > 0 {
httpRouteQueryParameters := []*appmesh.HttpQueryParameter{}

for _, vHttpRouteQueryParameter := range vHttpRouteQueryParameters.List() {
httpRouteQueryParameter := &appmesh.HttpQueryParameter{}

mHttpRouteQueryParameter := vHttpRouteQueryParameter.(map[string]interface{})

if vName, ok := mHttpRouteQueryParameter["name"].(string); ok && vName != "" {
httpRouteQueryParameter.Name = aws.String(vName)
}

if vMatch, ok := mHttpRouteQueryParameter["match"].([]interface{}); ok && len(vMatch) > 0 && vMatch[0] != nil {
httpRouteQueryParameter.Match = &appmesh.QueryParameterMatch{}

mMatch := vMatch[0].(map[string]interface{})

if vExact, ok := mMatch["exact"].(string); ok && vExact != "" {
httpRouteQueryParameter.Match.Exact = aws.String(vExact)
}
}

httpRouteQueryParameters = append(httpRouteQueryParameters, httpRouteQueryParameter)
}

httpRouteMatch.QueryParameters = httpRouteQueryParameters
}

httpRoute.Match = httpRouteMatch
}

Expand Down Expand Up @@ -1055,6 +1097,14 @@ func expandVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec {
dns.Hostname = aws.String(vHostname)
}

if vIPPreference, ok := mDns["ip_preference"].(string); ok && vIPPreference != "" {
dns.IpPreference = aws.String(vIPPreference)
}

if vResponseType, ok := mDns["response_type"].(string); ok && vResponseType != "" {
dns.ResponseType = aws.String(vResponseType)
}

serviceDiscovery.Dns = dns
}

Expand Down Expand Up @@ -1406,13 +1456,44 @@ func flattenHTTPRoute(httpRoute *appmesh.HttpRoute) []interface{} {
vHttpRouteHeaders = append(vHttpRouteHeaders, mHttpRouteHeader)
}

vHttpRoutePath := []interface{}{}

if httpRoutePath := httpRouteMatch.Path; httpRoutePath != nil {
mHttpRoutePath := map[string]interface{}{
"exact": aws.StringValue(httpRoutePath.Exact),
"regex": aws.StringValue(httpRoutePath.Regex),
}

vHttpRoutePath = []interface{}{mHttpRoutePath}
}

vHttpRouteQueryParameters := []interface{}{}

for _, httpRouteQueryParameter := range httpRouteMatch.QueryParameters {
mHttpRouteQueryParameter := map[string]interface{}{
"name": aws.StringValue(httpRouteQueryParameter.Name),
}

if match := httpRouteQueryParameter.Match; match != nil {
mMatch := map[string]interface{}{
"exact": aws.StringValue(match.Exact),
}

mHttpRouteQueryParameter["match"] = []interface{}{mMatch}
}

vHttpRouteQueryParameters = append(vHttpRouteQueryParameters, mHttpRouteQueryParameter)
}

mHttpRoute["match"] = []interface{}{
map[string]interface{}{
"header": vHttpRouteHeaders,
"method": aws.StringValue(httpRouteMatch.Method),
"prefix": aws.StringValue(httpRouteMatch.Prefix),
"scheme": aws.StringValue(httpRouteMatch.Scheme),
"port": int(aws.Int64Value(httpRouteMatch.Port)),
"header": vHttpRouteHeaders,
"method": aws.StringValue(httpRouteMatch.Method),
"path": vHttpRoutePath,
"port": int(aws.Int64Value(httpRouteMatch.Port)),
"prefix": aws.StringValue(httpRouteMatch.Prefix),
"query_parameter": vHttpRouteQueryParameters,
"scheme": aws.StringValue(httpRouteMatch.Scheme),
},
}
}
Expand Down Expand Up @@ -1804,7 +1885,9 @@ func flattenVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} {
if dns := serviceDiscovery.Dns; dns != nil {
mServiceDiscovery["dns"] = []interface{}{
map[string]interface{}{
"hostname": aws.StringValue(dns.Hostname),
"hostname": aws.StringValue(dns.Hostname),
"ip_preference": aws.StringValue(dns.IpPreference),
"response_type": aws.StringValue(dns.ResponseType),
},
}
}
Expand Down
Loading

0 comments on commit bfa0aa5

Please sign in to comment.