Exposed AWS API GW REST Api created_date attribute (#9532)

This commit is contained in:
Paul Stack 2016-11-14 12:09:28 +00:00 committed by GitHub
commit 24231333d3
3 changed files with 24 additions and 7 deletions

View File

@ -20,17 +20,22 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
Delete: resourceAwsApiGatewayRestApiDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"description": &schema.Schema{
"description": {
Type: schema.TypeString,
Optional: true,
},
"root_resource_id": &schema.Schema{
"root_resource_id": {
Type: schema.TypeString,
Computed: true,
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
@ -56,7 +61,11 @@ func resourceAwsApiGatewayRestApiCreate(d *schema.ResourceData, meta interface{}
d.SetId(*gateway.Id)
return resourceAwsApiGatewayRestApiRefreshResources(d, meta)
if err = resourceAwsApiGatewayRestApiRefreshResources(d, meta); err != nil {
return err
}
return resourceAwsApiGatewayRestApiRead(d, meta)
}
func resourceAwsApiGatewayRestApiRefreshResources(d *schema.ResourceData, meta interface{}) error {
@ -94,10 +103,13 @@ func resourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{})
return err
}
d.SetId(*api.Id)
d.Set("name", api.Name)
d.Set("description", api.Description)
if err := d.Set("created_date", api.CreatedDate.Format(time.RFC3339)); err != nil {
log.Printf("[DEBUG] Error setting created_date: %s", err)
}
return nil
}

View File

@ -18,7 +18,7 @@ func TestAccAWSAPIGatewayRestApi_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayRestAPIDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccAWSAPIGatewayRestAPIConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayRestAPIExists("aws_api_gateway_rest_api.test", &conf),
@ -27,10 +27,12 @@ func TestAccAWSAPIGatewayRestApi_basic(t *testing.T) {
"aws_api_gateway_rest_api.test", "name", "bar"),
resource.TestCheckResourceAttr(
"aws_api_gateway_rest_api.test", "description", ""),
resource.TestCheckResourceAttrSet(
"aws_api_gateway_rest_api.test", "created_date"),
),
},
resource.TestStep{
{
Config: testAccAWSAPIGatewayRestAPIUpdateConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayRestAPIExists("aws_api_gateway_rest_api.test", &conf),
@ -40,6 +42,8 @@ func TestAccAWSAPIGatewayRestApi_basic(t *testing.T) {
"aws_api_gateway_rest_api.test", "name", "test"),
resource.TestCheckResourceAttr(
"aws_api_gateway_rest_api.test", "description", "test"),
resource.TestCheckResourceAttrSet(
"aws_api_gateway_rest_api.test", "created_date"),
),
},
},

View File

@ -32,3 +32,4 @@ The following attributes are exported:
* `id` - The ID of the REST API
* `root_resource_id` - The resource ID of the REST API's root
* `created_date` - The creation date of the REST API