AWS-EMR Cluster Creation

I have used Terraform to provision an EMR cluster with Master node, core nodes, and task nodes.
The cluster is successfully created in 10 -12 minutes.
But the terraform apply command was keeping running and after 30 minutes it got timed out.

The log was showing the
aws_emr_instance_group.emr-task[0]: Still creating… [29m40s elapsed]
aws_emr_instance_group.emr-task[0]: Still creating… [29m50s elapsed]
aws_emr_instance_group.emr-task[0]: Still creating… [30m0s elapsed] 2021-01-29T21:17:31.173Z [INFO] plugin.terraform-provider-aws_v3.26.0_x5: 2021/01/29 21:17:31 [WARN] WaitForState timeout after 30m0s: timestamp=2021-01-29T21:17:31.173Z 2021-01-29T21:17:31.174Z [INFO] plugin.terraform-provider-aws_v3.26.0_x5: 2021/01/29 21:17:31 [WARN] WaitForState starting 30s refresh grace period: timestamp=2021-01-29T21:17:31.173Z
aws_emr_instance_group.emr-task[0]: Still creating… [30m10s elapsed]
aws_emr_instance_group.emr-task[0]: Still creating… [30m20s elapsed]
aws_emr_instance_group.emr-task[0]: Still creating… [30m30s elapsed] 2021-01-29T21:18:01.174Z [INFO] plugin.terraform-provider-aws_v3.26.0_x5: 2021/01/29 21:18:01 [ERROR] WaitForState exceeded refresh grace period: timestamp=2021-01-29T21:18:01.174Z

Failed to save state: failed to upload state: ExpiredToken: The provided token has expired.
status code: 400, request id: E3FF726E22DCDBF9

resource “aws_emr_instance_group” “emr-task” {
count = var.emr_create_task_instance_group ? 1:0
cluster_id = element(aws_emr_cluster.cluster.*.id,0)
instance_count = var.emr_task_instance_count
instance_type = var.emr_task_instance_type
name = “task-group”
bid_price = var.task_bid_price
ebs_config {
size = var.emr_task_instance_size
type = var.emr_task_ebs_type
volumes_per_instance = var.emr_task_volumes
}
}

Are you using temporary credentials or assume-role?

I am using assume-role. As soon as you asked the questions I noticed the duration is set as 900. I believe I should increase it.

withAWS(role:’’, roleAccount:"", duration: 900, roleSessionName: ‘jenkins-session’)

Increasing the duration from 900 seconds to 1800 seconds fixed the problem