diff --git a/docs/resources/virtual_environment_container.md b/docs/resources/virtual_environment_container.md index ba3ba302..f4398fd2 100644 --- a/docs/resources/virtual_environment_container.md +++ b/docs/resources/virtual_environment_container.md @@ -214,6 +214,7 @@ output "ubuntu_container_public_key" { difference on the resource. You may use the `ignore_changes` lifecycle meta-argument to ignore changes to this attribute. - `template` - (Optional) Whether to create a template (defaults to `false`). +- `timeout_create` - (Optional) Timeout for creating a container in seconds (defaults to 1800). - `unprivileged` - (Optional) Whether the container runs as unprivileged on the host (defaults to `false`). - `vm_id` - (Optional) The container identifier diff --git a/proxmoxtf/resource/container/container.go b/proxmoxtf/resource/container/container.go index ac28ee81..59e2454a 100644 --- a/proxmoxtf/resource/container/container.go +++ b/proxmoxtf/resource/container/container.go @@ -75,6 +75,7 @@ const ( dvStartupDownDelay = -1 dvStartOnBoot = true dvTemplate = false + dvTimeoutCreate = 1800 dvUnprivileged = false dvVMID = -1 @@ -154,6 +155,7 @@ const ( mkStartOnBoot = "start_on_boot" mkTags = "tags" mkTemplate = "template" + mkTimeoutCreate = "timeout_create" mkUnprivileged = "unprivileged" mkVMID = "vm_id" ) @@ -834,6 +836,12 @@ func Container() *schema.Resource { ForceNew: true, Default: dvTemplate, }, + mkTimeoutCreate: { + Type: schema.TypeInt, + Description: "Create container timeout", + Optional: true, + Default: dvTimeoutCreate, + }, mkUnprivileged: { Type: schema.TypeBool, Description: "Whether the container runs as unprivileged on the host", @@ -1721,8 +1729,10 @@ func containerCreateStart(ctx context.Context, d *schema.ResourceData, m interfa containerAPI := api.Node(nodeName).Container(vmID) + createTimeout := d.Get(mkTimeoutCreate).(int) + // Start the container and wait for it to reach a running state before continuing. - err = containerAPI.StartContainer(ctx, 60) + err = containerAPI.StartContainer(ctx, createTimeout) if err != nil { return diag.FromErr(err) }