Skip to content

Commit

Permalink
r/aws_appmesh_virtual_node: Initial support for end-to-end encryption.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Sep 8, 2019
1 parent 004331f commit 8e9c081
Show file tree
Hide file tree
Showing 5 changed files with 502 additions and 158 deletions.
86 changes: 47 additions & 39 deletions aws/resource_aws_appmesh_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) {
Config: testAccAwsAppmeshRouteConfig_httpRoute(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -127,18 +129,19 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) {
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.tcp_route.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Config: testAccAwsAppmeshRouteConfig_httpRouteUpdated(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -150,9 +153,8 @@ func testAccAwsAppmeshRoute_httpRoute(t *testing.T) {
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.tcp_route.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Expand All @@ -179,9 +181,11 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) {
Config: testAccAwsAppmeshRouteConfig_httpHeader(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -196,18 +200,19 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) {
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.tcp_route.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Config: testAccAwsAppmeshRouteConfig_httpHeaderUpdated(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -232,9 +237,8 @@ func testAccAwsAppmeshRoute_httpHeader(t *testing.T) {
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.tcp_route.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Expand All @@ -261,9 +265,11 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) {
Config: testAccAwsAppmeshRouteConfig_httpRetryPolicy(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -280,18 +286,19 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.per_retry_timeout_millis", "15000"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.retry_policy.0.tcp_retry_events.#", "0"),
resource.TestCheckResourceAttr(resourceName, "spec.0.tcp_route.#", "0"),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Config: testAccAwsAppmeshRouteConfig_httpRetryPolicyUpdated(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
resource.TestCheckResourceAttr(resourceName, "mesh_name", rName),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "spec.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.#", "1"),
resource.TestCheckResourceAttr(resourceName, "spec.0.http_route.0.action.#", "1"),
Expand All @@ -310,9 +317,8 @@ func testAccAwsAppmeshRoute_httpRetryPolicy(t *testing.T) {
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.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "last_updated_date"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appmesh-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtual_router_name", rName),
),
},
{
Expand Down Expand Up @@ -347,6 +353,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-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
Expand All @@ -364,6 +371,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-preview", fmt.Sprintf("mesh/%s/virtualRouter/%s/route/%s", rName, rName, rName)),
Expand Down Expand Up @@ -498,7 +506,7 @@ func testAccAwsAppmeshRouteImportStateIdFunc(resourceName string) resource.Impor
}
}

func testAccAwsAppmeshRouteConfigBase(rName string) string {
func testAccAwsAppmeshRouteConfig_base(rName string) string {
return fmt.Sprintf(`
resource "aws_appmesh_mesh" "test" {
name = %[1]q
Expand Down Expand Up @@ -530,7 +538,7 @@ resource "aws_appmesh_virtual_node" "test" {
}

func testAccAwsAppmeshRouteConfig_httpRoute(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand All @@ -555,7 +563,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_httpRouteUpdated(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down Expand Up @@ -585,7 +593,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_httpHeader(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down Expand Up @@ -616,7 +624,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_httpHeaderUpdated(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down Expand Up @@ -659,7 +667,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_httpRetryPolicy(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down Expand Up @@ -690,7 +698,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_httpRetryPolicyUpdated(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down Expand Up @@ -729,7 +737,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_tcpRoute(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand All @@ -750,7 +758,7 @@ resource "aws_appmesh_route" "test" {
}

func testAccAwsAppmeshRouteConfig_tcpRouteUpdated(rName string) string {
return testAccAwsAppmeshRouteConfigBase(rName) + fmt.Sprintf(`
return testAccAwsAppmeshRouteConfig_base(rName) + fmt.Sprintf(`
resource "aws_appmesh_route" "test" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.test.id}"
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_appmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestAccAWSAppmesh(t *testing.T) {
"basic": testAccAwsAppmeshVirtualNode_basic,
"cloudMapServiceDiscovery": testAccAwsAppmeshVirtualNode_cloudMapServiceDiscovery,
"listenerHealthChecks": testAccAwsAppmeshVirtualNode_listenerHealthChecks,
"listenerTls": testAccAwsAppmeshVirtualNode_listenerTls,
"logging": testAccAwsAppmeshVirtualNode_logging,
// "tags": testAccAwsAppmeshVirtualNode_tags,
},
Expand Down
Loading

0 comments on commit 8e9c081

Please sign in to comment.