diff --git a/selectel/networking.go b/selectel/networking.go index 6607e582..ee4474a4 100644 --- a/selectel/networking.go +++ b/selectel/networking.go @@ -7,7 +7,6 @@ import ( "github.com/selectel/go-selvpcclient/v3/selvpcclient" "github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/subnets" - "github.com/terraform-providers/terraform-provider-selectel/selectel/internal/hashcode" ) func getPrefixLengthFromCIDR(cidr string) (int, error) { @@ -53,9 +52,3 @@ func subnetsMapsFromStructs(subnetsStructs []subnets.Subnet) []map[string]interf return associatedSubnets } - -// hashSubnets is a hash function to use with the "subnet" set. -func hashSubnets(v interface{}) int { - m := v.(map[string]interface{}) - return hashcode.String(fmt.Sprintf("%s-", m["network_id"].(string))) -} diff --git a/selectel/provider.go b/selectel/provider.go index da5c978a..a03d44aa 100644 --- a/selectel/provider.go +++ b/selectel/provider.go @@ -127,10 +127,7 @@ func Provider() *schema.Provider { "selectel_vpc_keypair_v2": resourceVPCKeypairV2(), "selectel_vpc_license_v2": resourceVPCLicenseV2(), "selectel_vpc_project_v2": resourceVPCProjectV2(), - "selectel_vpc_role_v2": resourceVPCRoleV2(), // DEPRECATED "selectel_vpc_subnet_v2": resourceVPCSubnetV2(), - "selectel_vpc_token_v2": resourceVPCTokenV2(), // DEPRECATED - "selectel_vpc_user_v2": resourceVPCUserV2(), // DEPRECATED "selectel_iam_serviceuser_v1": resourceIAMServiceUserV1(), "selectel_iam_user_v1": resourceIAMUserV1(), "selectel_iam_s3_credentials_v1": resourceIAMS3CredentialsV1(), @@ -138,8 +135,6 @@ func Provider() *schema.Provider { "selectel_iam_saml_federation_certificate_v1": resourceIAMSAMLFederationCertificateV1(), "selectel_iam_group_v1": resourceIAMGroupV1(), "selectel_iam_group_membership_v1": resourceIAMGroupMembershipV1(), - "selectel_vpc_vrrp_subnet_v2": resourceVPCVRRPSubnetV2(), // DEPRECATED - "selectel_vpc_crossregion_subnet_v2": resourceVPCCrossRegionSubnetV2(), // DEPRECATED "selectel_mks_cluster_v1": resourceMKSClusterV1(), "selectel_mks_nodegroup_v1": resourceMKSNodegroupV1(), "selectel_domains_domain_v1": resourceDomainsDomainV1(), diff --git a/selectel/regions.go b/selectel/regions.go index cd82f773..ca9c335f 100644 --- a/selectel/regions.go +++ b/selectel/regions.go @@ -5,7 +5,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/selectel/go-selvpcclient/v3/selvpcclient" - "github.com/terraform-providers/terraform-provider-selectel/selectel/internal/hashcode" ) func expandVPCV2Regions(rawRegions *schema.Set) []string { @@ -20,12 +19,6 @@ func expandVPCV2Regions(rawRegions *schema.Set) []string { return expandedRegions } -// hashRegions is a hash function to use with the "regions" set. -func hashRegions(v interface{}) int { - m := v.(map[string]interface{}) - return hashcode.String(fmt.Sprintf("%s-", m["region"].(string))) -} - func validateRegion(selvpcClient *selvpcclient.Client, serviceType string, region string) error { endpoints, err := selvpcClient.Catalog.GetEndpoints(serviceType) if err != nil { diff --git a/selectel/resource_selectel_vpc_crossregion_subnet_v2.go b/selectel/resource_selectel_vpc_crossregion_subnet_v2.go deleted file mode 100644 index 6c92d580..00000000 --- a/selectel/resource_selectel_vpc_crossregion_subnet_v2.go +++ /dev/null @@ -1,124 +0,0 @@ -package selectel - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceVPCCrossRegionSubnetV2() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceVPCCrossRegionSubnetV2Create, - ReadContext: resourceVPCCrossRegionSubnetV2Read, - DeleteContext: resourceVPCCrossRegionSubnetV2Delete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "regions": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - Set: hashRegions, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - }, - }, - "cidr": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - "servers": { - Type: schema.TypeSet, - Computed: true, - Set: hashServers, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "subnets": { - Type: schema.TypeSet, - Computed: true, - Set: hashSubnets, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Computed: true, - }, - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "network_id": { - Type: schema.TypeString, - Computed: true, - }, - "subnet_id": { - Type: schema.TypeString, - Computed: true, - }, - "project_id": { - Type: schema.TypeString, - Computed: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Computed: true, - }, - "vtep_ip_address": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func resourceVPCCrossRegionSubnetV2Create(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_crossregion_subnet_v2")) -} - -func resourceVPCCrossRegionSubnetV2Read(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_crossregion_subnet_v2")) -} - -func resourceVPCCrossRegionSubnetV2Delete(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_crossregion_subnet_v2")) -} diff --git a/selectel/resource_selectel_vpc_role_v2.go b/selectel/resource_selectel_vpc_role_v2.go deleted file mode 100644 index 561901c9..00000000 --- a/selectel/resource_selectel_vpc_role_v2.go +++ /dev/null @@ -1,43 +0,0 @@ -package selectel - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceVPCRoleV2() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceVPCRoleV2Create, - ReadContext: resourceVPCRoleV2Read, - DeleteContext: resourceVPCRoleV2Delete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "user_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - } -} - -func resourceVPCRoleV2Create(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_role_v2")) -} - -func resourceVPCRoleV2Read(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_role_v2")) -} - -func resourceVPCRoleV2Delete(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_role_v2")) -} diff --git a/selectel/resource_selectel_vpc_token_v2.go b/selectel/resource_selectel_vpc_token_v2.go deleted file mode 100644 index c3154521..00000000 --- a/selectel/resource_selectel_vpc_token_v2.go +++ /dev/null @@ -1,42 +0,0 @@ -package selectel - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceVPCTokenV2() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceVPCTokenV2Create, - ReadContext: resourceVPCTokenV2Read, - DeleteContext: resourceVPCTokenV2Delete, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - ConflictsWith: []string{"account_name"}, - Optional: true, - ForceNew: true, - }, - "account_name": { - Type: schema.TypeString, - ConflictsWith: []string{"project_id"}, - Optional: true, - ForceNew: true, - }, - }, - } -} - -func resourceVPCTokenV2Create(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_token_v2")) -} - -func resourceVPCTokenV2Read(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_token_v2")) -} - -func resourceVPCTokenV2Delete(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_token_v2")) -} diff --git a/selectel/resource_selectel_vpc_user_v2.go b/selectel/resource_selectel_vpc_user_v2.go deleted file mode 100644 index c3741ecc..00000000 --- a/selectel/resource_selectel_vpc_user_v2.go +++ /dev/null @@ -1,79 +0,0 @@ -package selectel - -import ( - "context" - "unicode" - - "github.com/hashicorp/go-cty/cty" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourceVPCUserV2() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceVPCUserV2Create, - ReadContext: resourceVPCUserV2Read, - UpdateContext: resourceVPCUserV2Update, - DeleteContext: resourceVPCUserV2Delete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: false, - }, - "password": { - Type: schema.TypeString, - Required: true, - ForceNew: false, - ValidateDiagFunc: func(i interface{}, _ cty.Path) diag.Diagnostics { - password := i.(string) - if len(password) < 8 { - return diag.Errorf("password must be at least 8 characters long") - } - - chrType := 0 - for _, r := range password { - switch { - case unicode.IsDigit(r): - chrType |= 1 - case unicode.IsLower(r): - chrType |= 2 - case unicode.IsUpper(r): - chrType |= 4 - } - } - if chrType != 7 { - return diag.Errorf("password must contain at least one digit, one lowercase and one uppercase character") - } - - return nil - }, - }, - "enabled": { - Type: schema.TypeBool, - Optional: true, - Default: true, - ForceNew: false, - }, - }, - } -} - -func resourceVPCUserV2Create(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_user_v2")) -} - -func resourceVPCUserV2Read(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_user_v2")) -} - -func resourceVPCUserV2Update(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_user_v2")) -} - -func resourceVPCUserV2Delete(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_user_v2")) -} diff --git a/selectel/resource_selectel_vpc_vrrp_subnet_v2.go b/selectel/resource_selectel_vpc_vrrp_subnet_v2.go deleted file mode 100644 index b7bb2933..00000000 --- a/selectel/resource_selectel_vpc_vrrp_subnet_v2.go +++ /dev/null @@ -1,133 +0,0 @@ -package selectel - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/selectel/go-selvpcclient/v3/selvpcclient" -) - -func resourceVPCVRRPSubnetV2() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceVPCVRRPSubnetV2Create, - ReadContext: resourceVPCVRRPSubnetV2Read, - DeleteContext: resourceVPCVRRPSubnetV2Delete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - Schema: map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "master_region": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "slave_region": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "prefix_length": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Default: 29, - ValidateFunc: validation.IntBetween(24, 29), - }, - "ip_version": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: selvpcclient.IPv4, - ValidateFunc: validation.StringInSlice([]string{ - string(selvpcclient.IPv4), - string(selvpcclient.IPv6), - }, false), - }, - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - "subnets": { - Type: schema.TypeSet, - Computed: true, - Set: hashSubnets, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "network_id": { - Type: schema.TypeString, - Computed: true, - }, - "subnet_id": { - Type: schema.TypeString, - Computed: true, - }, - "region": { - Type: schema.TypeString, - Computed: true, - }, - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "vlan_id": { - Type: schema.TypeInt, - Computed: true, - }, - "project_id": { - Type: schema.TypeString, - Computed: true, - }, - "vtep_ip_address": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "servers": { - Type: schema.TypeSet, - Computed: true, - Set: hashServers, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func resourceVPCVRRPSubnetV2Create(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_vrrp_subnet_v2")) -} - -func resourceVPCVRRPSubnetV2Read(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_vrrp_subnet_v2")) -} - -func resourceVPCVRRPSubnetV2Delete(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return diag.FromErr(errResourceDeprecated("selectel_vpc_vrrp_subnet_v2")) -}