Skip to content

Commit

Permalink
Exposed aws_api_gateway_deployment.created_date attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninir committed Nov 14, 2016
1 parent 1658055 commit 6fb63f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
22 changes: 15 additions & 7 deletions builtin/providers/aws/resource_aws_api_gateway_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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"),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6fb63f2

Please sign in to comment.