diff --git a/kubernetes/resource_kubernetes_pod.go b/kubernetes/resource_kubernetes_pod.go index 80403a1454..76bc164fc4 100644 --- a/kubernetes/resource_kubernetes_pod.go +++ b/kubernetes/resource_kubernetes_pod.go @@ -24,6 +24,12 @@ func resourceKubernetesPod() *schema.Resource { Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "metadata": namespacedMetadataSchema("pod", true), "spec": { @@ -67,7 +73,7 @@ func resourceKubernetesPodCreate(d *schema.ResourceData, meta interface{}) error stateConf := &resource.StateChangeConf{ Target: []string{"Running"}, Pending: []string{"Pending"}, - Timeout: 5 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Refresh: func() (interface{}, string, error) { out, err := conn.CoreV1().Pods(metadata.Namespace).Get(metadata.Name, metav1.GetOptions{}) if err != nil { @@ -174,7 +180,7 @@ func resourceKubernetesPodDelete(d *schema.ResourceData, meta interface{}) error return err } - err = resource.Retry(5*time.Minute, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { out, err := conn.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) if err != nil { if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 { diff --git a/website/docs/r/pod.html.markdown b/website/docs/r/pod.html.markdown index a349874d97..96999f7b92 100644 --- a/website/docs/r/pod.html.markdown +++ b/website/docs/r/pod.html.markdown @@ -48,6 +48,14 @@ The following arguments are supported: * `name` - (Optional) Name of the pod, must be unique. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names * `namespace` - (Optional) Namespace defines the space within which name of the pod must be unique. +### Timeouts + +`kubernetes_pod` provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - (Default `5 minutes`) Used for Creating Pods. +- `delete` - (Default `5 minutes`) Used for Destroying Pods. + #### Attributes * `generation` - A sequence number representing a specific generation of the desired state.