Exposed AWS API GW REST Api created_date attribute (#9532)
This commit is contained in:
commit
24231333d3
|
@ -20,17 +20,22 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
|
||||||
Delete: resourceAwsApiGatewayRestApiDelete,
|
Delete: resourceAwsApiGatewayRestApiDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"description": &schema.Schema{
|
"description": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"root_resource_id": &schema.Schema{
|
"root_resource_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"created_date": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
@ -56,7 +61,11 @@ func resourceAwsApiGatewayRestApiCreate(d *schema.ResourceData, meta interface{}
|
||||||
|
|
||||||
d.SetId(*gateway.Id)
|
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 {
|
func resourceAwsApiGatewayRestApiRefreshResources(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
@ -94,10 +103,13 @@ func resourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(*api.Id)
|
|
||||||
d.Set("name", api.Name)
|
d.Set("name", api.Name)
|
||||||
d.Set("description", api.Description)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ func TestAccAWSAPIGatewayRestApi_basic(t *testing.T) {
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSAPIGatewayRestAPIDestroy,
|
CheckDestroy: testAccCheckAWSAPIGatewayRestAPIDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSAPIGatewayRestAPIConfig,
|
Config: testAccAWSAPIGatewayRestAPIConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSAPIGatewayRestAPIExists("aws_api_gateway_rest_api.test", &conf),
|
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"),
|
"aws_api_gateway_rest_api.test", "name", "bar"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_api_gateway_rest_api.test", "description", ""),
|
"aws_api_gateway_rest_api.test", "description", ""),
|
||||||
|
resource.TestCheckResourceAttrSet(
|
||||||
|
"aws_api_gateway_rest_api.test", "created_date"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSAPIGatewayRestAPIUpdateConfig,
|
Config: testAccAWSAPIGatewayRestAPIUpdateConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSAPIGatewayRestAPIExists("aws_api_gateway_rest_api.test", &conf),
|
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"),
|
"aws_api_gateway_rest_api.test", "name", "test"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_api_gateway_rest_api.test", "description", "test"),
|
"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
|
* `id` - The ID of the REST API
|
||||||
* `root_resource_id` - The resource ID of the REST API's root
|
* `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