Skip to content

Commit

Permalink
Merge pull request #31516 from PatMyron/patch-1
Browse files Browse the repository at this point in the history
source enum validations from AWS Go SDK
  • Loading branch information
ewbankkit authored May 30, 2023
2 parents 509e3c1 + 249323a commit 7ac2dd9
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 100 deletions.
11 changes: 3 additions & 8 deletions internal/service/cognitoidentity/pool_roles_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,9 @@ func ResourcePoolRolesAttachment() *schema.Resource {
ValidateFunc: validRoleMappingsRulesClaim,
},
"match_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
cognitoidentity.MappingRuleMatchTypeEquals,
cognitoidentity.MappingRuleMatchTypeContains,
cognitoidentity.MappingRuleMatchTypeStartsWith,
cognitoidentity.MappingRuleMatchTypeNotEqual,
}, false),
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(cognitoidentity.MappingRuleMatchType_Values(), false),
},
"role_arn": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,9 @@ func ResourceOrganizationCustomPolicyRule() *schema.Resource {
),
},
"maximum_execution_frequency": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
configservice.MaximumExecutionFrequencyOneHour,
configservice.MaximumExecutionFrequencyThreeHours,
configservice.MaximumExecutionFrequencySixHours,
configservice.MaximumExecutionFrequencyTwelveHours,
configservice.MaximumExecutionFrequencyTwentyFourHours,
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(configservice.MaximumExecutionFrequency_Values(), false),
},
"name": {
Type: schema.TypeString,
Expand Down
12 changes: 3 additions & 9 deletions internal/service/configservice/organization_custom_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,9 @@ func ResourceOrganizationCustomRule() *schema.Resource {
ValidateFunc: validation.StringLenBetween(1, 256),
},
"maximum_execution_frequency": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
configservice.MaximumExecutionFrequencyOneHour,
configservice.MaximumExecutionFrequencyThreeHours,
configservice.MaximumExecutionFrequencySixHours,
configservice.MaximumExecutionFrequencyTwelveHours,
configservice.MaximumExecutionFrequencyTwentyFourHours,
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(configservice.MaximumExecutionFrequency_Values(), false),
},
"name": {
Type: schema.TypeString,
Expand Down
12 changes: 3 additions & 9 deletions internal/service/configservice/organization_managed_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ func ResourceOrganizationManagedRule() *schema.Resource {
),
},
"maximum_execution_frequency": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
configservice.MaximumExecutionFrequencyOneHour,
configservice.MaximumExecutionFrequencyThreeHours,
configservice.MaximumExecutionFrequencySixHours,
configservice.MaximumExecutionFrequencyTwelveHours,
configservice.MaximumExecutionFrequencyTwentyFourHours,
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(configservice.MaximumExecutionFrequency_Values(), false),
},
"name": {
Type: schema.TypeString,
Expand Down
8 changes: 1 addition & 7 deletions internal/service/configservice/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@ import (
)

func validExecutionFrequency() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
configservice.MaximumExecutionFrequencyOneHour,
configservice.MaximumExecutionFrequencyThreeHours,
configservice.MaximumExecutionFrequencySixHours,
configservice.MaximumExecutionFrequencyTwelveHours,
configservice.MaximumExecutionFrequencyTwentyFourHours,
}, false)
return validation.StringInSlice(configservice.MaximumExecutionFrequency_Values(), false)
}
11 changes: 3 additions & 8 deletions internal/service/ec2/ec2_availability_zones_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,9 @@ func DataSourceAvailabilityZones() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},
"state": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
ec2.AvailabilityZoneStateAvailable,
ec2.AvailabilityZoneStateInformation,
ec2.AvailabilityZoneStateImpaired,
ec2.AvailabilityZoneStateUnavailable,
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(ec2.AvailabilityZoneState_Values(), false),
},
"zone_ids": {
Type: schema.TypeList,
Expand Down
15 changes: 4 additions & 11 deletions internal/service/guardduty/ipset.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ func ResourceIPSet() *schema.Resource {
Required: true,
},
"format": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
guardduty.IpSetFormatTxt,
guardduty.IpSetFormatStix,
guardduty.IpSetFormatOtxCsv,
guardduty.IpSetFormatAlienVault,
guardduty.IpSetFormatProofPoint,
guardduty.IpSetFormatFireEye,
}, false),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(guardduty.IpSetFormat_Values(), false),
},
"location": {
Type: schema.TypeString,
Expand Down
15 changes: 4 additions & 11 deletions internal/service/guardduty/threatintelset.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ func ResourceThreatIntelSet() *schema.Resource {
Required: true,
},
"format": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
guardduty.ThreatIntelSetFormatTxt,
guardduty.ThreatIntelSetFormatStix,
guardduty.ThreatIntelSetFormatOtxCsv,
guardduty.ThreatIntelSetFormatAlienVault,
guardduty.ThreatIntelSetFormatProofPoint,
guardduty.ThreatIntelSetFormatFireEye,
}, false),
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(guardduty.ThreatIntelSetFormat_Values(), false),
},
"location": {
Type: schema.TypeString,
Expand Down
10 changes: 3 additions & 7 deletions internal/service/opensearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,9 @@ func ResourceDomain() *schema.Resource {
Optional: true,
},
"warm_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
opensearchservice.OpenSearchWarmPartitionInstanceTypeUltrawarm1MediumSearch,
opensearchservice.OpenSearchWarmPartitionInstanceTypeUltrawarm1LargeSearch,
"ultrawarm1.xlarge.search",
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(opensearchservice.OpenSearchWarmPartitionInstanceType_Values(), false),
},
"zone_awareness_config": {
Type: schema.TypeList,
Expand Down
12 changes: 3 additions & 9 deletions internal/service/redshift/event_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@ func ResourceEventSubscription() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},
"source_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"cluster",
"cluster-parameter-group",
"cluster-security-group",
"cluster-snapshot",
"scheduled-action",
}, false),
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(redshift.SourceType_Values(), false),
},
"status": {
Type: schema.TypeString,
Expand Down
14 changes: 2 additions & 12 deletions internal/service/route53/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -131,17 +130,8 @@ func ResourceHealthCheck() *schema.Resource {
MinItems: 3,
MaxItems: 64,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
endpoints.UsWest1RegionID,
endpoints.UsWest2RegionID,
endpoints.UsEast1RegionID,
endpoints.EuWest1RegionID,
endpoints.SaEast1RegionID,
endpoints.ApSoutheast1RegionID,
endpoints.ApSoutheast2RegionID,
endpoints.ApNortheast1RegionID,
}, true),
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(route53.HealthCheckRegion_Values(), false),
},
Optional: true,
},
Expand Down

0 comments on commit 7ac2dd9

Please sign in to comment.