Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: removed 1.12.0 deprecated fields. #1418

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAccConfigDSCloudProviderAccessSetup_aws_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "created_date"),
resource.TestCheckResourceAttrSet(resourceName, "role_id"),
resource.TestCheckResourceAttrSet(dsName, "aws.atlas_assumed_role_external_id"),
resource.TestCheckResourceAttrSet(dsName, "aws_config.0.atlas_assumed_role_external_id"),
),
},
},
Expand Down
12 changes: 0 additions & 12 deletions mongodbatlas/data_source_mongodbatlas_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ func dataSourceMongoDBAtlasCluster() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"bi_connector": {
Type: schema.TypeMap,
Computed: true,
Deprecated: "use bi_connector_config instead",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"bi_connector_config": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -426,10 +418,6 @@ func dataSourceMongoDBAtlasClusterRead(ctx context.Context, d *schema.ResourceDa
return diag.FromErr(fmt.Errorf(errorClusterSetting, "state_name", clusterName, err))
}

if err := d.Set("bi_connector", flattenBiConnector(cluster.BiConnector)); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector", clusterName, err))
}

if err := d.Set("bi_connector_config", flattenBiConnectorConfig(cluster.BiConnector)); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector_config", clusterName, err))
}
Expand Down
9 changes: 0 additions & 9 deletions mongodbatlas/data_source_mongodbatlas_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ func dataSourceMongoDBAtlasClusters() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"bi_connector": {
Type: schema.TypeMap,
Computed: true,
Deprecated: "use bi_connector_config instead",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"bi_connector_config": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -406,7 +398,6 @@ func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.C
"provider_instance_size_name": clusters[i].ProviderSettings.InstanceSizeName,
"provider_name": clusters[i].ProviderSettings.ProviderName,
"provider_region_name": clusters[i].ProviderSettings.RegionName,
"bi_connector": flattenBiConnector(clusters[i].BiConnector),
"bi_connector_config": flattenBiConnectorConfig(clusters[i].BiConnector),
"replication_specs": flattenReplicationSpecs(clusters[i].ReplicationSpecs),
"labels": flattenLabels(clusters[i].Labels),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func testAccDSMongoDBAtlasGlobalClusterConfig(projectID, name string) string {
project_id = "%s"
name = "%s"
disk_size_gb = 80
provider_backup_enabled = false
cloud_backup = false
cluster_type = "GEOSHARDED"

// Provider Settings "block"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func testAccMongoDBAtlasDataSourceLDAPVerifyConfig(projectName, orgID, clusterNa
provider_name = "AWS"
provider_region_name = "US_EAST_2"
provider_instance_size_name = "M10"
provider_backup_enabled = true //enable cloud provider snapshots
cloud_backup = true //enable cloud provider snapshots
}

resource "mongodbatlas_ldap_verify" "test" {
Expand Down
12 changes: 0 additions & 12 deletions mongodbatlas/data_source_mongodbatlas_project_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ func dataSourceMongoDBAtlasProjectAPIKey() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"role_names": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Deprecated: fmt.Sprintf(DeprecationMessageParameterToResource, "v1.12.0", "project_assignment"),
},
"project_assignment": {
Type: schema.TypeSet,
Computed: true,
Expand Down Expand Up @@ -97,10 +89,6 @@ func dataSourceMongoDBAtlasProjectAPIKeyRead(ctx context.Context, d *schema.Reso
return diag.Errorf(errorProjectSetting, `project_assignment`, projectID, err)
}
}

if err := d.Set("role_names", flattenProjectAPIKeyRoles(projectID, val.Roles)); err != nil {
return diag.FromErr(fmt.Errorf("error setting `roles`: %s", err))
}
}

d.SetId(id.UniqueId())
Expand Down
9 changes: 0 additions & 9 deletions mongodbatlas/data_source_mongodbatlas_project_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ func dataSourceMongoDBAtlasProjectAPIKeys() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"role_names": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Deprecated: fmt.Sprintf(DeprecationMessageParameterToResource, "v1.12.0", "project_assignment"),
},
"project_assignment": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -125,7 +117,6 @@ func flattenProjectAPIKeys(ctx context.Context, conn *matlas.Client, projectID s
"description": apiKey.Desc,
"public_key": apiKey.PublicKey,
"private_key": apiKey.PrivateKey,
"role_names": flattenProjectAPIKeyRoles(projectID, apiKey.Roles),
}

projectAssignment, err := newProjectAssignment(ctx, conn, projectID, apiKey.ID)
Expand Down
19 changes: 0 additions & 19 deletions mongodbatlas/fw_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import (
"regexp"
"time"

"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
Expand Down Expand Up @@ -59,7 +57,6 @@ type tfAssumeRoleModel struct {
RoleARN types.String `tfsdk:"role_arn"`
SessionName types.String `tfsdk:"session_name"`
SourceIdentity types.String `tfsdk:"source_identity"`
DurationSeconds types.Int64 `tfsdk:"duration_seconds"`
}

func (p *MongodbtlasProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
Expand Down Expand Up @@ -131,20 +128,6 @@ var fwAssumeRoleSchema = schema.ListNestedBlock{
Description: "The duration, between 15 minutes and 12 hours, of the role session. Valid time units are ns, us (or µs), ms, s, h, or m.",
Validators: []validator.String{
cstmvalidator.ValidDurationBetween(15, 12*60),
stringvalidator.ConflictsWith(path.Expressions{
path.MatchRelative().AtParent().AtName("duration_seconds"),
}...),
},
},
"duration_seconds": schema.Int64Attribute{
Optional: true,
DeprecationMessage: "Use assume_role.duration instead",
Description: "The duration, in seconds, of the role session.",
Validators: []validator.Int64{
int64validator.Between(900, 43200),
int64validator.ConflictsWith(path.Expressions{
path.MatchRelative().AtParent().AtName("duration"),
}...),
},
},
"external_id": schema.StringAttribute{
Expand Down Expand Up @@ -262,8 +245,6 @@ func parseTfModel(ctx context.Context, tfAssumeRoleModel *tfAssumeRoleModel) *As
if !tfAssumeRoleModel.Duration.IsNull() {
duration, _ := time.ParseDuration(tfAssumeRoleModel.Duration.ValueString())
assumeRole.Duration = duration
} else if !tfAssumeRoleModel.DurationSeconds.IsNull() {
assumeRole.Duration = time.Duration(tfAssumeRoleModel.DurationSeconds.ValueInt64()) * time.Second
}

assumeRole.ExternalID = tfAssumeRoleModel.ExternalID.ValueString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName,
provider_name = "AWS"
provider_region_name = "US_EAST_2"
provider_instance_size_name = "M10"
provider_backup_enabled = true //enable cloud provider snapshots
cloud_backup = true //enable cloud provider snapshots
}

resource "mongodbatlas_database_user" "test" {
Expand Down
32 changes: 10 additions & 22 deletions mongodbatlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ var (
)

const (
endPointSTSDefault = "https://sts.amazonaws.com"
DeprecationMessage = "this resource is deprecated and will be removed in %s, please transition to %s"
DeprecationMessageParameterToResource = "this parameter is deprecated and will be removed in %s, please transition to %s"
MissingAuthAttrError = "either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set"
ProviderConfigError = "error in configuring the provider."
AWS = "AWS"
AZURE = "AZURE"
endPointSTSDefault = "https://sts.amazonaws.com"
DeprecationMessage = "this resource is deprecated and will be removed in %s, please transition to %s"
MissingAuthAttrError = "either Atlas Programmatic API Keys or AWS Secrets Manager attributes must be set"
ProviderConfigError = "error in configuring the provider."
AWS = "AWS"
AZURE = "AZURE"
GCP
)

Expand Down Expand Up @@ -703,19 +702,10 @@ func assumeRoleSchema() *schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"duration": {
Type: schema.TypeString,
Optional: true,
Description: "The duration, between 15 minutes and 12 hours, of the role session. Valid time units are ns, us (or µs), ms, s, h, or m.",
ValidateFunc: validAssumeRoleDuration,
ConflictsWith: []string{"assume_role.0.duration_seconds"},
},
"duration_seconds": {
Type: schema.TypeInt,
Optional: true,
Deprecated: fmt.Sprintf(DeprecationMessageParameterToResource, "v1.12.0", "assume_role.duration"),
Description: "The duration, in seconds, of the role session.",
ValidateFunc: validation.IntBetween(900, 43200),
ConflictsWith: []string{"assume_role.0.duration"},
Type: schema.TypeString,
Optional: true,
Description: "The duration, between 15 minutes and 12 hours, of the role session. Valid time units are ns, us (or µs), ms, s, h, or m.",
ValidateFunc: validAssumeRoleDuration,
},
"external_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -823,8 +813,6 @@ func expandAssumeRole(tfMap map[string]interface{}) *AssumeRole {
if v, ok := tfMap["duration"].(string); ok && v != "" {
duration, _ := time.ParseDuration(v)
assumeRole.Duration = duration
} else if v, ok := tfMap["duration_seconds"].(int); ok && v != 0 {
assumeRole.Duration = time.Duration(v) * time.Second
}

if v, ok := tfMap["external_id"].(string); ok && v != "" {
Expand Down
46 changes: 4 additions & 42 deletions mongodbatlas/resource_mongodbatlas_advanced_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,11 @@ func resourceMongoDBAtlasAdvancedCluster() *schema.Resource {
Optional: true,
Description: "Flag that indicates whether to retain backup snapshots for the deleted dedicated cluster",
},
"bi_connector": {
Type: schema.TypeList,
Optional: true,
ConflictsWith: []string{"bi_connector_config"},
Deprecated: fmt.Sprintf(DeprecationMessageParameterToResource, "v1.12.0", "bi_connector_config"),
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"read_preference": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
"bi_connector_config": {
Type: schema.TypeList,
Optional: true,
ConflictsWith: []string{"bi_connector"},
Computed: true,
MaxItems: 1,
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Expand Down Expand Up @@ -388,13 +365,6 @@ func resourceMongoDBAtlasAdvancedClusterCreate(ctx context.Context, d *schema.Re
if v, ok := d.GetOk("backup_enabled"); ok {
request.BackupEnabled = pointy.Bool(v.(bool))
}
if _, ok := d.GetOk("bi_connector"); ok {
biConnector, err := expandBiConnectorConfig(d)
if err != nil {
return diag.FromErr(fmt.Errorf(errorClusterAdvancedCreate, err))
}
request.BiConnector = biConnector
}
if _, ok := d.GetOk("bi_connector_config"); ok {
biConnector, err := expandBiConnectorConfig(d)
if err != nil {
Expand Down Expand Up @@ -523,10 +493,6 @@ func resourceMongoDBAtlasAdvancedClusterRead(ctx context.Context, d *schema.Reso
return diag.FromErr(fmt.Errorf(errorClusterAdvancedSetting, "backup_enabled", clusterName, err))
}

if err := d.Set("bi_connector", flattenBiConnectorConfig(cluster.BiConnector)); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterAdvancedSetting, "bi_connector", clusterName, err))
}

if err := d.Set("bi_connector_config", flattenBiConnectorConfig(cluster.BiConnector)); err != nil {
return diag.FromErr(fmt.Errorf(errorClusterAdvancedSetting, "bi_connector_config", clusterName, err))
}
Expand Down Expand Up @@ -669,10 +635,6 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
cluster.BiConnector, _ = expandBiConnectorConfig(d)
}

if d.HasChange("bi_connector") {
cluster.BiConnector, _ = expandBiConnectorConfig(d)
}

if d.HasChange("cluster_type") {
cluster.ClusterType = d.Get("cluster_type").(string)
}
Expand Down
Loading
Loading