Skip to content

Commit

Permalink
r/aws_appmesh_route: Comment out tagging support temporarily.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Ewbank authored and Kit Ewbank committed Jul 24, 2019
1 parent 0a7dddc commit a9d7125
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 105 deletions.
41 changes: 22 additions & 19 deletions aws/resource_aws_appmesh_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ 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: tagsFromMapAppmesh(d.Get("tags").(map[string]interface{})),
// TODO Reinstate AppMesh tagging support.
// Tags: tagsFromMapAppmesh(d.Get("tags").(map[string]interface{})),
}

log.Printf("[DEBUG] Creating App Mesh route: %#v", req)
Expand Down Expand Up @@ -236,15 +237,16 @@ func resourceAwsAppmeshRouteRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error setting spec: %s", err)
}

err = saveTagsAppmesh(conn, d, aws.StringValue(resp.Route.Metadata.Arn))
if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
log.Printf("[WARN] App Mesh route (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
if err != nil {
return fmt.Errorf("error saving tags: %s", err)
}
// TODO Reinstate AppMesh tagging support.
// err = saveTagsAppmesh(conn, d, aws.StringValue(resp.Route.Metadata.Arn))
// if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
// log.Printf("[WARN] App Mesh route (%s) not found, removing from state", d.Id())
// d.SetId("")
// return nil
// }
// if err != nil {
// return fmt.Errorf("error saving tags: %s", err)
// }

return nil
}
Expand All @@ -268,15 +270,16 @@ func resourceAwsAppmeshRouteUpdate(d *schema.ResourceData, meta interface{}) err
}
}

err := setTagsAppmesh(conn, d, d.Get("arn").(string))
if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
log.Printf("[WARN] App Mesh route (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
if err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
// TODO Reinstate AppMesh tagging support.
// err := setTagsAppmesh(conn, d, d.Get("arn").(string))
// if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
// log.Printf("[WARN] App Mesh route (%s) not found, removing from state", d.Id())
// d.SetId("")
// return nil
// }
// if err != nil {
// return fmt.Errorf("error setting tags: %s", err)
// }

return resourceAwsAppmeshRouteRead(d, meta)
}
Expand Down
172 changes: 87 additions & 85 deletions aws/resource_aws_appmesh_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,61 +216,62 @@ func testAccAwsAppmeshRoute_tcpRoute(t *testing.T) {
})
}

func testAccAwsAppmeshRoute_tags(t *testing.T) {
var r appmesh.RouteData
resourceName := "aws_appmesh_route.foo"
meshName := fmt.Sprintf("tf-test-mesh-%d", acctest.RandInt())
vrName := fmt.Sprintf("tf-test-router-%d", acctest.RandInt())
vn1Name := fmt.Sprintf("tf-test-node-%d", acctest.RandInt())
vn2Name := fmt.Sprintf("tf-test-node-%d", acctest.RandInt())
rName := fmt.Sprintf("tf-test-route-%d", acctest.RandInt())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAppmeshRouteDestroy,
Steps: []resource.TestStep{
{
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"),
),
},
{
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"),
),
},
{
Config: testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAppmeshRouteExists(resourceName, &r),
resource.TestCheckResourceAttr(
resourceName, "tags.%", "0"),
),
},
{
ResourceName: resourceName,
ImportStateId: fmt.Sprintf("%s/%s/%s", meshName, vrName, rName),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
// TODO Reinstate AppMesh tagging support.
// func testAccAwsAppmeshRoute_tags(t *testing.T) {
// var r appmesh.RouteData
// resourceName := "aws_appmesh_route.foo"
// meshName := fmt.Sprintf("tf-test-mesh-%d", acctest.RandInt())
// vrName := fmt.Sprintf("tf-test-router-%d", acctest.RandInt())
// vn1Name := fmt.Sprintf("tf-test-node-%d", acctest.RandInt())
// vn2Name := fmt.Sprintf("tf-test-node-%d", acctest.RandInt())
// rName := fmt.Sprintf("tf-test-route-%d", acctest.RandInt())

// resource.Test(t, resource.TestCase{
// PreCheck: func() { testAccPreCheck(t) },
// Providers: testAccProviders,
// CheckDestroy: testAccCheckAppmeshRouteDestroy,
// Steps: []resource.TestStep{
// {
// 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"),
// ),
// },
// {
// 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"),
// ),
// },
// {
// Config: testAccAppmeshRouteConfig_httpRoute(meshName, vrName, vn1Name, vn2Name, rName),
// Check: resource.ComposeTestCheckFunc(
// testAccCheckAppmeshRouteExists(resourceName, &r),
// resource.TestCheckResourceAttr(
// resourceName, "tags.%", "0"),
// ),
// },
// {
// ResourceName: resourceName,
// ImportStateId: fmt.Sprintf("%s/%s/%s", meshName, vrName, rName),
// ImportState: true,
// ImportStateVerify: true,
// },
// },
// })
// }

func testAccCheckAppmeshRouteDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).appmeshconn
Expand Down Expand Up @@ -466,33 +467,34 @@ resource "aws_appmesh_route" "foo" {
`, 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" "foo" {
name = %[1]q
mesh_name = "${aws_appmesh_mesh.foo.id}"
virtual_router_name = "${aws_appmesh_virtual_router.foo.name}"
spec {
http_route {
match {
prefix = "/"
}
action {
weighted_target {
virtual_node = "${aws_appmesh_virtual_node.foo.name}"
weight = 100
}
}
}
}
tags = {
%[2]s = %[3]q
%[4]s = %[5]q
}
}
`, rName, tagKey1, tagValue1, tagKey2, tagValue2)
}
// TODO Reinstate AppMesh tagging support.
// 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" "foo" {
// name = %[1]q
// mesh_name = "${aws_appmesh_mesh.foo.id}"
// virtual_router_name = "${aws_appmesh_virtual_router.foo.name}"

// spec {
// http_route {
// match {
// prefix = "/"
// }

// action {
// weighted_target {
// virtual_node = "${aws_appmesh_virtual_node.foo.name}"
// weight = 100
// }
// }
// }
// }

// tags = {
// %[2]s = %[3]q
// %[4]s = %[5]q
// }
// }
// `, rName, tagKey1, tagValue1, tagKey2, tagValue2)
// }
3 changes: 2 additions & 1 deletion aws/resource_aws_appmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ func TestAccAWSAppmesh(t *testing.T) {
"Route": {
"httpRoute": testAccAwsAppmeshRoute_httpRoute,
"tcpRoute": testAccAwsAppmeshRoute_tcpRoute,
"tags": testAccAwsAppmeshRoute_tags,
// TODO Reinstate AppMesh tagging support.
// "tags": testAccAwsAppmeshRoute_tags,
},
"VirtualNode": {
"basic": testAccAwsAppmeshVirtualNode_basic,
Expand Down

0 comments on commit a9d7125

Please sign in to comment.