diff --git a/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment.go b/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment.go index 4faca8d420..1ebd1b6707 100644 --- a/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment.go +++ b/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment.go @@ -142,72 +142,6 @@ func DataSourceIBMAccountSettingsTemplateAssignment() *schema.Resource { Computed: true, Description: "Target account where the IAM resource is created.", }, - "profile": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Policy Template Id, only returned for a profile assignment with policy references.", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "Policy version, only returned for a profile assignment with policy references.", - }, - "resource_created": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for created resource.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Id of the created resource.", - }, - }, - }, - }, - "error_message": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for assignment error.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Name of the error.", - }, - "error_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal error code.", - }, - "message": { - Type: schema.TypeString, - Computed: true, - Description: "Error message detailing the nature of the error.", - }, - "status_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal status code for the error.", - }, - }, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "Status for the target account's assignment.", - }, - }, - }, - }, "account_settings": { Type: schema.TypeList, Computed: true, @@ -274,73 +208,6 @@ func DataSourceIBMAccountSettingsTemplateAssignment() *schema.Resource { }, }, }, - "policy_template_refs": { - Type: schema.TypeList, - Computed: true, - Description: "Policy resource(s) included only for trusted profile assignments with policy references.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Policy Template Id, only returned for a profile assignment with policy references.", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "Policy version, only returned for a profile assignment with policy references.", - }, - "resource_created": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for created resource.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Id of the created resource.", - }, - }, - }, - }, - "error_message": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for assignment error.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Name of the error.", - }, - "error_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal error code.", - }, - "message": { - Type: schema.TypeString, - Computed: true, - Description: "Error message detailing the nature of the error.", - }, - "status_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal status code for the error.", - }, - }, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "Status for the target account's assignment.", - }, - }, - }, - }, }, }, }, diff --git a/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment_test.go b/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment_test.go index a3984c484a..0f0449fff8 100644 --- a/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment_test.go +++ b/ibm/service/iamidentity/data_source_ibm_iam_account_settings_template_assignment_test.go @@ -63,6 +63,10 @@ func testAccCheckIBMAccountSettingsTemplateAssignmentDataSourceConfigBasic(name template_version = ibm_iam_account_settings_template.account_settings_template.version target_type = "Account" target = "%s" + + timeouts { + create = "5m" + } } data "ibm_iam_account_settings_template_assignment" "account_settings_template_assignment_instance" { diff --git a/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment.go b/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment.go index 34a9ce024d..88e47b2476 100644 --- a/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment.go +++ b/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment.go @@ -208,72 +208,6 @@ func DataSourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, }, }, - "account_settings": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Policy Template Id, only returned for a profile assignment with policy references.", - }, - "version": { - Type: schema.TypeString, - Computed: true, - Description: "Policy version, only returned for a profile assignment with policy references.", - }, - "resource_created": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for created resource.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Id of the created resource.", - }, - }, - }, - }, - "error_message": { - Type: schema.TypeList, - Computed: true, - Description: "Body parameters for assignment error.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Name of the error.", - }, - "error_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal error code.", - }, - "message": { - Type: schema.TypeString, - Computed: true, - Description: "Error message detailing the nature of the error.", - }, - "status_code": { - Type: schema.TypeString, - Computed: true, - Description: "Internal status code for the error.", - }, - }, - }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "Status for the target account's assignment.", - }, - }, - }, - }, "policy_template_refs": { Type: schema.TypeList, Computed: true, diff --git a/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment_test.go b/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment_test.go index 73a65f8343..882d655ee8 100644 --- a/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment_test.go +++ b/ibm/service/iamidentity/data_source_ibm_iam_trusted_profile_template_assignment_test.go @@ -69,6 +69,10 @@ func testAccCheckIBMTrustedProfileTemplateAssignmentDataSourceConfigBasic(name s depends_on = [ ibm_iam_trusted_profile_template.trusted_profile_template ] + + timeouts { + create = "5m" + } } data "ibm_iam_trusted_profile_template_assignment" "trusted_profile_template_assignment_instance" { diff --git a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template.go b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template.go index dbccd7a4e8..6910931b88 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template.go +++ b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template.go @@ -34,19 +34,22 @@ func ResourceIBMAccountSettingsTemplate() *schema.Resource { Description: "ID of the account where the template resides.", }, "name": { - Type: schema.TypeString, - Optional: true, - Description: "The name of the trusted profile template. This is visible only in the enterprise account.", + Type: schema.TypeString, + AtLeastOneOf: []string{"name", "description", "account_settings"}, + Optional: true, + Description: "The name of the trusted profile template. This is visible only in the enterprise account.", }, "description": { - Type: schema.TypeString, - Optional: true, - Description: "The description of the trusted profile template. Describe the template for enterprise account users.", + Type: schema.TypeString, + AtLeastOneOf: []string{"name", "description", "account_settings"}, + Optional: true, + Description: "The description of the trusted profile template. Describe the template for enterprise account users.", }, "account_settings": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Type: schema.TypeList, + AtLeastOneOf: []string{"name", "description", "account_settings"}, + MaxItems: 1, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "restrict_create_service_id": { @@ -145,33 +148,33 @@ func ResourceIBMAccountSettingsTemplate() *schema.Resource { Schema: map[string]*schema.Schema{ "timestamp": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Timestamp when the action was triggered.", }, "iam_id": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "IAM ID of the identity which triggered the action.", }, "iam_id_account": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Account of the identity which triggered the action.", }, "action": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Action of the history entry.", }, "params": { Type: schema.TypeList, - Required: true, + Computed: true, Description: "Params of the history entry.", Elem: &schema.Schema{Type: schema.TypeString}, }, "message": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Message which summarizes the executed action.", }, }, diff --git a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment.go b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment.go index c44916780c..70aeac1b30 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment.go +++ b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "log" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -27,6 +28,12 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { DeleteContext: resourceIBMAccountSettingsTemplateAssignmentDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "template_id": { Type: schema.TypeString, @@ -57,57 +64,57 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { Schema: map[string]*schema.Schema{ "transaction_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The transaction ID of the inbound REST request.", }, "operation": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The operation of the inbound REST request.", }, "user_agent": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The user agent of the inbound REST request.", }, "url": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The URL of that cluster.", }, "instance_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The instance ID of the server instance processing the request.", }, "thread_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The thread ID of the server instance processing the request.", }, "host": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The host of the server instance processing the request.", }, "start_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The start time of the request.", }, "end_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The finish time of the request.", }, "elapsed_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The elapsed time in msec.", }, "cluster_name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The cluster name.", }, }, @@ -136,20 +143,18 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { }, "account_settings": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "resource_created": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for created resource.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Id of the created resource.", }, }, @@ -157,29 +162,28 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { }, "error_message": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for assignment error.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Name of the error.", }, "error_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal error code.", }, "message": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Error message detailing the nature of the error.", }, "status_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal status code for the error.", }, }, @@ -187,7 +191,7 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { }, "status": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Status for the target account's assignment.", }, }, @@ -204,33 +208,33 @@ func ResourceIBMAccountSettingsTemplateAssignment() *schema.Resource { Schema: map[string]*schema.Schema{ "timestamp": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Timestamp when the action was triggered.", }, "iam_id": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "IAM ID of the identity which triggered the action.", }, "iam_id_account": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Account of the identity which triggered the action.", }, "action": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Action of the history entry.", }, "params": { Type: schema.TypeList, - Required: true, + Computed: true, Description: "Params of the history entry.", Elem: &schema.Schema{Type: schema.TypeString}, }, "message": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Message which summarizes the executed action.", }, }, @@ -313,7 +317,7 @@ func resourceIBMAccountSettingsTemplateAssignmentCreate(context context.Context, d.SetId(*templateAssignmentResponse.ID) - _, err = waitForAssignment(meta, d, isAccountSettingsTemplateAssigned) + _, err = waitForAssignment(d.Timeout(schema.TimeoutCreate), meta, d, isAccountSettingsTemplateAssigned) if err != nil { return diag.FromErr(fmt.Errorf("error assigning %s", err)) } @@ -442,7 +446,7 @@ func resourceIBMAccountSettingsTemplateAssignmentUpdate(context context.Context, return diag.FromErr(fmt.Errorf("UpdateAccountSettingsAssignmentWithContext failed %s\n%s", err, response)) } - _, err = waitForAssignment(meta, d, isAccountSettingsTemplateAssigned) + _, err = waitForAssignment(d.Timeout(schema.TimeoutUpdate), meta, d, isAccountSettingsTemplateAssigned) if err != nil { return diag.FromErr(fmt.Errorf("error assigning %s", err)) } @@ -467,7 +471,7 @@ func resourceIBMAccountSettingsTemplateAssignmentDelete(context context.Context, return diag.FromErr(fmt.Errorf("DeleteAccountSettingsAssignmentWithContext failed %s\n%s", err, response)) } - _, err = waitForAssignment(meta, d, isAccountSettingsAssignmentRemoved) + _, err = waitForAssignment(d.Timeout(schema.TimeoutDelete), meta, d, isAccountSettingsAssignmentRemoved) if err != nil { return diag.FromErr(fmt.Errorf("error removing assignment %s", err)) } diff --git a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment_test.go b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment_test.go index b0e9d830aa..e2bc9aad00 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment_test.go +++ b/ibm/service/iamidentity/resource_ibm_iam_account_settings_template_assignment_test.go @@ -73,6 +73,14 @@ func testAccCheckIBMAccountSettingsTemplateAssignmentConfigBasic(name string) st template_version = ibm_iam_account_settings_template.account_settings_template.version target_type = "Account" target = "%s" + + depends_on = [ + ibm_iam_account_settings_template.account_settings_template + ] + + timeouts { + create = "5m" + } } `, name, acc.IamIdentityAssignmentTargetAccountId) } @@ -92,6 +100,14 @@ func testAccCheckIBMAccountSettingsTemplateAssignmentConfigBasicUpdate(name stri template_version = 2 target_type = "Account" target = "%s" + + depends_on = [ + ibm_iam_account_settings_template.account_settings_template + ] + + timeouts { + update = "5m" + } } `, name, acc.IamIdentityAssignmentTargetAccountId) } diff --git a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template.go b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template.go index e1b710b77a..b890b7f9fc 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template.go +++ b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template.go @@ -31,20 +31,23 @@ func ResourceIBMTrustedProfileTemplate() *schema.Resource { Description: "ID of the account where the template resides.", }, "name": { - Type: schema.TypeString, - Optional: true, - Description: "The name of the trusted profile template. This is visible only in the enterprise account.", + Type: schema.TypeString, + AtLeastOneOf: []string{"name", "description", "profile"}, + Optional: true, + Description: "The name of the trusted profile template. This is visible only in the enterprise account.", }, "description": { - Type: schema.TypeString, - Optional: true, - Description: "The description of the trusted profile template. Describe the template for enterprise account users.", + Type: schema.TypeString, + AtLeastOneOf: []string{"name", "description", "profile"}, + Optional: true, + Description: "The description of the trusted profile template. Describe the template for enterprise account users.", }, "profile": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Input body parameters for the TemplateProfileComponent.", + Type: schema.TypeList, + AtLeastOneOf: []string{"name", "description", "profile"}, + MaxItems: 1, + Optional: true, + Description: "Input body parameters for the TemplateProfileComponent.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { @@ -195,33 +198,33 @@ func ResourceIBMTrustedProfileTemplate() *schema.Resource { Schema: map[string]*schema.Schema{ "timestamp": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Timestamp when the action was triggered.", }, "iam_id": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "IAM ID of the identity which triggered the action.", }, "iam_id_account": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Account of the identity which triggered the action.", }, "action": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Action of the history entry.", }, "params": { Type: schema.TypeList, - Required: true, + Computed: true, Description: "Params of the history entry.", Elem: &schema.Schema{Type: schema.TypeString}, }, "message": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Message which summarizes the executed action.", }, }, diff --git a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment.go b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment.go index f4ed009899..ad1ae38e10 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment.go +++ b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment.go @@ -8,8 +8,6 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "log" - "os" - "strconv" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -23,10 +21,9 @@ import ( ) const ( - envTimeoutDurationKey = "IAM_TEMPLATE_ASSIGNMENT_STATE_REFRESH_TIMEOUT_IN_SECONDS" - InProgress = "in_progress" - complete = "complete" - failed = "failed" + InProgress = "in_progress" + complete = "complete" + failed = "failed" ) func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { @@ -37,6 +34,12 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { DeleteContext: resourceIBMTrustedProfileTemplateAssignmentDelete, Importer: &schema.ResourceImporter{}, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "template_id": { Type: schema.TypeString, @@ -67,57 +70,57 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { Schema: map[string]*schema.Schema{ "transaction_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The transaction ID of the inbound REST request.", }, "operation": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The operation of the inbound REST request.", }, "user_agent": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The user agent of the inbound REST request.", }, "url": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The URL of that cluster.", }, "instance_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The instance ID of the server instance processing the request.", }, "thread_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The thread ID of the server instance processing the request.", }, "host": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The host of the server instance processing the request.", }, "start_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The start time of the request.", }, "end_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The finish time of the request.", }, "elapsed_time": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The elapsed time in msec.", }, "cluster_name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "The cluster name.", }, }, @@ -146,30 +149,28 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "profile": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Policy Template Id, only returned for a profile assignment with policy references.", }, "version": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Policy version, only returned for a profile assignment with policy references.", }, "resource_created": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for created resource.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Id of the created resource.", }, }, @@ -177,29 +178,28 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "error_message": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for assignment error.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Name of the error.", }, "error_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal error code.", }, "message": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Error message detailing the nature of the error.", }, "status_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal status code for the error.", }, }, @@ -207,7 +207,7 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "status": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Status for the target account's assignment.", }, }, @@ -215,30 +215,29 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "policy_template_refs": { Type: schema.TypeList, - Optional: true, + Computed: true, Description: "Policy resource(s) included only for trusted profile assignments with policy references.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Policy Template Id, only returned for a profile assignment with policy references.", }, "version": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Policy version, only returned for a profile assignment with policy references.", }, "resource_created": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for created resource.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Id of the created resource.", }, }, @@ -246,29 +245,28 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "error_message": { Type: schema.TypeList, - MaxItems: 1, - Optional: true, + Computed: true, Description: "Body parameters for assignment error.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Name of the error.", }, "error_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal error code.", }, "message": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Error message detailing the nature of the error.", }, "status_code": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Internal status code for the error.", }, }, @@ -276,7 +274,7 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { }, "status": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Status for the target account's assignment.", }, }, @@ -293,33 +291,33 @@ func ResourceIBMTrustedProfileTemplateAssignment() *schema.Resource { Schema: map[string]*schema.Schema{ "timestamp": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Timestamp when the action was triggered.", }, "iam_id": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "IAM ID of the identity which triggered the action.", }, "iam_id_account": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Account of the identity which triggered the action.", }, "action": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Action of the history entry.", }, "params": { Type: schema.TypeList, - Required: true, + Computed: true, Description: "Params of the history entry.", Elem: &schema.Schema{Type: schema.TypeString}, }, "message": { Type: schema.TypeString, - Required: true, + Computed: true, Description: "Message which summarizes the executed action.", }, }, @@ -396,7 +394,7 @@ func resourceIBMTrustedProfileTemplateAssignmentCreate(context context.Context, d.SetId(*templateAssignmentResponse.ID) - _, err = waitForAssignment(meta, d, isTrustedProfileTemplateAssigned) + _, err = waitForAssignment(d.Timeout(schema.TimeoutCreate), meta, d, isTrustedProfileTemplateAssigned) if err != nil { return diag.FromErr(fmt.Errorf("error assigning %s", err)) } @@ -525,7 +523,7 @@ func resourceIBMTrustedProfileTemplateAssignmentUpdate(context context.Context, return diag.FromErr(fmt.Errorf("UpdateTrustedProfileAssignmentWithContext failed %s\n%s", err, response)) } - _, err = waitForAssignment(meta, d, isTrustedProfileTemplateAssigned) + _, err = waitForAssignment(d.Timeout(schema.TimeoutUpdate), meta, d, isTrustedProfileTemplateAssigned) if err != nil { return diag.FromErr(fmt.Errorf("error assigning %s", err)) } @@ -549,7 +547,7 @@ func resourceIBMTrustedProfileTemplateAssignmentDelete(context context.Context, return diag.FromErr(fmt.Errorf("[DEBUG] DeleteTrustedProfileAssignmentWithContext failed %s\n%s", err, response)) } - _, err = waitForAssignment(meta, d, isTrustedProfileAssignmentRemoved) + _, err = waitForAssignment(d.Timeout(schema.TimeoutDelete), meta, d, isTrustedProfileAssignmentRemoved) if err != nil { return diag.FromErr(fmt.Errorf("error removing assignment %s", err)) } @@ -559,30 +557,14 @@ func resourceIBMTrustedProfileTemplateAssignmentDelete(context context.Context, return nil } -func waitForAssignment(meta interface{}, d *schema.ResourceData, refreshFn func(string, interface{}) resource.StateRefreshFunc) (interface{}, error) { - log.Printf("Waiting for (%s) to complete...", d.Id()) - - timeoutStr, isSet := os.LookupEnv(envTimeoutDurationKey) - if !isSet || len(timeoutStr) == 0 { - log.Printf("Setting default timeout to 15 minutes. For a longer timeout, set environment variable '%s'", envTimeoutDurationKey) - timeoutStr = "900" // 15 minute default - } else { - log.Printf("Using environment refresh timeout duration: %s seconds", timeoutStr) - } - - var timeoutInt, err = strconv.Atoi(timeoutStr) - if err != nil { - log.Printf("Environment variable %s has a value that cannot be converted to an integer", envTimeoutDurationKey) - return nil, err - } - +func waitForAssignment(timeout time.Duration, meta interface{}, d *schema.ResourceData, refreshFn func(string, interface{}) resource.StateRefreshFunc) (interface{}, error) { stateConf := &resource.StateChangeConf{ Pending: []string{InProgress}, Target: []string{complete}, Refresh: refreshFn(d.Id(), meta), Delay: 30 * time.Second, PollInterval: time.Minute, - Timeout: time.Duration(timeoutInt) * time.Second, + Timeout: timeout, } return stateConf.WaitForState() diff --git a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment_test.go b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment_test.go index e8e00202a4..8ceeec507a 100644 --- a/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment_test.go +++ b/ibm/service/iamidentity/resource_ibm_iam_trusted_profile_template_assignment_test.go @@ -93,6 +93,11 @@ func testAccCheckIBMTrustedProfileTemplateAssignmentConfigBasic(name string, ver ibm_iam_trusted_profile_template.trusted_profile_template, ibm_iam_trusted_profile_template.trusted_profile_template_v2 ] + + timeouts { + create = "5m" + update = "5m" + } } `, name, name, version, acc.IamIdentityAssignmentTargetAccountId) } diff --git a/website/docs/d/account_settings_template.html.markdown b/website/docs/d/account_settings_template.html.markdown index b0ae8d03fe..b5623a2c77 100644 --- a/website/docs/d/account_settings_template.html.markdown +++ b/website/docs/d/account_settings_template.html.markdown @@ -14,8 +14,8 @@ Provides a read-only data source to retrieve information about an account_settin ```hcl data "ibm_iam_account_settings_template" "account_settings_template" { - template_id = "template_id" - version = "version" + template_id = "${var.template_id}" + version = "${var.version}" } ``` diff --git a/website/docs/d/account_settings_template_assignment.html.markdown b/website/docs/d/account_settings_template_assignment.html.markdown index 321a0b71da..df2565e9bd 100644 --- a/website/docs/d/account_settings_template_assignment.html.markdown +++ b/website/docs/d/account_settings_template_assignment.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about an account_settin ```hcl data "ibm_iam_account_settings_template_assignment" "account_settings_template_assignment" { - assignment_id = "assignment_id" + assignment_id = "${var.assignment_id}" } ``` diff --git a/website/docs/d/trusted_profile_template.html.markdown b/website/docs/d/trusted_profile_template.html.markdown index d5e90417b0..109553393a 100644 --- a/website/docs/d/trusted_profile_template.html.markdown +++ b/website/docs/d/trusted_profile_template.html.markdown @@ -14,8 +14,8 @@ Provides a read-only data source to retrieve information about a trusted_profile ```hcl data "ibm_trusted_profile_template" "trusted_profile_template" { - template_id = "template_id" - version = "version" + template_id = "${var.template_id}" + version = "${var.version}" } ``` diff --git a/website/docs/d/trusted_profile_template_assignment.html.markdown b/website/docs/d/trusted_profile_template_assignment.html.markdown index 00d08daf6f..63adb3688c 100644 --- a/website/docs/d/trusted_profile_template_assignment.html.markdown +++ b/website/docs/d/trusted_profile_template_assignment.html.markdown @@ -14,7 +14,7 @@ Provides a read-only data source to retrieve information about a trusted_profile ```hcl data "ibm_iam_trusted_profile_template_assignment" "trusted_profile_template_assignment" { - assignment_id = "assignment_id" + assignment_id = "${var.assignment_id}" } ``` diff --git a/website/docs/r/account_settings_template_assignment.html.markdown b/website/docs/r/account_settings_template_assignment.html.markdown index f5945cc147..0d47297865 100644 --- a/website/docs/r/account_settings_template_assignment.html.markdown +++ b/website/docs/r/account_settings_template_assignment.html.markdown @@ -14,10 +14,10 @@ Create, update, and delete account_settings_template_assignments with this resou ```hcl resource "ibm_iam_account_settings_template_assignment" "account_settings_template_assignment_instance" { - template_id = "template_id" - template_version = 1 - target = "target" - target_type = "Account" + template_id = "${var.template_id}" + template_version = "${var.template_version}" + target = "${var.target_account}" + target_type = "${var.account_type}" } ``` diff --git a/website/docs/r/trusted_profile_template.html.markdown b/website/docs/r/trusted_profile_template.html.markdown index 1535f92b90..c46e543e85 100644 --- a/website/docs/r/trusted_profile_template.html.markdown +++ b/website/docs/r/trusted_profile_template.html.markdown @@ -14,11 +14,11 @@ Create, update, commit, and delete trusted profile templates with this resource. ```hcl resource "ibm_iam_trusted_profile_template" "trusted_profile_template_instance" { - name = var.trusted_profile_template_name - description = var.trusted_profile_template_description + name = "${var.trusted_profile_template_name}" + description = "${var.trusted_profile_template_description}" profile { - name = "name" - description = "description" + name = "profile from template" + description = "description of profile from template" rules { name = "name" type = "Profile-SAML" diff --git a/website/docs/r/trusted_profile_template_assignment.html.markdown b/website/docs/r/trusted_profile_template_assignment.html.markdown index eca23cf058..8318612711 100644 --- a/website/docs/r/trusted_profile_template_assignment.html.markdown +++ b/website/docs/r/trusted_profile_template_assignment.html.markdown @@ -14,10 +14,10 @@ Create, update, and delete trusted_profile_template_assignments with this resour ```hcl resource "ibm_iam_trusted_profile_template_assignment" "trusted_profile_template_assignment_instance" { - target = "target account or account group" - target_type = "Account or AccountGroup" - template_id = "template_id" - template_version = 1 + template_id = "${var.template_id}" + template_version = "${var.template_version}" + target = "${var.target_account}" + target_type = "${var.account_type}" } ```