Exposed AWS API GW REST Api created_date attribute
This commit is contained in:
parent
ab03a50d92
commit
a88b25cfcf
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue