From 6fb63f2854947ea2bcd9926b66202fbe38c921c3 Mon Sep 17 00:00:00 2001 From: Ninir Date: Sun, 23 Oct 2016 15:40:21 +0200 Subject: [PATCH] Exposed aws_api_gateway_deployment.created_date attribute --- .../resource_aws_api_gateway_deployment.go | 22 +++++++++++++------ ...esource_aws_api_gateway_deployment_test.go | 4 +++- .../r/api_gateway_deployment.html.markdown | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/resource_aws_api_gateway_deployment.go b/builtin/providers/aws/resource_aws_api_gateway_deployment.go index 4089999a9..494776288 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_deployment.go +++ b/builtin/providers/aws/resource_aws_api_gateway_deployment.go @@ -20,35 +20,40 @@ func resourceAwsApiGatewayDeployment() *schema.Resource { Delete: resourceAwsApiGatewayDeploymentDelete, Schema: map[string]*schema.Schema{ - "rest_api_id": &schema.Schema{ + "rest_api_id": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "stage_name": &schema.Schema{ + "stage_name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "description": &schema.Schema{ + "description": { Type: schema.TypeString, Optional: true, }, - "stage_description": &schema.Schema{ + "stage_description": { Type: schema.TypeString, Optional: true, ForceNew: true, }, - "variables": &schema.Schema{ + "variables": { Type: schema.TypeMap, Optional: true, ForceNew: true, Elem: schema.TypeString, }, + + "created_date": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -78,7 +83,7 @@ func resourceAwsApiGatewayDeploymentCreate(d *schema.ResourceData, meta interfac d.SetId(*deployment.Id) log.Printf("[DEBUG] API Gateway Deployment ID: %s", d.Id()) - return nil + return resourceAwsApiGatewayDeploymentRead(d, meta) } func resourceAwsApiGatewayDeploymentRead(d *schema.ResourceData, meta interface{}) error { @@ -97,9 +102,12 @@ func resourceAwsApiGatewayDeploymentRead(d *schema.ResourceData, meta interface{ return err } log.Printf("[DEBUG] Received API Gateway Deployment: %s", out) - d.SetId(*out.Id) d.Set("description", out.Description) + if err := d.Set("created_date", out.CreatedDate.Format(time.RFC3339)); err != nil { + log.Printf("[DEBUG] Error setting created_date: %s", err) + } + return nil } diff --git a/builtin/providers/aws/resource_aws_api_gateway_deployment_test.go b/builtin/providers/aws/resource_aws_api_gateway_deployment_test.go index 9da846e51..7cf58a4e4 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_deployment_test.go +++ b/builtin/providers/aws/resource_aws_api_gateway_deployment_test.go @@ -19,7 +19,7 @@ func TestAccAWSAPIGatewayDeployment_basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSAPIGatewayDeploymentDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSAPIGatewayDeploymentConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSAPIGatewayDeploymentExists("aws_api_gateway_deployment.test", &conf), @@ -29,6 +29,8 @@ func TestAccAWSAPIGatewayDeployment_basic(t *testing.T) { "aws_api_gateway_deployment.test", "description", "This is a test"), resource.TestCheckResourceAttr( "aws_api_gateway_deployment.test", "variables.a", "2"), + resource.TestCheckResourceAttrSet( + "aws_api_gateway_deployment.test", "created_date"), ), }, }, diff --git a/website/source/docs/providers/aws/r/api_gateway_deployment.html.markdown b/website/source/docs/providers/aws/r/api_gateway_deployment.html.markdown index 9068a2d19..11a3c1a5a 100644 --- a/website/source/docs/providers/aws/r/api_gateway_deployment.html.markdown +++ b/website/source/docs/providers/aws/r/api_gateway_deployment.html.markdown @@ -68,3 +68,4 @@ The following arguments are supported: The following attributes are exported: * `id` - The ID of the deployment +* `created_date` - The creation date of the deployment