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

d/aws_api_gateway_api_key - add attributes #10821

Merged
merged 7 commits into from
Jan 18, 2020
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
29 changes: 29 additions & 0 deletions aws/data_source_aws_api_gateway_api_key.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package aws

import (
"fmt"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsApiGatewayApiKey() *schema.Resource {
Expand All @@ -18,11 +22,28 @@ func dataSourceAwsApiGatewayApiKey() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
"last_updated_date": {
Type: schema.TypeString,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"value": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
"tags": tagsSchemaComputed(),
},
}
}
Expand All @@ -41,5 +62,13 @@ func dataSourceAwsApiGatewayApiKeyRead(d *schema.ResourceData, meta interface{})
d.SetId(aws.StringValue(apiKey.Id))
d.Set("name", apiKey.Name)
d.Set("value", apiKey.Value)
d.Set("created_date", aws.TimeValue(apiKey.CreatedDate).Format(time.RFC3339))
d.Set("description", apiKey.Description)
d.Set("enabled", apiKey.Enabled)
d.Set("last_updated_date", aws.TimeValue(apiKey.LastUpdatedDate).Format(time.RFC3339))

if err := d.Set("tags", keyvaluetags.ApigatewayKeyValueTags(apiKey.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
return nil
}
5 changes: 5 additions & 0 deletions aws/data_source_aws_api_gateway_api_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func TestAccDataSourceAwsApiGatewayApiKey(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName1, "id", dataSourceName1, "id"),
resource.TestCheckResourceAttrPair(resourceName1, "name", dataSourceName1, "name"),
resource.TestCheckResourceAttrPair(resourceName1, "value", dataSourceName1, "value"),
resource.TestCheckResourceAttrPair(resourceName1, "enabled", dataSourceName1, "enabled"),
resource.TestCheckResourceAttrPair(resourceName1, "description", dataSourceName1, "description"),
resource.TestCheckResourceAttrSet(dataSourceName1, "last_updated_date"),
resource.TestCheckResourceAttrSet(dataSourceName1, "created_date"),
resource.TestCheckResourceAttr(dataSourceName1, "tags.%", "0"),
),
},
},
Expand Down
5 changes: 5 additions & 0 deletions website/docs/d/api_gateway_api_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ data "aws_api_gateway_api_key" "my_api_key" {
* `id` - Set to the ID of the API Key.
* `name` - Set to the name of the API Key.
* `value` - Set to the value of the API Key.
* `created_date` - The date and time when the API Key was created.
* `last_updated_date` - The date and time when the API Key was last updated.
* `description` - The description of the API Key.
* `enabled` - Specifies whether the API Key is enabled.
* `tags` - A mapping of tags for the resource.