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

r/aws_ecs_cluster: Add arn attribute #2552

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion aws/resource_aws_ecs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ func resourceAwsEcsCluster() *schema.Resource {
Delete: resourceAwsEcsClusterDelete,

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"arn": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand All @@ -43,6 +48,7 @@ func resourceAwsEcsClusterCreate(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG] ECS cluster %s created", *out.Cluster.ClusterArn)

d.SetId(*out.Cluster.ClusterArn)
d.Set("arn", out.Cluster.ClusterArn)
d.Set("name", out.Cluster.ClusterName)
return nil
}
Expand Down Expand Up @@ -70,6 +76,7 @@ func resourceAwsEcsClusterRead(d *schema.ResourceData, meta interface{}) error {
}

d.SetId(*c.ClusterArn)
d.Set("arn", c.ClusterArn)
d.Set("name", c.ClusterName)
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions aws/resource_aws_ecs_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -20,6 +21,8 @@ func TestAccAWSEcsCluster_basic(t *testing.T) {
Config: testAccAWSEcsCluster,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEcsClusterExists("aws_ecs_cluster.foo"),
resource.TestMatchResourceAttr("aws_ecs_cluster.foo", "arn",
regexp.MustCompile("^arn:aws:ecs:[a-z0-9-]+:[0-9]{12}:cluster/red-grapes$")),
),
},
},
Expand Down
6 changes: 3 additions & 3 deletions website/docs/r/ecs_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |-
Provides an ECS cluster.
---

# aws\_ecs\_cluster
# aws_ecs_cluster

Provides an ECS cluster.

Expand All @@ -26,7 +26,7 @@ The following arguments are supported:

## Attributes Reference

The following attributes are exported:
The following additional attributes are exported:

* `name` - The name of the cluster
* `id` - The Amazon Resource Name (ARN) that identifies the cluster
* `arn` - The Amazon Resource Name (ARN) that identifies the cluster