Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] App Mesh preview - HTTP header based routing, route priorities, cookie based routing and retry policy #9468

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7ea9d57
Include 07/2019 AppMesh preview channel from 'https://github.com/ewba…
Jul 23, 2019
174b9ab
Add 'appmeshpreview' service.
Jul 23, 2019
5313920
Move AppmeshRoute structure functions to resource file.
Jul 23, 2019
5cffd04
r/aws_appmesh_route: New attributes for HTTP header routing.
Jul 23, 2019
69f78ad
r/aws_appmesh_route: 'appmesh' -> 'appmeshpreview'.
Jul 23, 2019
0a7dddc
Revert "r/aws_appmesh_route: 'appmesh' -> 'appmeshpreview'."
Jul 24, 2019
a9d7125
r/aws_appmesh_route: Comment out tagging support temporarily.
Jul 24, 2019
dbbba1b
Revert "r/aws_appmesh_route: Comment out tagging support temporarily."
Jul 24, 2019
3b1a432
Move other Appmesh structure functions to resource files.
Jul 24, 2019
daa5a30
'appmesh' -> 'appmeshpreview'.
Jul 24, 2019
ed5042a
Tags not support on current AppMesh preview: 'BadRequestException: Re…
Jul 25, 2019
b72438e
'appmesh' -> 'appmesh-preview' in ARNs for acceptance tests.
Jul 25, 2019
816a62e
Remove AppMesh tagging code to pass lint checks.
Jul 25, 2019
965a982
r/aws_appmesh_route: Initial support for HTTP header routing.
Jul 25, 2019
b34cf1c
r/aws_appmesh_route: Acceptance tests for HTTP header routing.
ewbankkit Jul 26, 2019
7dc09b6
Include 082019 AppMesh preview channel from 'https://github.com/ewban…
ewbankkit Aug 2, 2019
f5baa08
Use SDK-provided constants for HTTP method names.
ewbankkit Aug 2, 2019
14a78aa
r/aws_appmesh_route: Initial support for retry policy.
ewbankkit Aug 3, 2019
c9c10f7
'per_retry_timeout' -> 'per_retry_timeout_millis' until the API corre…
ewbankkit Aug 9, 2019
cf4b1f5
r/aws_appmesh_route: Acceptance tests for retry policy.
ewbankkit Aug 9, 2019
085f67e
Update 082019 AppMesh preview channel from 'https://github.com/ewbank…
ewbankkit Aug 9, 2019
004331f
Attributes in alphabetical order.
ewbankkit Aug 9, 2019
8e9c081
r/aws_appmesh_virtual_node: Initial support for end-to-end encryption.
ewbankkit Aug 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"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/appsync"
"github.com/aws/aws-sdk-go/service/athena"
"github.com/aws/aws-sdk-go/service/autoscaling"
Expand Down Expand Up @@ -171,6 +172,7 @@ type AWSClient struct {
appautoscalingconn *applicationautoscaling.ApplicationAutoScaling
applicationinsightsconn *applicationinsights.ApplicationInsights
appmeshconn *appmesh.AppMesh
appmeshpreviewconn *appmeshpreview.AppMeshPreview
appsyncconn *appsync.AppSync
athenaconn *athena.Athena
autoscalingconn *autoscaling.AutoScaling
Expand Down Expand Up @@ -348,6 +350,7 @@ func (c *Config) Client() (interface{}, error) {
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"])})),
appmeshpreviewconn: appmeshpreview.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appmeshpreview"])})),
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"])})),
autoscalingconn: autoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["autoscaling"])})),
Expand Down
7 changes: 7 additions & 0 deletions aws/diff_suppress_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,10 @@ func suppressRoute53ZoneNameWithTrailingDot(k, old, new string, d *schema.Resour
}
return strings.TrimSuffix(old, ".") == strings.TrimSuffix(new, ".")
}

/*
// suppressStringsEqualFold suppresses any difference between two strings that are equal under Unicode case-folding.
func suppressStringsEqualFold(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(old, new)
}
*/
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ func init() {
"applicationautoscaling",
"applicationinsights",
"appmesh",
"appmeshpreview",
"appsync",
"athena",
"autoscaling",
Expand Down
88 changes: 64 additions & 24 deletions aws/resource_aws_appmesh_mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)
Expand Down Expand Up @@ -81,13 +81,13 @@ func resourceAwsAppmeshMesh() *schema.Resource {
}

func resourceAwsAppmeshMeshCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).appmeshconn
conn := meta.(*AWSClient).appmeshpreviewconn

meshName := d.Get("name").(string)
req := &appmesh.CreateMeshInput{
MeshName: aws.String(meshName),
Spec: expandAppmeshMeshSpec(d.Get("spec").([]interface{})),
Tags: tagsFromMapAppmesh(d.Get("tags").(map[string]interface{})),
// Tags: tagsFromMapAppmesh(d.Get("tags").(map[string]interface{})),
}

log.Printf("[DEBUG] Creating App Mesh service mesh: %#v", req)
Expand All @@ -102,7 +102,7 @@ func resourceAwsAppmeshMeshCreate(d *schema.ResourceData, meta interface{}) erro
}

func resourceAwsAppmeshMeshRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).appmeshconn
conn := meta.(*AWSClient).appmeshpreviewconn

resp, err := conn.DescribeMesh(&appmesh.DescribeMeshInput{
MeshName: aws.String(d.Id()),
Expand Down Expand Up @@ -130,21 +130,21 @@ func resourceAwsAppmeshMeshRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("error setting spec: %s", err)
}

err = saveTagsAppmesh(conn, d, aws.StringValue(resp.Mesh.Metadata.Arn))
if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
log.Printf("[WARN] App Mesh service mesh (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
if err != nil {
return fmt.Errorf("error saving tags: %s", err)
}
// err = saveTagsAppmesh(conn, d, aws.StringValue(resp.Mesh.Metadata.Arn))
// if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
// log.Printf("[WARN] App Mesh service mesh (%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
}

func resourceAwsAppmeshMeshUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).appmeshconn
conn := meta.(*AWSClient).appmeshpreviewconn

if d.HasChange("spec") {
_, v := d.GetChange("spec")
Expand All @@ -160,21 +160,21 @@ func resourceAwsAppmeshMeshUpdate(d *schema.ResourceData, meta interface{}) erro
}
}

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

return resourceAwsAppmeshMeshRead(d, meta)
}

func resourceAwsAppmeshMeshDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).appmeshconn
conn := meta.(*AWSClient).appmeshpreviewconn

log.Printf("[DEBUG] Deleting App Mesh service mesh: %s", d.Id())
_, err := conn.DeleteMesh(&appmesh.DeleteMeshInput{
Expand All @@ -189,3 +189,43 @@ func resourceAwsAppmeshMeshDelete(d *schema.ResourceData, meta interface{}) erro

return nil
}

func expandAppmeshMeshSpec(vSpec []interface{}) *appmesh.MeshSpec {
spec := &appmesh.MeshSpec{}

if len(vSpec) == 0 || vSpec[0] == nil {
// Empty Spec is allowed.
return spec
}
mSpec := vSpec[0].(map[string]interface{})

if vEgressFilter, ok := mSpec["egress_filter"].([]interface{}); ok && len(vEgressFilter) > 0 && vEgressFilter[0] != nil {
mEgressFilter := vEgressFilter[0].(map[string]interface{})

if vType, ok := mEgressFilter["type"].(string); ok && vType != "" {
spec.EgressFilter = &appmesh.EgressFilter{
Type: aws.String(vType),
}
}
}

return spec
}

func flattenAppmeshMeshSpec(spec *appmesh.MeshSpec) []interface{} {
if spec == nil {
return []interface{}{}
}

mSpec := map[string]interface{}{}

if spec.EgressFilter != nil {
mSpec["egress_filter"] = []interface{}{
map[string]interface{}{
"type": aws.StringValue(spec.EgressFilter.Type),
},
}
}

return []interface{}{mSpec}
}
Loading