diff --git a/builtin/providers/aws/resource_aws_api_gateway_api_key.go b/builtin/providers/aws/resource_aws_api_gateway_api_key.go index 7ddd790874..fe606a5e0b 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_api_key.go +++ b/builtin/providers/aws/resource_aws_api_gateway_api_key.go @@ -23,41 +23,51 @@ func resourceAwsApiGatewayApiKey() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "description": &schema.Schema{ + "description": { Type: schema.TypeString, Optional: true, Default: "Managed by Terraform", }, - "enabled": &schema.Schema{ + "enabled": { Type: schema.TypeBool, Optional: true, Default: true, }, - "stage_key": &schema.Schema{ + "stage_key": { Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "rest_api_id": &schema.Schema{ + "rest_api_id": { Type: schema.TypeString, Required: true, }, - "stage_name": &schema.Schema{ + "stage_name": { Type: schema.TypeString, Required: true, }, }, }, }, + + "created_date": { + Type: schema.TypeString, + Computed: true, + }, + + "last_updated_date": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -102,6 +112,14 @@ func resourceAwsApiGatewayApiKeyRead(d *schema.ResourceData, meta interface{}) e d.Set("enabled", apiKey.Enabled) d.Set("stage_key", flattenApiGatewayStageKeys(apiKey.StageKeys)) + if err := d.Set("created_date", apiKey.CreatedDate.Format(time.RFC3339)); err != nil { + log.Printf("[DEBUG] Error setting created_date: %s", err) + } + + if err := d.Set("last_updated_date", apiKey.LastUpdatedDate.Format(time.RFC3339)); err != nil { + log.Printf("[DEBUG] Error setting last_updated_date: %s", err) + } + return nil } diff --git a/builtin/providers/aws/resource_aws_api_gateway_api_key_test.go b/builtin/providers/aws/resource_aws_api_gateway_api_key_test.go index b63e8b667d..cafb890ea4 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_api_key_test.go +++ b/builtin/providers/aws/resource_aws_api_gateway_api_key_test.go @@ -20,7 +20,7 @@ func TestAccAWSAPIGatewayApiKey_basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSAPIGatewayApiKeyDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSAPIGatewayApiKeyConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSAPIGatewayApiKeyExists("aws_api_gateway_api_key.test", &conf), @@ -29,6 +29,10 @@ func TestAccAWSAPIGatewayApiKey_basic(t *testing.T) { "aws_api_gateway_api_key.test", "name", "foo"), resource.TestCheckResourceAttr( "aws_api_gateway_api_key.test", "description", "Managed by Terraform"), + resource.TestCheckResourceAttrSet( + "aws_api_gateway_api_key.test", "created_date"), + resource.TestCheckResourceAttrSet( + "aws_api_gateway_api_key.test", "last_updated_date"), ), }, }, diff --git a/website/source/docs/providers/aws/r/api_gateway_api_key.html.markdown b/website/source/docs/providers/aws/r/api_gateway_api_key.html.markdown index eeb8f14c72..92d583a9ef 100644 --- a/website/source/docs/providers/aws/r/api_gateway_api_key.html.markdown +++ b/website/source/docs/providers/aws/r/api_gateway_api_key.html.markdown @@ -51,6 +51,8 @@ The following arguments are supported: The following attributes are exported: * `id` - The ID of the API key +* `created_date` - The creation date of the API key +* `last_updated_date` - The last update date of the API key ## Import @@ -59,4 +61,4 @@ API Gateway Keys can be imported using the `id`, e.g. ``` $ terraform import aws_api_gateway_api_key.my_demo_key 8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk -``` \ No newline at end of file +```