Skip to content

Commit

Permalink
data-source/aws_eks_cluster: Add tags attribute
Browse files Browse the repository at this point in the history
Reference: #10127

Output from acceptance testing:

```
--- PASS: TestAccAWSEksClusterDataSource_basic (1278.07s)
```
  • Loading branch information
bflad committed Sep 30, 2019
1 parent 6a19b22 commit 052093c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aws/data_source_aws_eks_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/eks"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsEksCluster() *schema.Resource {
Expand Down Expand Up @@ -84,6 +85,7 @@ func dataSourceAwsEksCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchemaComputed(),
"vpc_config": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -163,6 +165,11 @@ func dataSourceAwsEksClusterRead(d *schema.ResourceData, meta interface{}) error
d.Set("platform_version", cluster.PlatformVersion)
d.Set("role_arn", cluster.RoleArn)
d.Set("status", cluster.Status)

if err := d.Set("tags", keyvaluetags.EksKeyValueTags(cluster.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

d.Set("version", cluster.Version)

if err := d.Set("vpc_config", flattenEksVpcConfigResponse(cluster.ResourcesVpcConfig)); err != nil {
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_eks_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestAccAWSEksClusterDataSource_basic(t *testing.T) {
resource.TestMatchResourceAttr(dataSourceResourceName, "platform_version", regexp.MustCompile(`^eks\.\d+$`)),
resource.TestCheckResourceAttrPair(resourceName, "role_arn", dataSourceResourceName, "role_arn"),
resource.TestCheckResourceAttrPair(resourceName, "status", dataSourceResourceName, "status"),
resource.TestCheckResourceAttrPair(resourceName, "tags.%", dataSourceResourceName, "tags.%"),
resource.TestCheckResourceAttrPair(resourceName, "version", dataSourceResourceName, "version"),
resource.TestCheckResourceAttr(dataSourceResourceName, "vpc_config.#", "1"),
resource.TestCheckResourceAttrPair(resourceName, "vpc_config.0.endpoint_private_access", dataSourceResourceName, "vpc_config.0.endpoint_private_access"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/eks_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ output "identity-oidc-issuer" {
* `platform_version` - The platform version for the cluster.
* `role_arn` - The Amazon Resource Name (ARN) of the IAM role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf.
* `status` - The status of the EKS cluster. One of `CREATING`, `ACTIVE`, `DELETING`, `FAILED`.
* `tags` - Key-value mapping of resource tags.
* `version` - The Kubernetes server version for the cluster.
* `vpc_config` - Nested attribute containing VPC configuration for the cluster.
* `endpoint_private_access` - Indicates whether or not the Amazon EKS private API server endpoint is enabled.
Expand Down

0 comments on commit 052093c

Please sign in to comment.