Skip to content

Commit

Permalink
resource/aws_eks_cluster: allow referencing arn attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Raza Jhaveri committed Jun 6, 2018
1 parent 59ea1c3 commit 90f2878
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aws/data_source_aws_eks_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func dataSourceAwsEksCluster() *schema.Resource {
ForceNew: true,
ValidateFunc: validation.NoZeroValues,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"role_arn": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -106,6 +110,7 @@ func dataSourceAwsEksClusterRead(d *schema.ResourceData, meta interface{}) error
d.Set("created_at", aws.TimeValue(cluster.CreatedAt).String())
d.Set("endpoint", cluster.Endpoint)
d.Set("name", cluster.Name)
d.Set("arn", cluster.Arn)
d.Set("role_arn", cluster.RoleArn)
d.Set("version", cluster.Version)

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 @@ -25,6 +25,7 @@ func TestAccAWSEksClusterDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "certificate_authority.0.data", dataSourceResourceName, "certificate_authority.0.data"),
resource.TestCheckResourceAttrPair(resourceName, "created_at", dataSourceResourceName, "created_at"),
resource.TestCheckResourceAttrPair(resourceName, "endpoint", dataSourceResourceName, "endpoint"),
resource.TestCheckResourceAttrPair(resourceName, "arn", dataSourceResourceName, "arn"),
resource.TestCheckResourceAttrPair(resourceName, "role_arn", dataSourceResourceName, "role_arn"),
resource.TestCheckResourceAttrPair(resourceName, "version", dataSourceResourceName, "version"),
resource.TestCheckResourceAttr(dataSourceResourceName, "vpc_config.#", "1"),
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_eks_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func resourceAwsEksCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -191,6 +195,7 @@ func resourceAwsEksClusterRead(d *schema.ResourceData, meta interface{}) error {
d.Set("created_at", aws.TimeValue(cluster.CreatedAt).String())
d.Set("endpoint", cluster.Endpoint)
d.Set("name", cluster.Name)
d.Set("arn", cluster.Arn)
d.Set("role_arn", cluster.RoleArn)
d.Set("version", cluster.Version)

Expand Down
2 changes: 2 additions & 0 deletions aws/resource_aws_eks_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func TestAccAWSEksCluster_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "certificate_authority.0.data"),
resource.TestMatchResourceAttr(resourceName, "endpoint", regexp.MustCompile(`^https://`)),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestMatchResourceAttr(resourceName, "arn", regexp.MustCompile(
"^arn:aws:eks:[^:]+:[0-9]+:cluster/"+rName+"$")),
resource.TestMatchResourceAttr(resourceName, "role_arn", regexp.MustCompile(fmt.Sprintf("%s$", rName))),
resource.TestMatchResourceAttr(resourceName, "version", regexp.MustCompile(`^\d+\.\d+$`)),
resource.TestCheckResourceAttr(resourceName, "vpc_config.#", "1"),
Expand Down

0 comments on commit 90f2878

Please sign in to comment.