diff --git a/terraform/gen/plural_resource.go.tpl b/terraform/gen/plural_resource.go.tpl index c0c352192..8652e04e1 100644 --- a/terraform/gen/plural_resource.go.tpl +++ b/terraform/gen/plural_resource.go.tpl @@ -170,13 +170,12 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR {{.VarName}}I, err = r.p.Client.{{.GetMethod}}(ctx, {{if .Namespaced}}defaults.Namespace, {{end}}id{{if ne .WithSecrets ""}}, {{.WithSecrets}}{{end}}) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading {{.Name}} (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "{{.Kind}}")) - return + resp.Diagnostics.AddError(diagMessage, "{{.Kind}}") } continue } @@ -344,7 +343,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", err, "{{.Kind}}")) return } - if {{.VarName}}Before.GetMetadata().ID != {{.VarName}}I.GetMetadata().ID || {{.HasStaticID}} { + if {{.VarName}}Before.GetMetadata().Revision != {{.VarName}}I.GetMetadata().Revision || {{.HasStaticID}} { break } diff --git a/terraform/gen/singular_resource.go.tpl b/terraform/gen/singular_resource.go.tpl index 39145d3cd..1af61ea43 100644 --- a/terraform/gen/singular_resource.go.tpl +++ b/terraform/gen/singular_resource.go.tpl @@ -123,16 +123,16 @@ func (r resourceTeleport{{.Name}}) Create(ctx context.Context, req tfsdk.CreateR resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}")) return } - if {{.VarName}}Before.GetMetadata().ID != {{.VarName}}I.GetMetadata().ID || {{.HasStaticID}} { + if {{.VarName}}Before.GetMetadata().Revision != {{.VarName}}I.GetMetadata().Revision || {{.HasStaticID}} { break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading {{.Name}} (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "{{.Kind}}")) + resp.Diagnostics.AddError(diagMessage, "{{.Kind}}") return } } @@ -259,7 +259,7 @@ func (r resourceTeleport{{.Name}}) Update(ctx context.Context, req tfsdk.UpdateR break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(err), "{{.Kind}}")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading {{.Name}}", trace.Wrap(bErr), "{{.Kind}}")) return } if tries >= r.p.RetryConfig.MaxTries { diff --git a/terraform/provider/resource_teleport_access_list.go b/terraform/provider/resource_teleport_access_list.go index 30d4cdde3..253273ac5 100755 --- a/terraform/provider/resource_teleport_access_list.go +++ b/terraform/provider/resource_teleport_access_list.go @@ -116,13 +116,12 @@ func (r resourceTeleportAccessList) Create(ctx context.Context, req tfsdk.Create accessListI, err = r.p.Client.AccessListClient().GetAccessList(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading AccessList", trace.Wrap(err), "access_list")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading AccessList", trace.Wrap(bErr), "access_list")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading AccessList (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "access_list")) - return + resp.Diagnostics.AddError(diagMessage, "access_list") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportAccessList) Update(ctx context.Context, req tfsdk.Update resp.Diagnostics.Append(diagFromWrappedErr("Error reading AccessList", err, "access_list")) return } - if accessListBefore.GetMetadata().ID != accessListI.GetMetadata().ID || false { + if accessListBefore.GetMetadata().Revision != accessListI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_app.go b/terraform/provider/resource_teleport_app.go index 69e1a47cf..5a10f6cb3 100755 --- a/terraform/provider/resource_teleport_app.go +++ b/terraform/provider/resource_teleport_app.go @@ -115,13 +115,12 @@ func (r resourceTeleportApp) Create(ctx context.Context, req tfsdk.CreateResourc appI, err = r.p.Client.GetApp(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading App", trace.Wrap(err), "app")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading App", trace.Wrap(bErr), "app")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading App (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "app")) - return + resp.Diagnostics.AddError(diagMessage, "app") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportApp) Update(ctx context.Context, req tfsdk.UpdateResourc resp.Diagnostics.Append(diagFromWrappedErr("Error reading App", err, "app")) return } - if appBefore.GetMetadata().ID != appI.GetMetadata().ID || false { + if appBefore.GetMetadata().Revision != appI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_auth_preference.go b/terraform/provider/resource_teleport_auth_preference.go index bfec82e2a..cbfb985db 100755 --- a/terraform/provider/resource_teleport_auth_preference.go +++ b/terraform/provider/resource_teleport_auth_preference.go @@ -107,16 +107,16 @@ func (r resourceTeleportAuthPreference) Create(ctx context.Context, req tfsdk.Cr resp.Diagnostics.Append(diagFromWrappedErr("Error reading AuthPreference", trace.Wrap(err), "cluster_auth_preference")) return } - if authPreferenceBefore.GetMetadata().ID != authPreferenceI.GetMetadata().ID || false { + if authPreferenceBefore.GetMetadata().Revision != authPreferenceI.GetMetadata().Revision || false { break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading AuthPreference", trace.Wrap(err), "cluster_auth_preference")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading AuthPreference", trace.Wrap(bErr), "cluster_auth_preference")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading AuthPreference (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "cluster_auth_preference")) + resp.Diagnostics.AddError(diagMessage, "cluster_auth_preference") return } } @@ -231,7 +231,7 @@ func (r resourceTeleportAuthPreference) Update(ctx context.Context, req tfsdk.Up break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading AuthPreference", trace.Wrap(err), "cluster_auth_preference")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading AuthPreference", trace.Wrap(bErr), "cluster_auth_preference")) return } if tries >= r.p.RetryConfig.MaxTries { diff --git a/terraform/provider/resource_teleport_cluster_maintenance_config.go b/terraform/provider/resource_teleport_cluster_maintenance_config.go index 2e0cefa9e..0e4fe9ec3 100755 --- a/terraform/provider/resource_teleport_cluster_maintenance_config.go +++ b/terraform/provider/resource_teleport_cluster_maintenance_config.go @@ -109,16 +109,16 @@ func (r resourceTeleportClusterMaintenanceConfig) Create(ctx context.Context, re resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterMaintenanceConfig", trace.Wrap(err), "cluster_maintenance_config")) return } - if clusterMaintenanceConfigBefore.GetMetadata().ID != clusterMaintenanceConfigI.GetMetadata().ID || true { + if clusterMaintenanceConfigBefore.GetMetadata().Revision != clusterMaintenanceConfigI.GetMetadata().Revision || true { break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterMaintenanceConfig", trace.Wrap(err), "cluster_maintenance_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterMaintenanceConfig", trace.Wrap(bErr), "cluster_maintenance_config")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading ClusterMaintenanceConfig (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "cluster_maintenance_config")) + resp.Diagnostics.AddError(diagMessage, "cluster_maintenance_config") return } } @@ -234,7 +234,7 @@ func (r resourceTeleportClusterMaintenanceConfig) Update(ctx context.Context, re break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterMaintenanceConfig", trace.Wrap(err), "cluster_maintenance_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterMaintenanceConfig", trace.Wrap(bErr), "cluster_maintenance_config")) return } if tries >= r.p.RetryConfig.MaxTries { diff --git a/terraform/provider/resource_teleport_cluster_networking_config.go b/terraform/provider/resource_teleport_cluster_networking_config.go index fde906846..34ccb6ea6 100755 --- a/terraform/provider/resource_teleport_cluster_networking_config.go +++ b/terraform/provider/resource_teleport_cluster_networking_config.go @@ -107,16 +107,16 @@ func (r resourceTeleportClusterNetworkingConfig) Create(ctx context.Context, req resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterNetworkingConfig", trace.Wrap(err), "cluster_networking_config")) return } - if clusterNetworkingConfigBefore.GetMetadata().ID != clusterNetworkingConfigI.GetMetadata().ID || false { + if clusterNetworkingConfigBefore.GetMetadata().Revision != clusterNetworkingConfigI.GetMetadata().Revision || false { break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterNetworkingConfig", trace.Wrap(err), "cluster_networking_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterNetworkingConfig", trace.Wrap(bErr), "cluster_networking_config")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading ClusterNetworkingConfig (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "cluster_networking_config")) + resp.Diagnostics.AddError(diagMessage, "cluster_networking_config") return } } @@ -231,7 +231,7 @@ func (r resourceTeleportClusterNetworkingConfig) Update(ctx context.Context, req break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterNetworkingConfig", trace.Wrap(err), "cluster_networking_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading ClusterNetworkingConfig", trace.Wrap(bErr), "cluster_networking_config")) return } if tries >= r.p.RetryConfig.MaxTries { diff --git a/terraform/provider/resource_teleport_database.go b/terraform/provider/resource_teleport_database.go index 2c7f4d07f..597abc278 100755 --- a/terraform/provider/resource_teleport_database.go +++ b/terraform/provider/resource_teleport_database.go @@ -115,13 +115,12 @@ func (r resourceTeleportDatabase) Create(ctx context.Context, req tfsdk.CreateRe databaseI, err = r.p.Client.GetDatabase(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading Database", trace.Wrap(err), "db")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading Database", trace.Wrap(bErr), "db")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading Database (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "db")) - return + resp.Diagnostics.AddError(diagMessage, "db") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportDatabase) Update(ctx context.Context, req tfsdk.UpdateRe resp.Diagnostics.Append(diagFromWrappedErr("Error reading Database", err, "db")) return } - if databaseBefore.GetMetadata().ID != databaseI.GetMetadata().ID || false { + if databaseBefore.GetMetadata().Revision != databaseI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_device_trust.go b/terraform/provider/resource_teleport_device_trust.go index a7511b0d7..a17b7f220 100755 --- a/terraform/provider/resource_teleport_device_trust.go +++ b/terraform/provider/resource_teleport_device_trust.go @@ -112,13 +112,12 @@ func (r resourceTeleportDeviceV1) Create(ctx context.Context, req tfsdk.CreateRe trustedDeviceI, err = r.p.Client.GetDeviceResource(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading DeviceV1", trace.Wrap(err), "device")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DeviceV1", trace.Wrap(bErr), "device")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading DeviceV1 (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "device")) - return + resp.Diagnostics.AddError(diagMessage, "device") } continue } @@ -237,7 +236,7 @@ func (r resourceTeleportDeviceV1) Update(ctx context.Context, req tfsdk.UpdateRe resp.Diagnostics.Append(diagFromWrappedErr("Error reading DeviceV1", err, "device")) return } - if trustedDeviceBefore.GetMetadata().ID != trustedDeviceI.GetMetadata().ID || true { + if trustedDeviceBefore.GetMetadata().Revision != trustedDeviceI.GetMetadata().Revision || true { break } diff --git a/terraform/provider/resource_teleport_github_connector.go b/terraform/provider/resource_teleport_github_connector.go index 5256150b7..980788cbb 100755 --- a/terraform/provider/resource_teleport_github_connector.go +++ b/terraform/provider/resource_teleport_github_connector.go @@ -115,13 +115,12 @@ func (r resourceTeleportGithubConnector) Create(ctx context.Context, req tfsdk.C githubConnectorI, err = r.p.Client.GetGithubConnector(ctx, id, true) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading GithubConnector", trace.Wrap(err), "github")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading GithubConnector", trace.Wrap(bErr), "github")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading GithubConnector (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "github")) - return + resp.Diagnostics.AddError(diagMessage, "github") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportGithubConnector) Update(ctx context.Context, req tfsdk.U resp.Diagnostics.Append(diagFromWrappedErr("Error reading GithubConnector", err, "github")) return } - if githubConnectorBefore.GetMetadata().ID != githubConnectorI.GetMetadata().ID || true { + if githubConnectorBefore.GetMetadata().Revision != githubConnectorI.GetMetadata().Revision || true { break } diff --git a/terraform/provider/resource_teleport_login_rule.go b/terraform/provider/resource_teleport_login_rule.go index fb54465c2..f8c60b7c4 100755 --- a/terraform/provider/resource_teleport_login_rule.go +++ b/terraform/provider/resource_teleport_login_rule.go @@ -108,13 +108,12 @@ func (r resourceTeleportLoginRule) Create(ctx context.Context, req tfsdk.CreateR loginRuleI, err = r.p.Client.GetLoginRule(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading LoginRule", trace.Wrap(err), "login_rule")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading LoginRule", trace.Wrap(bErr), "login_rule")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading LoginRule (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "login_rule")) - return + resp.Diagnostics.AddError(diagMessage, "login_rule") } continue } @@ -233,7 +232,7 @@ func (r resourceTeleportLoginRule) Update(ctx context.Context, req tfsdk.UpdateR resp.Diagnostics.Append(diagFromWrappedErr("Error reading LoginRule", err, "login_rule")) return } - if loginRuleBefore.GetMetadata().ID != loginRuleI.GetMetadata().ID || false { + if loginRuleBefore.GetMetadata().Revision != loginRuleI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_oidc_connector.go b/terraform/provider/resource_teleport_oidc_connector.go index 4e6113f66..c93f14aaf 100755 --- a/terraform/provider/resource_teleport_oidc_connector.go +++ b/terraform/provider/resource_teleport_oidc_connector.go @@ -115,13 +115,12 @@ func (r resourceTeleportOIDCConnector) Create(ctx context.Context, req tfsdk.Cre oidcConnectorI, err = r.p.Client.GetOIDCConnector(ctx, id, true) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading OIDCConnector", trace.Wrap(err), "oidc")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading OIDCConnector", trace.Wrap(bErr), "oidc")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading OIDCConnector (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "oidc")) - return + resp.Diagnostics.AddError(diagMessage, "oidc") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportOIDCConnector) Update(ctx context.Context, req tfsdk.Upd resp.Diagnostics.Append(diagFromWrappedErr("Error reading OIDCConnector", err, "oidc")) return } - if oidcConnectorBefore.GetMetadata().ID != oidcConnectorI.GetMetadata().ID || true { + if oidcConnectorBefore.GetMetadata().Revision != oidcConnectorI.GetMetadata().Revision || true { break } diff --git a/terraform/provider/resource_teleport_okta_import_rule.go b/terraform/provider/resource_teleport_okta_import_rule.go index 873f904ff..07511159b 100755 --- a/terraform/provider/resource_teleport_okta_import_rule.go +++ b/terraform/provider/resource_teleport_okta_import_rule.go @@ -115,13 +115,12 @@ func (r resourceTeleportOktaImportRule) Create(ctx context.Context, req tfsdk.Cr oktaImportRuleI, err = r.p.Client.OktaClient().GetOktaImportRule(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading OktaImportRule", trace.Wrap(err), "okta_import_rule")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading OktaImportRule", trace.Wrap(bErr), "okta_import_rule")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading OktaImportRule (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "okta_import_rule")) - return + resp.Diagnostics.AddError(diagMessage, "okta_import_rule") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportOktaImportRule) Update(ctx context.Context, req tfsdk.Up resp.Diagnostics.Append(diagFromWrappedErr("Error reading OktaImportRule", err, "okta_import_rule")) return } - if oktaImportRuleBefore.GetMetadata().ID != oktaImportRuleI.GetMetadata().ID || false { + if oktaImportRuleBefore.GetMetadata().Revision != oktaImportRuleI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_provision_token.go b/terraform/provider/resource_teleport_provision_token.go index 6bff1078b..7c946fc8c 100755 --- a/terraform/provider/resource_teleport_provision_token.go +++ b/terraform/provider/resource_teleport_provision_token.go @@ -127,13 +127,12 @@ func (r resourceTeleportProvisionToken) Create(ctx context.Context, req tfsdk.Cr provisionTokenI, err = r.p.Client.GetToken(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading ProvisionToken", trace.Wrap(err), "token")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading ProvisionToken", trace.Wrap(bErr), "token")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading ProvisionToken (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "token")) - return + resp.Diagnostics.AddError(diagMessage, "token") } continue } @@ -261,7 +260,7 @@ func (r resourceTeleportProvisionToken) Update(ctx context.Context, req tfsdk.Up resp.Diagnostics.Append(diagFromWrappedErr("Error reading ProvisionToken", err, "token")) return } - if provisionTokenBefore.GetMetadata().ID != provisionTokenI.GetMetadata().ID || false { + if provisionTokenBefore.GetMetadata().Revision != provisionTokenI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_role.go b/terraform/provider/resource_teleport_role.go index 73979b21a..c88e88309 100755 --- a/terraform/provider/resource_teleport_role.go +++ b/terraform/provider/resource_teleport_role.go @@ -115,13 +115,12 @@ func (r resourceTeleportRole) Create(ctx context.Context, req tfsdk.CreateResour roleI, err = r.p.Client.GetRole(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading Role", trace.Wrap(err), "role")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading Role", trace.Wrap(bErr), "role")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading Role (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "role")) - return + resp.Diagnostics.AddError(diagMessage, "role") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportRole) Update(ctx context.Context, req tfsdk.UpdateResour resp.Diagnostics.Append(diagFromWrappedErr("Error reading Role", err, "role")) return } - if roleBefore.GetMetadata().ID != roleI.GetMetadata().ID || false { + if roleBefore.GetMetadata().Revision != roleI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_saml_connector.go b/terraform/provider/resource_teleport_saml_connector.go index 8d1e3aa72..e12266194 100755 --- a/terraform/provider/resource_teleport_saml_connector.go +++ b/terraform/provider/resource_teleport_saml_connector.go @@ -115,13 +115,12 @@ func (r resourceTeleportSAMLConnector) Create(ctx context.Context, req tfsdk.Cre samlConnectorI, err = r.p.Client.GetSAMLConnector(ctx, id, true) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading SAMLConnector", trace.Wrap(err), "saml")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading SAMLConnector", trace.Wrap(bErr), "saml")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading SAMLConnector (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "saml")) - return + resp.Diagnostics.AddError(diagMessage, "saml") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportSAMLConnector) Update(ctx context.Context, req tfsdk.Upd resp.Diagnostics.Append(diagFromWrappedErr("Error reading SAMLConnector", err, "saml")) return } - if samlConnectorBefore.GetMetadata().ID != samlConnectorI.GetMetadata().ID || true { + if samlConnectorBefore.GetMetadata().Revision != samlConnectorI.GetMetadata().Revision || true { break } diff --git a/terraform/provider/resource_teleport_server.go b/terraform/provider/resource_teleport_server.go index fcfdde6da..45d93fb77 100755 --- a/terraform/provider/resource_teleport_server.go +++ b/terraform/provider/resource_teleport_server.go @@ -117,13 +117,12 @@ func (r resourceTeleportServer) Create(ctx context.Context, req tfsdk.CreateReso serverI, err = r.p.Client.GetNode(ctx, defaults.Namespace, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading Server", trace.Wrap(err), "node")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading Server", trace.Wrap(bErr), "node")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading Server (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "node")) - return + resp.Diagnostics.AddError(diagMessage, "node") } continue } @@ -251,7 +250,7 @@ func (r resourceTeleportServer) Update(ctx context.Context, req tfsdk.UpdateReso resp.Diagnostics.Append(diagFromWrappedErr("Error reading Server", err, "node")) return } - if serverBefore.GetMetadata().ID != serverI.GetMetadata().ID || false { + if serverBefore.GetMetadata().Revision != serverI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_session_recording_config.go b/terraform/provider/resource_teleport_session_recording_config.go index a8f4e883a..58e4f2ea3 100755 --- a/terraform/provider/resource_teleport_session_recording_config.go +++ b/terraform/provider/resource_teleport_session_recording_config.go @@ -107,16 +107,16 @@ func (r resourceTeleportSessionRecordingConfig) Create(ctx context.Context, req resp.Diagnostics.Append(diagFromWrappedErr("Error reading SessionRecordingConfig", trace.Wrap(err), "session_recording_config")) return } - if sessionRecordingConfigBefore.GetMetadata().ID != sessionRecordingConfigI.GetMetadata().ID || false { + if sessionRecordingConfigBefore.GetMetadata().Revision != sessionRecordingConfigI.GetMetadata().Revision || false { break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading SessionRecordingConfig", trace.Wrap(err), "session_recording_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading SessionRecordingConfig", trace.Wrap(bErr), "session_recording_config")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading SessionRecordingConfig (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "session_recording_config")) + resp.Diagnostics.AddError(diagMessage, "session_recording_config") return } } @@ -231,7 +231,7 @@ func (r resourceTeleportSessionRecordingConfig) Update(ctx context.Context, req break } if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading SessionRecordingConfig", trace.Wrap(err), "session_recording_config")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading SessionRecordingConfig", trace.Wrap(bErr), "session_recording_config")) return } if tries >= r.p.RetryConfig.MaxTries { diff --git a/terraform/provider/resource_teleport_trusted_cluster.go b/terraform/provider/resource_teleport_trusted_cluster.go index c1fc090d8..21f1b5569 100755 --- a/terraform/provider/resource_teleport_trusted_cluster.go +++ b/terraform/provider/resource_teleport_trusted_cluster.go @@ -115,13 +115,12 @@ func (r resourceTeleportTrustedCluster) Create(ctx context.Context, req tfsdk.Cr trustedClusterI, err = r.p.Client.GetTrustedCluster(ctx, id) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading TrustedCluster", trace.Wrap(err), "trusted_cluster")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading TrustedCluster", trace.Wrap(bErr), "trusted_cluster")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading TrustedCluster (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "trusted_cluster")) - return + resp.Diagnostics.AddError(diagMessage, "trusted_cluster") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportTrustedCluster) Update(ctx context.Context, req tfsdk.Up resp.Diagnostics.Append(diagFromWrappedErr("Error reading TrustedCluster", err, "trusted_cluster")) return } - if trustedClusterBefore.GetMetadata().ID != trustedClusterI.GetMetadata().ID || false { + if trustedClusterBefore.GetMetadata().Revision != trustedClusterI.GetMetadata().Revision || false { break } diff --git a/terraform/provider/resource_teleport_user.go b/terraform/provider/resource_teleport_user.go index 190818c0f..197d88c5f 100755 --- a/terraform/provider/resource_teleport_user.go +++ b/terraform/provider/resource_teleport_user.go @@ -115,13 +115,12 @@ func (r resourceTeleportUser) Create(ctx context.Context, req tfsdk.CreateResour userI, err = r.p.Client.GetUser(ctx, id, false) if trace.IsNotFound(err) { if bErr := backoff.Do(ctx); bErr != nil { - resp.Diagnostics.Append(diagFromWrappedErr("Error reading User", trace.Wrap(err), "user")) + resp.Diagnostics.Append(diagFromWrappedErr("Error reading User", trace.Wrap(bErr), "user")) return } if tries >= r.p.RetryConfig.MaxTries { diagMessage := fmt.Sprintf("Error reading User (tried %d times) - state outdated, please import resource", tries) - resp.Diagnostics.Append(diagFromWrappedErr(diagMessage, trace.Wrap(err), "user")) - return + resp.Diagnostics.AddError(diagMessage, "user") } continue } @@ -249,7 +248,7 @@ func (r resourceTeleportUser) Update(ctx context.Context, req tfsdk.UpdateResour resp.Diagnostics.Append(diagFromWrappedErr("Error reading User", err, "user")) return } - if userBefore.GetMetadata().ID != userI.GetMetadata().ID || false { + if userBefore.GetMetadata().Revision != userI.GetMetadata().Revision || false { break } diff --git a/terraform/test/main_test.go b/terraform/test/main_test.go index c714ea628..a6c3c552f 100644 --- a/terraform/test/main_test.go +++ b/terraform/test/main_test.go @@ -84,6 +84,11 @@ func TestTerraformWithCache(t *testing.T) { }) } +func (s *TerraformBaseSuite) TearDownSuite() { + fmt.Println(s.Auth.Stdout()) + fmt.Println(s.Auth.Stderr()) +} + func (s *TerraformBaseSuite) SetupSuite() { var err error t := s.T() @@ -168,7 +173,7 @@ func (s *TerraformBaseSuite) SetupSuite() { identity_file = file("` + s.teleportConfig.Identity + `") retry_base_duration = "900ms" retry_cap_duration = "4s" - retry_max_tries = "12" + retry_max_tries = "2" } `