diff --git a/resources/services/acm/certificates.go b/resources/services/acm/certificates.go index 8808b942a..189bbdc88 100644 --- a/resources/services/acm/certificates.go +++ b/resources/services/acm/certificates.go @@ -2,7 +2,6 @@ package acm import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/acm" @@ -60,13 +59,13 @@ func AcmCertificates() *schema.Table { Name: "domain_validation_options", Description: "Contains information about the initial validation of each domain name that occurs as a result of the RequestCertificate request.", Type: schema.TypeJSON, - Resolver: resolveACMCertificateJSONField(func(cd *types.CertificateDetail) interface{} { return cd.DomainValidationOptions }), + Resolver: schema.PathResolver("DomainValidationOptions"), }, { Name: "extended_key_usages", Description: "Contains a list of Extended Key Usage X.509 v3 extension objects.", Type: schema.TypeJSON, - Resolver: resolveACMCertificateJSONField(func(cd *types.CertificateDetail) interface{} { return cd.ExtendedKeyUsages }), + Resolver: schema.PathResolver("ExtendedKeyUsages"), }, { Name: "failure_reason", @@ -102,7 +101,7 @@ func AcmCertificates() *schema.Table { Name: "key_usages", Description: "A list of Key Usage X.509 v3 extension objects. Each object is a string value that identifies the purpose of the public key contained in the certificate.", Type: schema.TypeStringArray, - Resolver: resolveACMCertificateKeyUsages, + Resolver: schema.PathResolver("KeyUsages.Name"), }, { Name: "not_after", @@ -129,12 +128,7 @@ func AcmCertificates() *schema.Table { Name: "renewal_summary_domain_validation_options", Description: "Contains information about the validation of each domain name in the certificate, as it pertains to ACM's managed renewal.", Type: schema.TypeJSON, - Resolver: resolveACMCertificateJSONField(func(cd *types.CertificateDetail) interface{} { - if cd.RenewalSummary == nil { - return nil - } - return cd.RenewalSummary.DomainValidationOptions - }), + Resolver: schema.PathResolver("RenewalSummary.DomainValidationOptions"), }, { Name: "renewal_summary_status", @@ -234,26 +228,6 @@ func fetchAcmCertificates(ctx context.Context, meta schema.ClientMeta, parent *s return nil } -func resolveACMCertificateKeyUsages(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - cert := resource.Item.(*types.CertificateDetail) - result := make([]string, 0, len(cert.KeyUsages)) - for _, v := range cert.KeyUsages { - result = append(result, string(v.Name)) - } - return diag.WrapError(resource.Set(c.Name, result)) -} - -func resolveACMCertificateJSONField(getter func(*types.CertificateDetail) interface{}) func(context.Context, schema.ClientMeta, *schema.Resource, schema.Column) error { - return func(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - cert := resource.Item.(*types.CertificateDetail) - b, err := json.Marshal(getter(cert)) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) - } -} - func resolveACMCertificateTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { cert := resource.Item.(*types.CertificateDetail) cl := meta.(*client.Client) diff --git a/resources/services/applicationautoscaling/policies.go b/resources/services/applicationautoscaling/policies.go index 1f75559d1..150b096e6 100644 --- a/resources/services/applicationautoscaling/policies.go +++ b/resources/services/applicationautoscaling/policies.go @@ -2,7 +2,6 @@ package applicationautoscaling import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/applicationautoscaling" @@ -82,19 +81,19 @@ func ApplicationautoscalingPolicies() *schema.Table { Name: "alarms", Description: "The CloudWatch alarms associated with the scaling policy.", Type: schema.TypeJSON, - Resolver: resolveApplicationautoscalingPolicyAlarms, + Resolver: schema.PathResolver("Alarms"), }, { Name: "step_scaling_policy_configuration", Description: "A step scaling policy.", Type: schema.TypeJSON, - Resolver: resolveApplicationautoscalingPolicyStepScalingPolicyConfiguration, + Resolver: schema.PathResolver("StepScalingPolicyConfiguration"), }, { Name: "target_tracking_scaling_policy_configuration", Description: "A target tracking scaling policy.", Type: schema.TypeJSON, - Resolver: resolveApplicationautoscalingPolicyTargetTrackingScalingPolicyConfiguration, + Resolver: schema.PathResolver("TargetTrackingScalingPolicyConfiguration"), }, }, } @@ -128,27 +127,3 @@ func fetchApplicationautoscalingPolicies(ctx context.Context, meta schema.Client return nil } -func resolveApplicationautoscalingPolicyAlarms(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ScalingPolicy) - if r.Alarms == nil { - return nil - } - b, _ := json.Marshal(r.Alarms) - return diag.WrapError(resource.Set(c.Name, b)) -} -func resolveApplicationautoscalingPolicyStepScalingPolicyConfiguration(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ScalingPolicy) - if r.StepScalingPolicyConfiguration == nil { - return nil - } - b, _ := json.Marshal(r.StepScalingPolicyConfiguration) - return diag.WrapError(resource.Set(c.Name, b)) -} -func resolveApplicationautoscalingPolicyTargetTrackingScalingPolicyConfiguration(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ScalingPolicy) - if r.TargetTrackingScalingPolicyConfiguration == nil { - return nil - } - b, _ := json.Marshal(r.TargetTrackingScalingPolicyConfiguration) - return diag.WrapError(resource.Set(c.Name, b)) -} diff --git a/resources/services/autoscaling/groups.go b/resources/services/autoscaling/groups.go index c46865b9d..f1337ac0d 100644 --- a/resources/services/autoscaling/groups.go +++ b/resources/services/autoscaling/groups.go @@ -2,7 +2,6 @@ package autoscaling import ( "context" - "encoding/json" "errors" "regexp" @@ -217,7 +216,7 @@ func AutoscalingGroups() *schema.Table { { Name: "aws_autoscaling_group_instances", Description: "Describes an EC2 instance.", - Resolver: fetchAutoscalingGroupInstances, + Resolver: schema.PathTableResolver("Instances"), Columns: []schema.Column{ { Name: "group_cq_id", @@ -294,7 +293,7 @@ func AutoscalingGroups() *schema.Table { { Name: "aws_autoscaling_group_tags", Description: "Describes a tag for an Auto Scaling group.", - Resolver: fetchAutoscalingGroupTags, + Resolver: schema.PathTableResolver("Tags"), Columns: []schema.Column{ { Name: "group_cq_id", @@ -414,7 +413,7 @@ func AutoscalingGroups() *schema.Table { Name: "step_adjustments", Description: "A set of adjustments that enable you to scale based on the size of the alarm breach.", Type: schema.TypeJSON, - Resolver: resolveAutoscalingGroupScalingPoliciesStepAdjustments, + Resolver: schema.PathResolver("StepAdjustments"), }, { Name: "target_tracking_configuration_target_value", @@ -684,16 +683,6 @@ func resolveAutoscalingGroupsSuspendedProcesses(ctx context.Context, meta schema return diag.WrapError(resource.Set(c.Name, j)) } -func fetchAutoscalingGroupInstances(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(autoscalingGroupWrapper) - res <- p.Instances - return nil -} -func fetchAutoscalingGroupTags(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(autoscalingGroupWrapper) - res <- p.Tags - return nil -} func fetchAutoscalingGroupScalingPolicies(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { p := parent.Item.(autoscalingGroupWrapper) cl := meta.(*client.Client) @@ -727,14 +716,6 @@ func resolveAutoscalingGroupScalingPoliciesAlarms(ctx context.Context, meta sche } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveAutoscalingGroupScalingPoliciesStepAdjustments(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.ScalingPolicy) - data, err := json.Marshal(p.StepAdjustments) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func resolveAutoscalingGroupScalingPoliciesTargetTrackingConfigurationCustomizedMetricDimensions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { p := resource.Item.(types.ScalingPolicy) if p.TargetTrackingConfiguration == nil || p.TargetTrackingConfiguration.CustomizedMetricSpecification == nil { diff --git a/resources/services/backup/plans.go b/resources/services/backup/plans.go index ba996b9c3..e6fae9f5f 100644 --- a/resources/services/backup/plans.go +++ b/resources/services/backup/plans.go @@ -2,11 +2,9 @@ package backup import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/backup" - "github.com/aws/aws-sdk-go-v2/service/backup/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -78,7 +76,7 @@ func Plans() *schema.Table { Name: "advanced_backup_settings", Description: "Contains a list of backup options for a resource type.", Type: schema.TypeJSON, - Resolver: resolvePlanAdvancedBackupSettings, + Resolver: schema.PathResolver("AdvancedBackupSettings"), IgnoreInTests: true, }, { @@ -92,7 +90,7 @@ func Plans() *schema.Table { { Name: "aws_backup_plan_rules", Description: "Specifies a scheduled task used to back up a selection of resources.", - Resolver: fetchPlanRules, + Resolver: schema.PathTableResolver("BackupPlan.Rules"), IgnoreError: client.IgnoreAccessDeniedServiceDisabled, Columns: []schema.Column{ { @@ -121,7 +119,7 @@ func Plans() *schema.Table { Name: "copy_actions", Description: "The details of the copy operation.", Type: schema.TypeJSON, - Resolver: resolveRuleCopyActions, + Resolver: schema.PathResolver("CopyActions"), IgnoreInTests: true, }, { @@ -211,13 +209,13 @@ func Plans() *schema.Table { Name: "conditions", Description: "A list of conditions that you define to assign resources to your backup plans using tags.", Type: schema.TypeJSON, - Resolver: resolveSelectionConditions, + Resolver: schema.PathResolver("BackupSelection.Conditions"), }, { Name: "list_of_tags", Description: "A list of conditions that you define to assign resources to your backup plans using tags.", Type: schema.TypeJSON, - Resolver: resolveSelectionListOfTags, + Resolver: schema.PathResolver("BackupSelection.ListOfTags"), }, { Name: "not_resources", @@ -273,15 +271,6 @@ func fetchBackupPlans(ctx context.Context, meta schema.ClientMeta, parent *schem return nil } -func resolvePlanAdvancedBackupSettings(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - plan := resource.Item.(backup.GetBackupPlanOutput) - b, err := json.Marshal(plan.AdvancedBackupSettings) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} - func resolvePlanTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { plan := resource.Item.(backup.GetBackupPlanOutput) cl := meta.(*client.Client) @@ -342,45 +331,3 @@ func fetchBackupSelections(ctx context.Context, meta schema.ClientMeta, parent * } return nil } - -func fetchPlanRules(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - plan := parent.Item.(backup.GetBackupPlanOutput) - if plan.BackupPlan == nil { - return nil - } - res <- plan.BackupPlan.Rules - return nil -} - -func resolveRuleCopyActions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - rule := resource.Item.(types.BackupRule) - b, err := json.Marshal(rule.CopyActions) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} - -func resolveSelectionConditions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - s := resource.Item.(backup.GetBackupSelectionOutput) - if s.BackupSelection == nil || s.BackupSelection.Conditions == nil { - return nil - } - b, err := json.Marshal(s.BackupSelection.Conditions) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} - -func resolveSelectionListOfTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - s := resource.Item.(backup.GetBackupSelectionOutput) - if s.BackupSelection == nil || len(s.BackupSelection.ListOfTags) == 0 { - return nil - } - b, err := json.Marshal(s.BackupSelection.ListOfTags) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} diff --git a/resources/services/backup/vaults.go b/resources/services/backup/vaults.go index ba82b1c46..788ac9108 100644 --- a/resources/services/backup/vaults.go +++ b/resources/services/backup/vaults.go @@ -2,7 +2,6 @@ package backup import ( "context" - "encoding/json" "errors" "strings" @@ -160,7 +159,7 @@ func Vaults() *schema.Table { Name: "created_by", Description: "Contains identifying information about the creation of a recovery point.", Type: schema.TypeJSON, - Resolver: resolveVaultRecoveryPointCreatedBy, + Resolver: schema.PathResolver("CreatedBy"), }, { Name: "creation_date", @@ -356,15 +355,6 @@ func fetchVaultRecoveryPoints(ctx context.Context, meta schema.ClientMeta, paren return nil } -func resolveVaultRecoveryPointCreatedBy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - rp := resource.Item.(types.RecoveryPointByBackupVault) - b, err := json.Marshal(rp.CreatedBy) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} - func resolveRecoveryPointTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { rp := resource.Item.(types.RecoveryPointByBackupVault) if rp.ResourceArn == nil || rp.RecoveryPointArn == nil { diff --git a/resources/services/cloudfront/distributions.go b/resources/services/cloudfront/distributions.go index b24368d7a..4d391beeb 100644 --- a/resources/services/cloudfront/distributions.go +++ b/resources/services/cloudfront/distributions.go @@ -374,7 +374,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_default_cache_behavior_functions", Description: "A complex type that contains a Lambda function association.", - Resolver: fetchCloudfrontDistributionDefaultCacheBehaviorLambdaFunctions, + Resolver: schema.PathTableResolver("DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -404,7 +404,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_origins", Description: "An origin", - Resolver: fetchCloudfrontDistributionOrigins, + Resolver: schema.PathTableResolver("DistributionConfig.Origins.Items"), Columns: []schema.Column{ { Name: "distribution_cq_id", @@ -508,7 +508,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_cache_behaviors", Description: "A complex type that describes how CloudFront processes requests", - Resolver: fetchCloudfrontDistributionCacheBehaviors, + Resolver: schema.PathTableResolver("DistributionConfig.CacheBehaviors.Items"), Columns: []schema.Column{ { Name: "distribution_cq_id", @@ -657,7 +657,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_cache_behavior_lambda_functions", Description: "A complex type that contains a Lambda function association.", - Resolver: fetchCloudfrontDistributionCacheBehaviorLambdaFunctions, + Resolver: schema.PathTableResolver("LambdaFunctionAssociations.Items"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -689,7 +689,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_custom_error_responses", Description: "A complex type that controls: * Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer. * How long CloudFront caches HTTP status codes in the 4xx and 5xx range. For more information about custom error pages, see Customizing Error Responses (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html) in the Amazon CloudFront Developer Guide.", - Resolver: fetchCloudfrontDistributionCustomErrorResponses, + Resolver: schema.PathTableResolver("DistributionConfig.CustomErrorResponses.Items"), Columns: []schema.Column{ { Name: "distribution_cq_id", @@ -723,7 +723,7 @@ func CloudfrontDistributions() *schema.Table { { Name: "aws_cloudfront_distribution_origin_groups", Description: "An origin group includes two origins (a primary origin and a second origin to failover to) and a failover criteria that you specify", - Resolver: fetchCloudfrontDistributionOriginGroups, + Resolver: schema.PathTableResolver("DistributionConfig.OriginGroups.Items"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -736,7 +736,7 @@ func CloudfrontDistributions() *schema.Table { Name: "failover_criteria_status_codes", Description: "The items (status codes) for an origin group.", Type: schema.TypeIntArray, - Resolver: resolveCloudfrontDistributionOriginGroupsFailoverCriteriaStatusCodes, + Resolver: schema.PathResolver("FailoverCriteria.StatusCodes.Items"), }, { Name: "id", @@ -747,7 +747,7 @@ func CloudfrontDistributions() *schema.Table { Name: "members_origin_ids", Description: "Items (origins) in an origin group.", Type: schema.TypeStringArray, - Resolver: resolveCloudfrontDistributionOriginGroupsMembersOriginIds, + Resolver: schema.PathResolver("Members.Items.OriginId"), }, }, }, @@ -837,29 +837,7 @@ func resolveCloudfrontDistributionsAliasIcpRecordals(ctx context.Context, meta s } return diag.WrapError(resource.Set(c.Name, j)) } -func fetchCloudfrontDistributionDefaultCacheBehaviorLambdaFunctions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(types.Distribution) - if r.DistributionConfig == nil { - return nil - } - if r.DistributionConfig.DefaultCacheBehavior == nil { - return nil - } - if r.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations == nil { - return nil - } - res <- r.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items - return nil -} -func fetchCloudfrontDistributionOrigins(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - distribution := parent.Item.(types.Distribution) - if distribution.DistributionConfig.Origins == nil { - return nil - } - res <- distribution.DistributionConfig.Origins.Items - return nil -} func resolveCloudfrontDistributionOriginsCustomHeaders(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.Origin) if r.CustomHeaders == nil { @@ -871,54 +849,3 @@ func resolveCloudfrontDistributionOriginsCustomHeaders(ctx context.Context, meta } return diag.WrapError(resource.Set(c.Name, tags)) } -func fetchCloudfrontDistributionCacheBehaviors(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - distribution := parent.Item.(types.Distribution) - if distribution.DistributionConfig.CacheBehaviors != nil { - res <- distribution.DistributionConfig.CacheBehaviors.Items - } - return nil -} -func fetchCloudfrontDistributionCacheBehaviorLambdaFunctions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cacheBehavior := parent.Item.(types.CacheBehavior) - if cacheBehavior.LambdaFunctionAssociations == nil { - return nil - } - res <- cacheBehavior.LambdaFunctionAssociations.Items - return nil -} -func fetchCloudfrontDistributionCustomErrorResponses(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - distribution := parent.Item.(types.Distribution) - if distribution.DistributionConfig.CustomErrorResponses != nil { - res <- distribution.DistributionConfig.CustomErrorResponses.Items - } - return nil -} -func fetchCloudfrontDistributionOriginGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - distribution := parent.Item.(types.Distribution) - if distribution.DistributionConfig.OriginGroups != nil { - res <- distribution.DistributionConfig.OriginGroups.Items - } - return nil -} -func resolveCloudfrontDistributionOriginGroupsFailoverCriteriaStatusCodes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - origin := resource.Item.(types.OriginGroup) - if origin.FailoverCriteria == nil || origin.FailoverCriteria.StatusCodes == nil { - return nil - } - data := make([]int, 0, *origin.FailoverCriteria.StatusCodes.Quantity) - for _, i := range origin.FailoverCriteria.StatusCodes.Items { - data = append(data, int(i)) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveCloudfrontDistributionOriginGroupsMembersOriginIds(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.OriginGroup) - if r.Members == nil { - return nil - } - members := make([]string, 0, *r.Members.Quantity) - for _, t := range r.Members.Items { - members = append(members, *t.OriginId) - } - return diag.WrapError(resource.Set(c.Name, members)) -} diff --git a/resources/services/cloudwatch/alarms.go b/resources/services/cloudwatch/alarms.go index 54d13abf3..7172c0949 100644 --- a/resources/services/cloudwatch/alarms.go +++ b/resources/services/cloudwatch/alarms.go @@ -180,7 +180,7 @@ func CloudwatchAlarms() *schema.Table { { Name: "aws_cloudwatch_alarm_metrics", Description: "This structure is used in both GetMetricData and PutMetricAlarm.", - Resolver: fetchCloudwatchAlarmMetrics, + Resolver: schema.PathTableResolver("Metrics"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -300,11 +300,7 @@ func resolveCloudwatchAlarmDimensions(ctx context.Context, meta schema.ClientMet } return diag.WrapError(resource.Set("dimensions", dimensions)) } -func fetchCloudwatchAlarmMetrics(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - alarm := parent.Item.(types.MetricAlarm) - res <- alarm.Metrics - return nil -} + func resolveCloudwatchAlarmMetricMetricStatMetricDimensions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { metric := resource.Item.(types.MetricDataQuery) if metric.MetricStat == nil || metric.MetricStat.Metric == nil { diff --git a/resources/services/cloudwatchlogs/filters.go b/resources/services/cloudwatchlogs/filters.go index 81582345d..95cdf94e1 100644 --- a/resources/services/cloudwatchlogs/filters.go +++ b/resources/services/cloudwatchlogs/filters.go @@ -5,7 +5,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" - "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -61,7 +60,7 @@ func CloudwatchlogsFilters() *schema.Table { { Name: "aws_cloudwatchlogs_filter_metric_transformations", Description: "Indicates how to transform ingested log events to metric data in a CloudWatch metric.", - Resolver: fetchCloudwatchlogsFilterMetricTransformations, + Resolver: schema.PathTableResolver("MetricTransformations"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -118,7 +117,3 @@ func fetchCloudwatchlogsFilters(ctx context.Context, meta schema.ClientMeta, par } return nil } -func fetchCloudwatchlogsFilterMetricTransformations(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - res <- parent.Item.(types.MetricFilter).MetricTransformations - return nil -} diff --git a/resources/services/codebuild/projects.go b/resources/services/codebuild/projects.go index 7b8a3421d..0cb55fa25 100644 --- a/resources/services/codebuild/projects.go +++ b/resources/services/codebuild/projects.go @@ -398,7 +398,7 @@ func CodebuildProjects() *schema.Table { Name: "tags", Description: "A list of tag key and value pairs associated with this build project", Type: schema.TypeJSON, - Resolver: resolveCodebuildProjectsTags, + Resolver: client.ResolveTags, }, { Name: "timeout_in_minutes", @@ -470,7 +470,7 @@ func CodebuildProjects() *schema.Table { { Name: "aws_codebuild_project_environment_variables", Description: "Information about an environment variable for a build project or a build.", - Resolver: fetchCodebuildProjectEnvironmentVariables, + Resolver: schema.PathTableResolver("Environment.EnvironmentVariables"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -499,7 +499,7 @@ func CodebuildProjects() *schema.Table { { Name: "aws_codebuild_project_file_system_locations", Description: "Information about a file system created by Amazon Elastic File System (EFS)", - Resolver: fetchCodebuildProjectFileSystemLocations, + Resolver: schema.PathTableResolver("FileSystemLocations"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -538,7 +538,7 @@ func CodebuildProjects() *schema.Table { { Name: "aws_codebuild_project_secondary_artifacts", Description: "Information about the build output artifacts for the build project.", - Resolver: fetchCodebuildProjectSecondaryArtifacts, + Resolver: schema.PathTableResolver("SecondaryArtifacts"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -602,7 +602,7 @@ func CodebuildProjects() *schema.Table { { Name: "aws_codebuild_project_secondary_sources", Description: "Information about the build input source code for the build project.", - Resolver: fetchCodebuildProjectSecondarySources, + Resolver: schema.PathTableResolver("SecondarySources"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -723,14 +723,9 @@ func resolveCodebuildProjectsSecondarySourceVersions(ctx context.Context, meta s } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveCodebuildProjectsTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Project) - j := map[string]interface{}{} - for _, v := range p.Tags { - j[*v.Key] = *v.Value - } - return diag.WrapError(resource.Set(c.Name, j)) -} + +// currently SDK is not able to support serializing [][]types.WebhookFilter +// so it must be done manually func resolveCodebuildProjectsWebhookFilterGroups(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { p := resource.Item.(types.Project) if p.Webhook == nil { @@ -742,26 +737,3 @@ func resolveCodebuildProjectsWebhookFilterGroups(ctx context.Context, meta schem } return diag.WrapError(resource.Set(c.Name, data)) } -func fetchCodebuildProjectEnvironmentVariables(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.Project) - if p.Environment == nil { - return nil - } - res <- p.Environment.EnvironmentVariables - return nil -} -func fetchCodebuildProjectFileSystemLocations(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.Project) - res <- p.FileSystemLocations - return nil -} -func fetchCodebuildProjectSecondaryArtifacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.Project) - res <- p.SecondaryArtifacts - return nil -} -func fetchCodebuildProjectSecondarySources(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.Project) - res <- p.SecondarySources - return nil -} diff --git a/resources/services/cognito/identity_pools.go b/resources/services/cognito/identity_pools.go index ebbe7fded..aff37e8d9 100644 --- a/resources/services/cognito/identity_pools.go +++ b/resources/services/cognito/identity_pools.go @@ -94,7 +94,7 @@ func CognitoIdentityPools() *schema.Table { { Name: "aws_cognito_identity_pool_cognito_identity_providers", Description: "A provider representing an Amazon Cognito user pool and its client ID.", - Resolver: fetchCognitoIdentityPoolCognitoIdentityProviders, + Resolver: schema.PathTableResolver("CognitoIdentityProviders"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -161,9 +161,3 @@ func fetchCognitoIdentityPools(ctx context.Context, meta schema.ClientMeta, pare } return nil } - -func fetchCognitoIdentityPoolCognitoIdentityProviders(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - pool := parent.Item.(*cognitoidentity.DescribeIdentityPoolOutput) - res <- pool.CognitoIdentityProviders - return nil -} diff --git a/resources/services/cognito/user_pools.go b/resources/services/cognito/user_pools.go index c6a9de36a..e0ee429e1 100644 --- a/resources/services/cognito/user_pools.go +++ b/resources/services/cognito/user_pools.go @@ -2,7 +2,6 @@ package cognito import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider" @@ -39,7 +38,7 @@ func CognitoUserPools() *schema.Table { Name: "account_recovery_setting", Description: "Use this setting to define which verified available method a user can use to recover their password when they call ForgotPassword", Type: schema.TypeJSON, - Resolver: resolveCognitoUserPoolAccountRecoverySetting, + Resolver: schema.PathResolver("AccountRecoverySetting"), IgnoreInTests: true, }, { @@ -445,7 +444,7 @@ func CognitoUserPools() *schema.Table { { Name: "aws_cognito_user_pool_schema_attributes", Description: "Contains information about the schema attribute.", - Resolver: fetchCognitoUserPoolSchemaAttributes, + Resolver: schema.PathTableResolver("SchemaAttributes"), Columns: []schema.Column{ { Name: "user_pool_cq_id", @@ -614,21 +613,6 @@ func fetchCognitoUserPools(ctx context.Context, meta schema.ClientMeta, parent * return nil } -func resolveCognitoUserPoolAccountRecoverySetting(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - pool := resource.Item.(*types.UserPoolType) - data, err := json.Marshal(pool.AccountRecoverySetting) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} - -func fetchCognitoUserPoolSchemaAttributes(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - pool := parent.Item.(*types.UserPoolType) - res <- pool.SchemaAttributes - return nil -} - func fetchCognitoUserPoolIdentityProviders(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { pool := parent.Item.(*types.UserPoolType) c := meta.(*client.Client) diff --git a/resources/services/dax/clusters.go b/resources/services/dax/clusters.go index 4cf54b995..1b927344b 100644 --- a/resources/services/dax/clusters.go +++ b/resources/services/dax/clusters.go @@ -166,7 +166,7 @@ func DaxClusters() *schema.Table { { Name: "aws_dax_cluster_nodes", Description: "Represents an individual node within a DAX cluster.", - Resolver: fetchDaxClusterNodes, + Resolver: schema.PathTableResolver("Nodes"), Columns: []schema.Column{ { Name: "cluster_cq_id", @@ -275,10 +275,3 @@ func resolveDaxClusterSecurityGroups(ctx context.Context, meta schema.ClientMeta } return diag.WrapError(resource.Set(c.Name, val)) } -func fetchDaxClusterNodes(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(types.Cluster) - for i := range r.Nodes { - res <- r.Nodes[i] - } - return nil -} diff --git a/resources/services/directconnect/connections.go b/resources/services/directconnect/connections.go index aece14ae6..8edfc4c0c 100644 --- a/resources/services/directconnect/connections.go +++ b/resources/services/directconnect/connections.go @@ -127,7 +127,7 @@ func DirectconnectConnections() *schema.Table { Name: "tags", Description: "The tags associated with the connection.", Type: schema.TypeJSON, - Resolver: resolveDirectconnectConnectionTags, + Resolver: client.ResolveTags, }, { Name: "vlan", @@ -139,7 +139,7 @@ func DirectconnectConnections() *schema.Table { { Name: "aws_directconnect_connection_mac_sec_keys", Description: "The MAC Security (MACsec) security keys associated with the connection.", - Resolver: fetchDirectconnectConnectionMacSecKeys, + Resolver: schema.PathTableResolver("MacSecKeys"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -197,17 +197,3 @@ func fetchDirectconnectConnections(ctx context.Context, meta schema.ClientMeta, res <- output.Connections return nil } - -func resolveDirectconnectConnectionTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.Connection) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set("tags", tags)) -} -func fetchDirectconnectConnectionMacSecKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - connection := parent.Item.(types.Connection) - res <- connection.MacSecKeys - return nil -} diff --git a/resources/services/directconnect/gateways.go b/resources/services/directconnect/gateways.go index 3ad9450b5..90276e742 100644 --- a/resources/services/directconnect/gateways.go +++ b/resources/services/directconnect/gateways.go @@ -93,7 +93,7 @@ func DirectconnectGateways() *schema.Table { Name: "allowed_prefixes_to_direct_connect_gateway", Description: "The Amazon VPC prefixes to advertise to the Direct Connect gateway.", Type: schema.TypeStringArray, - Resolver: resolveDirectconnectGatewayAssociationAllowedPrefixes, + Resolver: schema.PathResolver("AllowedPrefixesToDirectConnectGateway.Cidr"), }, { Name: "associated_gateway_id", @@ -271,12 +271,3 @@ func fetchDirectconnectGatewayAttachments(ctx context.Context, meta schema.Clien } return nil } - -func resolveDirectconnectGatewayAssociationAllowedPrefixes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.DirectConnectGatewayAssociation) - allowedPrefixes := make([]*string, len(r.AllowedPrefixesToDirectConnectGateway)) - for i, prefix := range r.AllowedPrefixesToDirectConnectGateway { - allowedPrefixes[i] = prefix.Cidr - } - return diag.WrapError(resource.Set(c.Name, allowedPrefixes)) -} diff --git a/resources/services/directconnect/lags.go b/resources/services/directconnect/lags.go index 55d06a578..7690aaf2b 100644 --- a/resources/services/directconnect/lags.go +++ b/resources/services/directconnect/lags.go @@ -55,7 +55,7 @@ func DirectconnectLags() *schema.Table { Name: "connection_ids", Description: "The list of IDs of Direct Connect Connections bundled by the LAG", Type: schema.TypeStringArray, - Resolver: resolveDirectconnectLagConnectionIds, + Resolver: schema.PathResolver("Connections.ConnectionId"), }, { Name: "connections_bandwidth", @@ -129,14 +129,14 @@ func DirectconnectLags() *schema.Table { Name: "tags", Description: "The tags associated with the LAG.", Type: schema.TypeJSON, - Resolver: resolveDirectconnectLagTags, + Resolver: client.ResolveTags, }, }, Relations: []*schema.Table{ { Name: "aws_directconnect_lag_mac_sec_keys", Description: "The MAC Security (MACsec) security keys associated with the LAG.", - Resolver: fetchDirectconnectLagMacSecKeys, + Resolver: schema.PathTableResolver("MacSecKeys"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -194,27 +194,3 @@ func fetchDirectconnectLags(ctx context.Context, meta schema.ClientMeta, parent res <- output.Lags return nil } - -func resolveDirectconnectLagTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.Lag) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set("tags", tags)) -} - -func fetchDirectconnectLagMacSecKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - connection := parent.Item.(types.Lag) - res <- connection.MacSecKeys - return nil -} - -func resolveDirectconnectLagConnectionIds(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.Lag) - connectionIds := make([]*string, len(r.Connections)) - for i, connection := range r.Connections { - connectionIds[i] = connection.ConnectionId - } - return diag.WrapError(resource.Set("connection_ids", connectionIds)) -} diff --git a/resources/services/directconnect/virtual_interfaces.go b/resources/services/directconnect/virtual_interfaces.go index d728fbef8..5ec751250 100644 --- a/resources/services/directconnect/virtual_interfaces.go +++ b/resources/services/directconnect/virtual_interfaces.go @@ -114,13 +114,13 @@ func DirectconnectVirtualInterfaces() *schema.Table { Name: "route_filter_prefixes", Description: "The routes to be advertised to the AWS network in this Region", Type: schema.TypeStringArray, - Resolver: resolveDirectconnectVirtualInterfaceRouteFilterPrefixes, + Resolver: schema.PathResolver("RouteFilterPrefixes.Cidr"), }, { Name: "tags", Description: "The tags associated with the virtual interface.", Type: schema.TypeJSON, - Resolver: resolveDirectconnectVirtualInterfaceTags, + Resolver: client.ResolveTags, }, { Name: "virtual_gateway_id", @@ -158,7 +158,7 @@ func DirectconnectVirtualInterfaces() *schema.Table { { Name: "aws_directconnect_virtual_interface_bgp_peers", Description: "Information about a BGP peer. ", - Resolver: fetchDirectconnectVirtualInterfaceBgpPeers, + Resolver: schema.PathTableResolver("BgpPeers"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -240,24 +240,3 @@ func fetchDirectconnectVirtualInterfaces(ctx context.Context, meta schema.Client res <- output.VirtualInterfaces return nil } -func resolveDirectconnectVirtualInterfaceRouteFilterPrefixes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.VirtualInterface) - routeFilterPrefixes := make([]*string, len(r.RouteFilterPrefixes)) - for i, prefix := range r.RouteFilterPrefixes { - routeFilterPrefixes[i] = prefix.Cidr - } - return diag.WrapError(resource.Set("route_filter_prefixes", routeFilterPrefixes)) -} -func resolveDirectconnectVirtualInterfaceTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.VirtualInterface) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set("tags", tags)) -} -func fetchDirectconnectVirtualInterfaceBgpPeers(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - virtualInterface := parent.Item.(types.VirtualInterface) - res <- virtualInterface.BgpPeers - return nil -} diff --git a/resources/services/dms/replication_instances.go b/resources/services/dms/replication_instances.go index 5ad4d66b2..bf67573c6 100644 --- a/resources/services/dms/replication_instances.go +++ b/resources/services/dms/replication_instances.go @@ -205,7 +205,7 @@ func DmsReplicationInstances() *schema.Table { { Name: "aws_dms_replication_instance_replication_subnet_group_subnets", Description: "In response to a request by the DescribeReplicationSubnetGroups operation, this object identifies a subnet by its given Availability Zone, subnet identifier, and status.", - Resolver: fetchDmsReplicationInstanceReplicationSubnetGroupSubnets, + Resolver: schema.PathTableResolver("ReplicationSubnetGroup.Subnets"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -235,7 +235,7 @@ func DmsReplicationInstances() *schema.Table { { Name: "aws_dms_replication_instance_vpc_security_groups", Description: "Describes the status of a security group associated with the virtual private cloud (VPC) hosting your replication and DB instances.", - Resolver: fetchDmsReplicationInstanceVpcSecurityGroups, + Resolver: schema.PathTableResolver("VpcSecurityGroups"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -306,18 +306,3 @@ func fetchDmsReplicationInstances(ctx context.Context, meta schema.ClientMeta, _ } return nil } - -func fetchDmsReplicationInstanceReplicationSubnetGroupSubnets(_ context.Context, _ schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - replicationInstance := parent.Item.(DmsReplicationInstanceWrapper) - if replicationInstance.ReplicationSubnetGroup == nil { - return nil - } - res <- replicationInstance.ReplicationSubnetGroup.Subnets - return nil -} - -func fetchDmsReplicationInstanceVpcSecurityGroups(_ context.Context, _ schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - replicationInstance := parent.Item.(DmsReplicationInstanceWrapper) - res <- replicationInstance.VpcSecurityGroups - return nil -} diff --git a/resources/services/ec2/egress_only_internet_gateways.go b/resources/services/ec2/egress_only_internet_gateways.go index 2697c01ab..4bb32807f 100644 --- a/resources/services/ec2/egress_only_internet_gateways.go +++ b/resources/services/ec2/egress_only_internet_gateways.go @@ -2,7 +2,6 @@ package ec2 import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ec2" @@ -47,7 +46,7 @@ func EgressOnlyInternetGateways() *schema.Table { Name: "attachments", Description: "Information about the attachment of the egress-only internet gateway.", Type: schema.TypeJSON, - Resolver: resolveEgressOnlyInternetGatewaysAttachments, + Resolver: schema.PathResolver("Attachments"), }, { Name: "id", @@ -88,12 +87,3 @@ func fetchEc2EgressOnlyInternetGateways(ctx context.Context, meta schema.ClientM } return nil } -func resolveEgressOnlyInternetGatewaysAttachments(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - egress := resource.Item.(types.EgressOnlyInternetGateway) - b, err := json.Marshal(egress.Attachments) - if err != nil { - return diag.WrapError(err) - } - - return diag.WrapError(resource.Set(c.Name, b)) -} diff --git a/resources/services/ec2/network_interfaces.go b/resources/services/ec2/network_interfaces.go index 55b738b29..5b4e67221 100644 --- a/resources/services/ec2/network_interfaces.go +++ b/resources/services/ec2/network_interfaces.go @@ -2,7 +2,6 @@ package ec2 import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ec2" @@ -161,7 +160,7 @@ func NetworkInterfaces() *schema.Table { Name: "groups", Description: "The tags assigned to the egress-only internet gateway.", Type: schema.TypeJSON, - Resolver: resolveNetworkInterfacesGroups, + Resolver: schema.PathResolver("Groups"), }, { Name: "interface_type", @@ -361,12 +360,3 @@ func fetchEc2NetworkInterfaces(ctx context.Context, meta schema.ClientMeta, pare } return nil } -func resolveNetworkInterfacesGroups(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - ni := resource.Item.(types.NetworkInterface) - b, err := json.Marshal(ni.Groups) - if err != nil { - return diag.WrapError(err) - } - - return diag.WrapError(resource.Set(c.Name, b)) -} diff --git a/resources/services/ecs/clusters.go b/resources/services/ecs/clusters.go index 8d9b186ea..a38725bda 100644 --- a/resources/services/ecs/clusters.go +++ b/resources/services/ecs/clusters.go @@ -2,7 +2,6 @@ package ecs import ( "context" - "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws" @@ -113,7 +112,7 @@ func Clusters() *schema.Table { Name: "default_capacity_provider_strategy", Description: "The default capacity provider strategy for the cluster", Type: schema.TypeJSON, - Resolver: resolveClustersDefaultCapacityProviderStrategy, + Resolver: schema.PathResolver("DefaultCapacityProviderStrategy"), }, { Name: "pending_tasks_count", @@ -158,7 +157,7 @@ func Clusters() *schema.Table { { Name: "aws_ecs_cluster_attachments", Description: "An object representing a container instance or task attachment.", - Resolver: fetchEcsClusterAttachments, + Resolver: schema.PathTableResolver("Attachments"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -206,7 +205,7 @@ func Clusters() *schema.Table { Name: "attributes", Description: "The attributes of the task", Type: schema.TypeJSON, - Resolver: resolveClusterTasksAttributes, + Resolver: schema.PathResolver("Attributes"), }, { Name: "availability_zone", @@ -283,7 +282,7 @@ func Clusters() *schema.Table { Name: "inference_accelerators", Description: "The Elastic Inference accelerator that's associated with the task.", Type: schema.TypeJSON, - Resolver: resolveClusterTasksInferenceAccelerators, + Resolver: schema.PathResolver("InferenceAccelerators"), }, { Name: "last_status", @@ -304,7 +303,7 @@ func Clusters() *schema.Table { Name: "overrides", Description: "One or more container overrides.", Type: schema.TypeJSON, - Resolver: resolveClusterTasksOverrides, + Resolver: schema.PathResolver("Overrides"), }, { Name: "platform_family", @@ -469,7 +468,7 @@ func Clusters() *schema.Table { Name: "managed_agents", Description: "The details of any Amazon ECS managed agents associated with the container.", Type: schema.TypeJSON, - Resolver: resolveClusterTaskContainersManagedAgents, + Resolver: schema.PathResolver("ManagedAgents"), }, { Name: "memory", @@ -490,13 +489,13 @@ func Clusters() *schema.Table { Name: "network_bindings", Description: "The network bindings associated with the container.", Type: schema.TypeJSON, - Resolver: resolveClusterTaskContainersNetworkBindings, + Resolver: schema.PathResolver("NetworkBindings"), }, { Name: "network_interfaces", Description: "The network interfaces associated with the container.", Type: schema.TypeJSON, - Resolver: resolveClusterTaskContainersNetworkInterfaces, + Resolver: schema.PathResolver("NetworkInterfaces"), }, { Name: "reason", @@ -532,7 +531,7 @@ func Clusters() *schema.Table { Name: "capacity_provider_strategy", Description: "The capacity provider strategy the service uses", Type: schema.TypeJSON, - Resolver: resolveClusterServicesCapacityProviderStrategy, + Resolver: schema.PathResolver("CapacityProviderStrategy"), IgnoreInTests: true, }, { @@ -719,7 +718,7 @@ func Clusters() *schema.Table { Name: "capacity_provider_strategy", Description: "The capacity provider strategy that the deployment is using.", Type: schema.TypeJSON, - Resolver: resolveClusterServiceDeploymentsCapacityProviderStrategy, + Resolver: schema.PathResolver("CapacityProviderStrategy"), IgnoreInTests: true, }, { @@ -927,7 +926,7 @@ func Clusters() *schema.Table { Name: "capacity_provider_strategy", Description: "The capacity provider strategy that are associated with the task set.", Type: schema.TypeJSON, - Resolver: resolveClusterServiceTaskSetsCapacityProviderStrategy, + Resolver: schema.PathResolver("CapacityProviderStrategy"), IgnoreInTests: true, }, { @@ -1462,17 +1461,7 @@ func fetchEcsClusters(ctx context.Context, meta schema.ClientMeta, parent *schem } return nil } -func resolveClustersDefaultCapacityProviderStrategy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - cluster, ok := resource.Item.(types.Cluster) - if !ok { - return diag.WrapError(fmt.Errorf("expected to have types.Cluster but got %T", resource.Item)) - } - data, err := json.Marshal(cluster.DefaultCapacityProviderStrategy) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} + func resolveClustersSettings(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { cluster, ok := resource.Item.(types.Cluster) if !ok { @@ -1516,14 +1505,6 @@ func resolveClustersTags(ctx context.Context, meta schema.ClientMeta, resource * } return diag.WrapError(resource.Set(c.Name, tags)) } -func fetchEcsClusterAttachments(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster, ok := parent.Item.(types.Cluster) - if !ok { - return diag.WrapError(fmt.Errorf("expected to have types.Cluster but got %T", parent.Item)) - } - res <- cluster.Attachments - return nil -} func resolveClusterAttachmentsDetails(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { attachment, ok := resource.Item.(types.Attachment) if !ok { @@ -1575,33 +1556,6 @@ func fetchEcsClusterTasks(ctx context.Context, meta schema.ClientMeta, parent *s } return nil } -func resolveClusterTasksAttributes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Task) - data, err := json.Marshal(p.Attributes) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveClusterTasksInferenceAccelerators(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Task) - data, err := json.Marshal(p.InferenceAccelerators) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveClusterTasksOverrides(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Task) - if p.Overrides == nil { - return nil - } - data, err := json.Marshal(p.Overrides) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func resolveClusterTaskAttachmentsDetails(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { p := resource.Item.(types.Attachment) @@ -1613,30 +1567,6 @@ func resolveClusterTaskAttachmentsDetails(ctx context.Context, meta schema.Clien return diag.WrapError(resource.Set(c.Name, j)) } -func resolveClusterTaskContainersManagedAgents(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Container) - data, err := json.Marshal(p.ManagedAgents) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveClusterTaskContainersNetworkBindings(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Container) - data, err := json.Marshal(p.NetworkBindings) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveClusterTaskContainersNetworkInterfaces(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - p := resource.Item.(types.Container) - data, err := json.Marshal(p.NetworkInterfaces) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func fetchEcsClusterServices(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { cluster := parent.Item.(types.Cluster) region := meta.(*client.Client).Region @@ -1674,14 +1604,7 @@ func fetchEcsClusterServices(ctx context.Context, meta schema.ClientMeta, parent } return nil } -func resolveClusterServicesCapacityProviderStrategy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - service := resource.Item.(types.Service) - data, err := json.Marshal(service.CapacityProviderStrategy) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} + func resolveClusterServicesPlacementConstraints(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { service := resource.Item.(types.Service) j := make(map[string]interface{}) @@ -1691,6 +1614,7 @@ func resolveClusterServicesPlacementConstraints(ctx context.Context, meta schema return diag.WrapError(resource.Set(c.Name, j)) } + func resolveClusterServicesPlacementStrategy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { service := resource.Item.(types.Service) j := make(map[string]interface{}) @@ -1701,24 +1625,6 @@ func resolveClusterServicesPlacementStrategy(ctx context.Context, meta schema.Cl return diag.WrapError(resource.Set(c.Name, j)) } -func resolveClusterServiceDeploymentsCapacityProviderStrategy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - deployment := resource.Item.(types.Deployment) - data, err := json.Marshal(deployment.CapacityProviderStrategy) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} - -func resolveClusterServiceTaskSetsCapacityProviderStrategy(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - taskSet := resource.Item.(types.TaskSet) - data, err := json.Marshal(taskSet.CapacityProviderStrategy) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} - func fetchEcsClusterContainerInstances(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { cluster := parent.Item.(types.Cluster) region := meta.(*client.Client).Region diff --git a/resources/services/ecs/task_definitions.go b/resources/services/ecs/task_definitions.go index 45d2723ec..c87a9fb4a 100644 --- a/resources/services/ecs/task_definitions.go +++ b/resources/services/ecs/task_definitions.go @@ -2,7 +2,6 @@ package ecs import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/ecs" @@ -143,7 +142,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "requires_attributes", Description: "The container instance attributes required by your task", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionsRequiresAttributes, + Resolver: schema.PathResolver("RequiresAttributes"), }, { Name: "requires_compatibilities", @@ -188,7 +187,7 @@ func EcsTaskDefinitions() *schema.Table { { Name: "aws_ecs_task_definition_container_definitions", Description: "Container definitions are used in task definitions to describe the different containers that are launched as part of a task.", - Resolver: fetchEcsTaskDefinitionContainerDefinitions, + Resolver: schema.PathTableResolver("ContainerDefinitions"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -344,7 +343,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "linux_parameters_devices", Description: "Any host devices to expose to the container", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersDevices, + Resolver: schema.PathResolver("LinuxParameters.Devices"), }, { Name: "linux_parameters_init_process_enabled", @@ -374,7 +373,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "linux_parameters_tmpfs", Description: "The container path, mount options, and size (in MiB) of the tmpfs mount", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersTmpfs, + Resolver: schema.PathResolver("LinuxParameters.Tmpfs"), }, { Name: "log_configuration_log_driver", @@ -408,7 +407,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "mount_points", Description: "The mount points for data volumes in your container", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionContainerDefinitionsMountPoints, + Resolver: schema.PathResolver("MountPoints"), }, { Name: "name", @@ -419,7 +418,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "port_mappings", Description: "The list of port mappings for the container", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionContainerDefinitionsPortMappings, + Resolver: schema.PathResolver("PortMappings"), }, { Name: "privileged", @@ -474,7 +473,7 @@ func EcsTaskDefinitions() *schema.Table { Name: "ulimits", Description: "A list of ulimits to set in the container", Type: schema.TypeJSON, - Resolver: resolveEcsTaskDefinitionContainerDefinitionsUlimits, + Resolver: schema.PathResolver("Ulimits"), }, { Name: "user", @@ -497,7 +496,7 @@ func EcsTaskDefinitions() *schema.Table { { Name: "aws_ecs_task_definition_volumes", Description: "A data volume used in a task definition", - Resolver: fetchEcsTaskDefinitionVolumes, + Resolver: schema.PathTableResolver("Volumes"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -696,19 +695,6 @@ func resolveEcsTaskDefinitionsProxyConfigurationProperties(ctx context.Context, } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveEcsTaskDefinitionsRequiresAttributes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(TaskDefinitionWrapper) - data, err := json.Marshal(r.RequiresAttributes) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func fetchEcsTaskDefinitionContainerDefinitions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(TaskDefinitionWrapper) - res <- r.ContainerDefinitions - return nil -} func resolveEcsTaskDefinitionContainerDefinitionsDependsOn(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.ContainerDefinition) j := map[string]string{} @@ -750,30 +736,6 @@ func resolveEcsTaskDefinitionContainerDefinitionsExtraHosts(ctx context.Context, } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersDevices(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ContainerDefinition) - if r.LinuxParameters == nil { - return nil - } - - data, err := json.Marshal(r.LinuxParameters.Devices) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersTmpfs(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ContainerDefinition) - if r.LinuxParameters == nil { - return nil - } - - data, err := json.Marshal(r.LinuxParameters.Tmpfs) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func resolveEcsTaskDefinitionContainerDefinitionsLogConfigurationSecretOptions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.ContainerDefinition) j := map[string]interface{}{} @@ -785,23 +747,6 @@ func resolveEcsTaskDefinitionContainerDefinitionsLogConfigurationSecretOptions(c } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveEcsTaskDefinitionContainerDefinitionsMountPoints(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ContainerDefinition) - - data, err := json.Marshal(r.MountPoints) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveEcsTaskDefinitionContainerDefinitionsPortMappings(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ContainerDefinition) - data, err := json.Marshal(r.PortMappings) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func resolveEcsTaskDefinitionContainerDefinitionsResourceRequirements(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.ContainerDefinition) j := map[string]string{} @@ -832,15 +777,6 @@ func resolveEcsTaskDefinitionContainerDefinitionsSystemControls(ctx context.Cont } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveEcsTaskDefinitionContainerDefinitionsUlimits(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ContainerDefinition) - - data, err := json.Marshal(r.Ulimits) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} func resolveEcsTaskDefinitionContainerDefinitionsVolumesFrom(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.ContainerDefinition) j := map[string]interface{}{} @@ -852,12 +788,6 @@ func resolveEcsTaskDefinitionContainerDefinitionsVolumesFrom(ctx context.Context } return diag.WrapError(resource.Set(c.Name, j)) } -func fetchEcsTaskDefinitionVolumes(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(TaskDefinitionWrapper) - res <- r.Volumes - return nil -} - func resolveEcsTaskDefinitionTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(TaskDefinitionWrapper) j := map[string]string{} diff --git a/resources/services/efs/filesystems.go b/resources/services/efs/filesystems.go index 2f09c52ef..5efec6879 100644 --- a/resources/services/efs/filesystems.go +++ b/resources/services/efs/filesystems.go @@ -104,7 +104,7 @@ func EfsFilesystems() *schema.Table { Name: "tags", Description: "The tags associated with the file system, presented as an array of Tag objects. ", Type: schema.TypeJSON, - Resolver: resolveEfsFilesystemsTags, + Resolver: client.ResolveTags, }, { Name: "availability_zone_id", @@ -196,11 +196,3 @@ func ResolveEfsFilesystemBackupPolicyStatus(ctx context.Context, meta schema.Cli return diag.WrapError(resource.Set(c.Name, response.BackupPolicy.Status)) } -func resolveEfsFilesystemsTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.FileSystemDescription) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set("tags", tags)) -} diff --git a/resources/services/eks/clusters.go b/resources/services/eks/clusters.go index c50517a08..8834da693 100644 --- a/resources/services/eks/clusters.go +++ b/resources/services/eks/clusters.go @@ -148,7 +148,7 @@ func EksClusters() *schema.Table { { Name: "aws_eks_cluster_encryption_configs", Description: "The encryption configuration for the cluster.", - Resolver: fetchEksClusterEncryptionConfigs, + Resolver: schema.PathTableResolver("EncryptionConfig"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -173,7 +173,7 @@ func EksClusters() *schema.Table { { Name: "aws_eks_cluster_loggings", Description: "An object representing the enabled or disabled Kubernetes control plane logs for your cluster.", - Resolver: fetchEksClusterLoggings, + Resolver: schema.PathTableResolver("Logging.ClusterLogging"), Columns: []schema.Column{ { Name: "cluster_cq_id", @@ -231,19 +231,7 @@ func fetchEksClusters(ctx context.Context, meta schema.ClientMeta, parent *schem } return nil } -func fetchEksClusterEncryptionConfigs(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(*types.Cluster) - res <- p.EncryptionConfig - return nil -} -func fetchEksClusterLoggings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(*types.Cluster) - if p.Logging == nil { - return nil - } - res <- p.Logging.ClusterLogging - return nil -} + func resolveEksClusterLoggingTypes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { logSetup := resource.Item.(types.LogSetup) logTypes := make([]string, len(logSetup.Types)) diff --git a/resources/services/elasticbeanstalk/environments.go b/resources/services/elasticbeanstalk/environments.go index 1001b0780..43611b00c 100644 --- a/resources/services/elasticbeanstalk/environments.go +++ b/resources/services/elasticbeanstalk/environments.go @@ -373,7 +373,7 @@ func ElasticbeanstalkEnvironments() *schema.Table { { Name: "aws_elasticbeanstalk_environment_links", Description: "A link to another environment, defined in the environment's manifest", - Resolver: fetchElasticbeanstalkEnvironmentLinks, + Resolver: schema.PathTableResolver("EnvironmentLinks"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -455,11 +455,6 @@ func resolveElasticbeanstalkEnvironmentListeners(ctx context.Context, meta schem } return diag.WrapError(resource.Set(c.Name, tags)) } -func fetchElasticbeanstalkEnvironmentLinks(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.EnvironmentDescription) - res <- p.EnvironmentLinks - return nil -} func fetchElasticbeanstalkConfigurationOptions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { p := parent.Item.(types.EnvironmentDescription) diff --git a/resources/services/elbv1/load_balancers.go b/resources/services/elbv1/load_balancers.go index 2a7708c4e..89f6096d8 100644 --- a/resources/services/elbv1/load_balancers.go +++ b/resources/services/elbv1/load_balancers.go @@ -51,42 +51,42 @@ func Elbv1LoadBalancers() *schema.Table { { Name: "attributes_access_log_enabled", Type: schema.TypeBool, - Resolver: resolveElbv1loadBalancerAttributesAccessLogEnabled, + Resolver: schema.PathResolver("Attributes.AccessLog.Enabled"), }, { Name: "attributes_access_log_s3_bucket_name", Type: schema.TypeString, - Resolver: resolveElbv1loadBalancerAttributesAccessLogS3BucketName, + Resolver: schema.PathResolver("Attributes.AccessLog.S3BucketName"), }, { Name: "attributes_access_log_s3_bucket_prefix", Type: schema.TypeString, - Resolver: resolveElbv1loadBalancerAttributesAccessLogS3BucketPrefix, + Resolver: schema.PathResolver("Attributes.AccessLog.S3BucketPrefix"), }, { Name: "attributes_access_log_emit_interval", Type: schema.TypeInt, - Resolver: resolveElbv1loadBalancerAttributesAccessLogEmitInterval, + Resolver: schema.PathResolver("Attributes.AccessLog.EmitInterval"), }, { Name: "attributes_connection_settings_idle_timeout", Type: schema.TypeInt, - Resolver: resolveElbv1loadBalancerAttributesConnectionSettingsIdleTimeout, + Resolver: schema.PathResolver("Attributes.ConnectionSettings.IdleTimeout"), }, { Name: "attributes_cross_zone_load_balancing_enabled", Type: schema.TypeBool, - Resolver: resolveElbv1loadBalancerAttributesCrossZoneLoadBalancingEnabled, + Resolver: schema.PathResolver("Attributes.CrossZoneLoadBalancing.Enabled"), }, { Name: "attributes_connection_draining_enabled", Type: schema.TypeBool, - Resolver: resolveElbv1loadBalancerAttributesConnectionDrainingEnabled, + Resolver: schema.PathResolver("Attributes.ConnectionDraining.Enabled"), }, { Name: "attributes_connection_draining_timeout", Type: schema.TypeInt, - Resolver: resolveElbv1loadBalancerAttributesConnectionDrainingTimeout, + Resolver: schema.PathResolver("Attributes.ConnectionDraining.Timeout"), }, { Name: "attributes_additional_attributes", @@ -158,7 +158,7 @@ func Elbv1LoadBalancers() *schema.Table { Name: "instances", Description: "The IDs of the instances for the load balancer.", Type: schema.TypeStringArray, - Resolver: resolveElbv1loadBalancerInstances, + Resolver: schema.PathResolver("Instances.InstanceId"), }, { Name: "name", @@ -210,7 +210,7 @@ func Elbv1LoadBalancers() *schema.Table { { Name: "aws_elbv1_load_balancer_backend_server_descriptions", Description: "Information about the configuration of an EC2 instance.", - Resolver: fetchElbv1LoadBalancerBackendServerDescriptions, + Resolver: schema.PathTableResolver("BackendServerDescriptions"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -240,7 +240,7 @@ func Elbv1LoadBalancers() *schema.Table { { Name: "aws_elbv1_load_balancer_listeners", Description: "The policies enabled for a listener.", - Resolver: fetchElbv1LoadBalancerListeners, + Resolver: schema.PathTableResolver("ListenerDescriptions"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -295,7 +295,7 @@ func Elbv1LoadBalancers() *schema.Table { { Name: "aws_elbv1_load_balancer_policies_app_cookie_stickiness", Description: "Information about a policy for application-controlled session stickiness.", - Resolver: fetchElbv1LoadBalancerPoliciesAppCookieStickinessPolicies, + Resolver: schema.PathTableResolver("Policies.AppCookieStickinessPolicies"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -325,7 +325,7 @@ func Elbv1LoadBalancers() *schema.Table { { Name: "aws_elbv1_load_balancer_policies_lb_cookie_stickiness", Description: "Information about a policy for duration-based session stickiness.", - Resolver: fetchElbv1LoadBalancerPoliciesLbCookieStickinessPolicies, + Resolver: schema.PathTableResolver("Policies.LBCookieStickinessPolicies"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -456,63 +456,7 @@ func fetchElbv1LoadBalancers(ctx context.Context, meta schema.ClientMeta, parent return nil } -func resolveElbv1loadBalancerAttributesAccessLogEnabled(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.AccessLog == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.AccessLog.Enabled)) -} -func resolveElbv1loadBalancerAttributesAccessLogS3BucketName(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.AccessLog == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.AccessLog.S3BucketName)) -} -func resolveElbv1loadBalancerAttributesAccessLogS3BucketPrefix(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.AccessLog == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.AccessLog.S3BucketPrefix)) -} -func resolveElbv1loadBalancerAttributesAccessLogEmitInterval(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.AccessLog == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.AccessLog.EmitInterval)) -} -func resolveElbv1loadBalancerAttributesConnectionSettingsIdleTimeout(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.ConnectionSettings == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.ConnectionSettings.IdleTimeout)) -} -func resolveElbv1loadBalancerAttributesCrossZoneLoadBalancingEnabled(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.CrossZoneLoadBalancing == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.CrossZoneLoadBalancing.Enabled)) -} -func resolveElbv1loadBalancerAttributesConnectionDrainingEnabled(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.ConnectionDraining == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.ConnectionDraining.Enabled)) -} -func resolveElbv1loadBalancerAttributesConnectionDrainingTimeout(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - if r.Attributes == nil && r.Attributes.ConnectionDraining == nil { - return nil - } - return diag.WrapError(resource.Set(c.Name, r.Attributes.ConnectionDraining.Timeout)) -} func resolveElbv1loadBalancerAttributesAdditionalAttributes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(ELBv1LoadBalancerWrapper) if r.Attributes == nil { @@ -525,42 +469,7 @@ func resolveElbv1loadBalancerAttributesAdditionalAttributes(ctx context.Context, } return diag.WrapError(resource.Set(c.Name, response)) } -func resolveElbv1loadBalancerInstances(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(ELBv1LoadBalancerWrapper) - response := make([]string, 0, len(r.Instances)) - for _, i := range r.Instances { - response = append(response, *i.InstanceId) - } - return diag.WrapError(resource.Set(c.Name, response)) -} -func fetchElbv1LoadBalancerBackendServerDescriptions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(ELBv1LoadBalancerWrapper) - res <- r.BackendServerDescriptions - return nil -} -func fetchElbv1LoadBalancerListeners(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(ELBv1LoadBalancerWrapper) - res <- r.ListenerDescriptions - return nil -} -func fetchElbv1LoadBalancerPoliciesAppCookieStickinessPolicies(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(ELBv1LoadBalancerWrapper) - if r.Policies == nil { - return nil - } - res <- r.Policies.AppCookieStickinessPolicies - return nil -} -func fetchElbv1LoadBalancerPoliciesLbCookieStickinessPolicies(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(ELBv1LoadBalancerWrapper) - - if r.Policies == nil { - return nil - } - res <- r.Policies.LBCookieStickinessPolicies - return nil -} func fetchElbv1LoadBalancerPolicies(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { r := parent.Item.(ELBv1LoadBalancerWrapper) c := meta.(*client.Client) diff --git a/resources/services/elbv2/load_balancers.go b/resources/services/elbv2/load_balancers.go index 65902426d..1c64d4c99 100644 --- a/resources/services/elbv2/load_balancers.go +++ b/resources/services/elbv2/load_balancers.go @@ -143,7 +143,7 @@ func Elbv2LoadBalancers() *schema.Table { { Name: "aws_elbv2_load_balancer_availability_zones", Description: "Information about an Availability Zone.", - Resolver: fetchElbv2LoadBalancerAvailabilityZones, + Resolver: schema.PathTableResolver("AvailabilityZones"), Columns: []schema.Column{ { Name: "load_balancer_cq_id", @@ -178,7 +178,7 @@ func Elbv2LoadBalancers() *schema.Table { { Name: "aws_elbv2_load_balancer_availability_zone_addresses", Description: "Information about a static IP address for a load balancer.", - Resolver: fetchElbv2LoadBalancerAvailabilityZoneAddresses, + Resolver: schema.PathTableResolver("LoadBalancerAddresses"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -379,16 +379,6 @@ func resolveElbv2loadBalancerTags(ctx context.Context, meta schema.ClientMeta, r return diag.WrapError(resource.Set(c.Name, tags)) } -func fetchElbv2LoadBalancerAvailabilityZones(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.LoadBalancer) - res <- p.AvailabilityZones - return nil -} -func fetchElbv2LoadBalancerAvailabilityZoneAddresses(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - p := parent.Item.(types.AvailabilityZone) - res <- p.LoadBalancerAddresses - return nil -} // ==================================================================================================================== // User Defined Helpers diff --git a/resources/services/emr/block_public_access_configs.go b/resources/services/emr/block_public_access_configs.go index 381d56b48..e37724da5 100644 --- a/resources/services/emr/block_public_access_configs.go +++ b/resources/services/emr/block_public_access_configs.go @@ -2,7 +2,6 @@ package emr import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/service/emr" "github.com/cloudquery/cq-provider-aws/client" @@ -48,7 +47,7 @@ func EmrBlockPublicAccessConfigs() *schema.Table { Name: "configurations", Description: "A list of additional configurations to apply within a configuration object.", Type: schema.TypeJSON, - Resolver: resolveEmrBlockPublicAccessConfigConfigurations, + Resolver: schema.PathResolver("BlockPublicAccessConfiguration.Configurations"), IgnoreInTests: true, }, { @@ -75,7 +74,7 @@ func EmrBlockPublicAccessConfigs() *schema.Table { { Name: "aws_emr_block_public_access_config_port_ranges", Description: "A list of port ranges that are permitted to allow inbound traffic from all public IP addresses", - Resolver: fetchEmrBlockPublicAccessConfigPermittedPublicSecurityGroupRuleRanges, + Resolver: schema.PathTableResolver("BlockPublicAccessConfiguration.PermittedPublicSecurityGroupRuleRanges"), Columns: []schema.Column{ { Name: "block_public_access_config_cq_id", @@ -118,24 +117,3 @@ func fetchEmrBlockPublicAccessConfigs(ctx context.Context, meta schema.ClientMet res <- out return nil } - -func resolveEmrBlockPublicAccessConfigConfigurations(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - out := resource.Item.(*emr.GetBlockPublicAccessConfigurationOutput) - if out.BlockPublicAccessConfiguration == nil { - return nil - } - b, err := json.Marshal(out.BlockPublicAccessConfiguration.Configurations) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} - -func fetchEmrBlockPublicAccessConfigPermittedPublicSecurityGroupRuleRanges(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - out := parent.Item.(*emr.GetBlockPublicAccessConfigurationOutput) - if out.BlockPublicAccessConfiguration == nil { - return nil - } - res <- out.BlockPublicAccessConfiguration.PermittedPublicSecurityGroupRuleRanges - return nil -} diff --git a/resources/services/emr/clusters.go b/resources/services/emr/clusters.go index 970ca6d45..52c548f10 100644 --- a/resources/services/emr/clusters.go +++ b/resources/services/emr/clusters.go @@ -2,11 +2,9 @@ package emr import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/emr" - "github.com/aws/aws-sdk-go-v2/service/emr/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -39,7 +37,7 @@ func EmrClusters() *schema.Table { Name: "applications", Description: "The applications installed on this cluster.", Type: schema.TypeJSON, - Resolver: resolveEMRClusterJSONField(func(c *types.Cluster) interface{} { return c.Applications }), + Resolver: schema.PathResolver("Applications"), }, { Name: "auto_scaling_role", @@ -61,7 +59,7 @@ func EmrClusters() *schema.Table { Name: "configurations", Description: "The list of Configurations supplied to the EMR cluster.", Type: schema.TypeJSON, - Resolver: resolveEMRClusterJSONField(func(c *types.Cluster) interface{} { return c.Configurations }), + Resolver: schema.PathResolver("Configurations"), }, { Name: "custom_ami_id", @@ -221,7 +219,7 @@ func EmrClusters() *schema.Table { Name: "placement_groups", Description: "Placement group configured for an Amazon EMR cluster.", Type: schema.TypeJSON, - Resolver: resolveEMRClusterJSONField(func(c *types.Cluster) interface{} { return c.PlacementGroups }), + Resolver: schema.PathResolver("PlacementGroups"), }, { Name: "release_label", @@ -350,14 +348,3 @@ func fetchEmrClusters(ctx context.Context, meta schema.ClientMeta, parent *schem } return nil } - -func resolveEMRClusterJSONField(getter func(c *types.Cluster) interface{}) func(context.Context, schema.ClientMeta, *schema.Resource, schema.Column) error { - return func(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - cl := resource.Item.(*types.Cluster) - b, err := json.Marshal(getter(cl)) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) - } -} diff --git a/resources/services/fsx/backups.go b/resources/services/fsx/backups.go index 0d5611f93..7ac7c430f 100644 --- a/resources/services/fsx/backups.go +++ b/resources/services/fsx/backups.go @@ -5,7 +5,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/fsx" - "github.com/aws/aws-sdk-go-v2/service/fsx/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -95,7 +94,7 @@ func FsxBackups() *schema.Table { Name: "tags", Description: "Tags associated with a particular file system.", Type: schema.TypeJSON, - Resolver: resolveFsxBackupTags, + Resolver: client.ResolveTags, }, }, } @@ -123,11 +122,3 @@ func fetchFsxBackups(ctx context.Context, meta schema.ClientMeta, parent *schema } return nil } -func resolveFsxBackupTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.Backup) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set(c.Name, tags)) -} diff --git a/resources/services/iam/policies.go b/resources/services/iam/policies.go index cc218cc12..857e37bba 100644 --- a/resources/services/iam/policies.go +++ b/resources/services/iam/policies.go @@ -92,7 +92,7 @@ func IamPolicies() *schema.Table { { Name: "aws_iam_policy_versions", Description: "Contains information about a version of a managed policy.", - Resolver: fetchIamPolicyVersions, + Resolver: schema.PathTableResolver("PolicyVersionList"), Columns: []schema.Column{ { Name: "policy_cq_id", @@ -152,11 +152,6 @@ func fetchIamPolicies(ctx context.Context, meta schema.ClientMeta, parent *schem } return nil } -func fetchIamPolicyVersions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - r := parent.Item.(types.ManagedPolicyDetail) - res <- r.PolicyVersionList - return nil -} func resolveIamPolicyVersionDocument(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.PolicyVersion) if r.Document != nil { diff --git a/resources/services/iam/virtual_mfa_devices.go b/resources/services/iam/virtual_mfa_devices.go index f799c1b1f..393031aef 100644 --- a/resources/services/iam/virtual_mfa_devices.go +++ b/resources/services/iam/virtual_mfa_devices.go @@ -5,7 +5,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/iam" - "github.com/aws/aws-sdk-go-v2/service/iam/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -53,7 +52,7 @@ func IamVirtualMfaDevices() *schema.Table { Name: "tags", Description: "A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html) in the IAM User Guide. ", Type: schema.TypeJSON, - Resolver: resolveIamVirtualMfaDeviceTags, + Resolver: client.ResolveTags, }, { Name: "user_arn", @@ -107,7 +106,7 @@ func IamVirtualMfaDevices() *schema.Table { Name: "user_tags", Description: "A list of tags that are associated with the user. For more information about tagging, see Tagging IAM resources (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html) in the IAM User Guide. ", Type: schema.TypeJSON, - Resolver: resolveIamVirtualMfaDeviceUserTags, + Resolver: client.ResolveTags, }, }, } @@ -133,22 +132,3 @@ func fetchIamVirtualMfaDevices(ctx context.Context, meta schema.ClientMeta, pare return nil } -func resolveIamVirtualMfaDeviceTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.VirtualMFADevice) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set(c.Name, tags)) -} -func resolveIamVirtualMfaDeviceUserTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.VirtualMFADevice) - if r.User == nil { - return nil - } - tags := map[string]*string{} - for _, t := range r.User.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set(c.Name, tags)) -} diff --git a/resources/services/iot/iot_jobs.go b/resources/services/iot/iot_jobs.go index a6dff9c91..f8d22ddb6 100644 --- a/resources/services/iot/iot_jobs.go +++ b/resources/services/iot/iot_jobs.go @@ -223,7 +223,7 @@ func IotJobs() *schema.Table { { Name: "aws_iot_job_abort_config_criteria_list", Description: "The criteria that determine when and how a job abort takes place.", - Resolver: fetchIotJobAbortConfigCriteriaLists, + Resolver: schema.PathTableResolver("AbortConfig.CriteriaList"), Columns: []schema.Column{ { Name: "job_cq_id", @@ -322,11 +322,3 @@ func ResolveIotJobTags(ctx context.Context, meta schema.ClientMeta, resource *sc } return diag.WrapError(resource.Set(c.Name, tags)) } -func fetchIotJobAbortConfigCriteriaLists(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - i := parent.Item.(*types.Job) - if i.AbortConfig == nil { - return nil - } - res <- i.AbortConfig.CriteriaList - return nil -} diff --git a/resources/services/iot/iot_security_profiles.go b/resources/services/iot/iot_security_profiles.go index 5ded95e81..08b7c3a9b 100644 --- a/resources/services/iot/iot_security_profiles.go +++ b/resources/services/iot/iot_security_profiles.go @@ -2,11 +2,9 @@ package iot import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/iot" - "github.com/aws/aws-sdk-go-v2/service/iot/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -54,7 +52,7 @@ func IotSecurityProfiles() *schema.Table { Name: "additional_metrics_to_retain_v2", Description: "A list of metrics whose data is retained (stored)", Type: schema.TypeJSON, - Resolver: resolveIotSecurityProfilesAdditionalMetricsToRetainV2, + Resolver: schema.PathResolver("AdditionalMetricsToRetainV2"), }, { Name: "alert_targets", @@ -99,7 +97,7 @@ func IotSecurityProfiles() *schema.Table { { Name: "aws_iot_security_profile_behaviors", Description: "A Device Defender security profile behavior.", - Resolver: fetchIotSecurityProfileBehaviors, + Resolver: schema.PathTableResolver("Behaviors"), Columns: []schema.Column{ { Name: "security_profile_cq_id", @@ -152,7 +150,7 @@ func IotSecurityProfiles() *schema.Table { Name: "criteria_value", Description: "The value to be compared with the metric.", Type: schema.TypeJSON, - Resolver: resolveIotSecurityProfileBehaviorsCriteriaValue, + Resolver: schema.PathResolver("Criteria.Value"), }, { Name: "metric", @@ -276,38 +274,3 @@ func ResolveIotSecurityProfileTags(ctx context.Context, meta schema.ClientMeta, } return diag.WrapError(diag.WrapError(resource.Set(c.Name, tags))) } -func resolveIotSecurityProfilesAdditionalMetricsToRetainV2(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - i := resource.Item.(*iot.DescribeSecurityProfileOutput) - - if i.AdditionalMetricsToRetainV2 == nil { - return nil - } - - b, err := json.Marshal(i.AdditionalMetricsToRetainV2) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} -func fetchIotSecurityProfileBehaviors(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - i := parent.Item.(*iot.DescribeSecurityProfileOutput) - if i.Behaviors == nil { - return nil - } - - res <- i.Behaviors - return nil -} -func resolveIotSecurityProfileBehaviorsCriteriaValue(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - i := resource.Item.(types.Behavior) - if i.Criteria == nil || i.Criteria.Value == nil { - return nil - } - - data, err := json.Marshal(i.Criteria.Value) - if err != nil { - return diag.WrapError(err) - } - - return diag.WrapError(resource.Set(c.Name, data)) -} diff --git a/resources/services/iot/iot_streams.go b/resources/services/iot/iot_streams.go index 31bd20065..a69579e9f 100644 --- a/resources/services/iot/iot_streams.go +++ b/resources/services/iot/iot_streams.go @@ -5,7 +5,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/iot" - "github.com/aws/aws-sdk-go-v2/service/iot/types" "github.com/cloudquery/cq-provider-aws/client" "github.com/cloudquery/cq-provider-sdk/provider/diag" "github.com/cloudquery/cq-provider-sdk/provider/schema" @@ -77,7 +76,7 @@ func IotStreams() *schema.Table { { Name: "aws_iot_stream_files", Description: "Represents a file to stream.", - Resolver: fetchIotStreamFiles, + Resolver: schema.PathTableResolver("Files"), Columns: []schema.Column{ { Name: "stream_cq_id", @@ -153,9 +152,3 @@ func fetchIotStreams(ctx context.Context, meta schema.ClientMeta, parent *schema } return diags } -func fetchIotStreamFiles(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - i := parent.Item.(*types.StreamInfo) - - res <- i.Files - return nil -} diff --git a/resources/services/iot/iot_thing_groups.go b/resources/services/iot/iot_thing_groups.go index 0d0f7f2b6..f80567e12 100644 --- a/resources/services/iot/iot_thing_groups.go +++ b/resources/services/iot/iot_thing_groups.go @@ -2,7 +2,6 @@ package iot import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/iot" @@ -103,7 +102,7 @@ func IotThingGroups() *schema.Table { Name: "root_to_parent_thing_groups", Description: "The root parent thing group.", Type: schema.TypeJSON, - Resolver: resolveIotThingGroupsRootToParentThingGroups, + Resolver: schema.PathResolver("ThingGroupMetadata.RootToParentThingGroups"), }, { Name: "name", @@ -258,16 +257,3 @@ func ResolveIotThingGroupTags(ctx context.Context, meta schema.ClientMeta, resou } return diag.WrapError(resource.Set(c.Name, tags)) } -func resolveIotThingGroupsRootToParentThingGroups(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - i := resource.Item.(*iot.DescribeThingGroupOutput) - if i.ThingGroupMetadata == nil { - return nil - } - - data, err := json.Marshal(i.ThingGroupMetadata.RootToParentThingGroups) - if err != nil { - return diag.WrapError(err) - } - - return diag.WrapError(resource.Set(c.Name, data)) -} diff --git a/resources/services/iot/iot_topic_rules.go b/resources/services/iot/iot_topic_rules.go index 254e88c30..282465c6c 100644 --- a/resources/services/iot/iot_topic_rules.go +++ b/resources/services/iot/iot_topic_rules.go @@ -2,7 +2,6 @@ package iot import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/iot" @@ -391,7 +390,7 @@ func IotTopicRules() *schema.Table { Name: "error_action_iot_site_wise", Description: "Sends data from the MQTT message that triggered the rule to IoT SiteWise asset properties.", Type: schema.TypeJSON, - Resolver: resolveIotTopicRulesErrorActionIotSiteWise, + Resolver: schema.PathResolver("Rule.ErrorAction.IotSiteWise"), IgnoreInTests: true, }, { @@ -686,7 +685,7 @@ func IotTopicRules() *schema.Table { { Name: "aws_iot_topic_rule_actions", Description: "Describes the actions associated with a rule.", - Resolver: fetchIotTopicRuleActions, + Resolver: schema.PathTableResolver("Rule.Actions"), Columns: []schema.Column{ { Name: "topic_rule_cq_id", @@ -1027,7 +1026,7 @@ func IotTopicRules() *schema.Table { Name: "iot_site_wise", Description: "Sends data from the MQTT message that triggered the rule to IoT SiteWise asset properties.", Type: schema.TypeJSON, - Resolver: resolveIotTopicRuleActionsIotSiteWise, + Resolver: schema.PathResolver("IotSiteWise"), IgnoreInTests: true, }, { @@ -1375,17 +1374,6 @@ func resolveIotTopicRulesErrorActionHttpHeaders(ctx context.Context, meta schema } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveIotTopicRulesErrorActionIotSiteWise(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - i := resource.Item.(*iot.GetTopicRuleOutput) - if i.Rule == nil || i.Rule.ErrorAction == nil || i.Rule.ErrorAction.IotSiteWise == nil { - return nil - } - b, err := json.Marshal(i.Rule.ErrorAction.IotSiteWise) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} func resolveIotTopicRulesErrorActionTimestreamDimensions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { i := resource.Item.(*iot.GetTopicRuleOutput) if i.Rule == nil || i.Rule.ErrorAction == nil || i.Rule.ErrorAction.Timestream == nil { @@ -1397,14 +1385,6 @@ func resolveIotTopicRulesErrorActionTimestreamDimensions(ctx context.Context, me } return diag.WrapError(resource.Set(c.Name, j)) } -func fetchIotTopicRuleActions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - i := parent.Item.(*iot.GetTopicRuleOutput) - if i.Rule == nil { - return nil - } - res <- i.Rule.Actions - return nil -} func resolveIotTopicRuleActionsHttpHeaders(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { i := resource.Item.(types.Action) if i.Http == nil { @@ -1416,17 +1396,6 @@ func resolveIotTopicRuleActionsHttpHeaders(ctx context.Context, meta schema.Clie } return diag.WrapError(resource.Set(c.Name, j)) } -func resolveIotTopicRuleActionsIotSiteWise(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - i := resource.Item.(types.Action) - if i.IotSiteWise == nil { - return nil - } - b, err := json.Marshal(i.IotSiteWise) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, b)) -} func resolveIotTopicRuleActionsTimestreamDimensions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { i := resource.Item.(types.Action) if i.Timestream == nil { diff --git a/resources/services/redshift/clusters.go b/resources/services/redshift/clusters.go index e208e0fa3..74695d1af 100644 --- a/resources/services/redshift/clusters.go +++ b/resources/services/redshift/clusters.go @@ -455,7 +455,7 @@ func RedshiftClusters() *schema.Table { Name: "tags", Description: "The list of tags for the cluster.", Type: schema.TypeJSON, - Resolver: resolveRedshiftClusterTags, + Resolver: client.ResolveTags, }, { Name: "total_storage_capacity_in_mega_bytes", @@ -478,7 +478,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_nodes", Description: "The identifier of a node in a cluster.", - Resolver: fetchRedshiftClusterNodes, + Resolver: schema.PathTableResolver("ClusterNodes"), Columns: []schema.Column{ { Name: "cluster_cq_id", @@ -508,7 +508,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_parameter_groups", Description: "Describes the status of a parameter group.", - Resolver: fetchRedshiftClusterParameterGroups, + Resolver: schema.PathTableResolver("ClusterParameterGroups"), Columns: []schema.Column{ { Name: "cluster_cq_id", @@ -590,7 +590,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_parameter_group_status_lists", Description: "Describes the status of a parameter group.", - Resolver: fetchRedshiftClusterParameterGroupStatusLists, + Resolver: schema.PathTableResolver("ClusterParameterStatusList"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -621,7 +621,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_security_groups", Description: "Describes a cluster security group.", - Resolver: fetchRedshiftClusterSecurityGroups, + Resolver: schema.PathTableResolver("ClusterSecurityGroups"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -645,7 +645,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_deferred_maintenance_windows", Description: "Describes a deferred maintenance window .", - Resolver: fetchRedshiftClusterDeferredMaintenanceWindows, + Resolver: schema.PathTableResolver("DeferredMaintenanceWindows"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -674,7 +674,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_endpoint_vpc_endpoints", Description: "The connection endpoint for connecting to an Amazon Redshift cluster through the proxy.", - Resolver: fetchRedshiftClusterEndpointVpcEndpoints, + Resolver: schema.PathTableResolver("Endpoint.VpcEndpoints"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -698,7 +698,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_endpoint_vpc_endpoint_network_interfaces", Description: "Describes a network interface.", - Resolver: fetchRedshiftClusterEndpointVpcEndpointNetworkInterfaces, + Resolver: schema.PathTableResolver("NetworkInterfaces"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -734,7 +734,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_iam_roles", Description: "An AWS Identity and Access Management (IAM) role that can be used by the associated Amazon Redshift cluster to access other AWS services.", - Resolver: fetchRedshiftClusterIamRoles, + Resolver: schema.PathTableResolver("IamRoles"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -758,7 +758,7 @@ func RedshiftClusters() *schema.Table { { Name: "aws_redshift_cluster_vpc_security_groups", Description: "Describes the members of a VPC security group.", - Resolver: fetchRedshiftClusterVpcSecurityGroups, + Resolver: schema.PathTableResolver("VpcSecurityGroups"), Columns: []schema.Column{ { Name: "cluster_cq_id", @@ -805,14 +805,7 @@ func fetchRedshiftClusters(ctx context.Context, meta schema.ClientMeta, parent * } return nil } -func resolveRedshiftClusterTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.Cluster) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set(c.Name, tags)) -} + func resolveRedshiftClusterLoggingStatus(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.Cluster) @@ -830,16 +823,7 @@ func resolveRedshiftClusterLoggingStatus(ctx context.Context, meta schema.Client return diag.WrapError(resource.Set(c.Name, response)) } -func fetchRedshiftClusterNodes(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.ClusterNodes - return nil -} -func fetchRedshiftClusterParameterGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.ClusterParameterGroups - return nil -} + func fetchRedshiftClusterParameter(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { parameterGroup := parent.Item.(types.ClusterParameterGroupStatus) config := redshift.DescribeClusterParametersInput{ @@ -863,41 +847,3 @@ func fetchRedshiftClusterParameter(ctx context.Context, meta schema.ClientMeta, return nil } -func fetchRedshiftClusterParameterGroupStatusLists(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - parameterGroup := parent.Item.(types.ClusterParameterGroupStatus) - res <- parameterGroup.ClusterParameterStatusList - return nil -} -func fetchRedshiftClusterSecurityGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.ClusterSecurityGroups - return nil -} -func fetchRedshiftClusterDeferredMaintenanceWindows(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.DeferredMaintenanceWindows - return nil -} -func fetchRedshiftClusterEndpointVpcEndpoints(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - if cluster.Endpoint == nil { - return nil - } - res <- cluster.Endpoint.VpcEndpoints - return nil -} -func fetchRedshiftClusterEndpointVpcEndpointNetworkInterfaces(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - vpcEndpoint := parent.Item.(types.VpcEndpoint) - res <- vpcEndpoint.NetworkInterfaces - return nil -} -func fetchRedshiftClusterIamRoles(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.IamRoles - return nil -} -func fetchRedshiftClusterVpcSecurityGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - cluster := parent.Item.(types.Cluster) - res <- cluster.VpcSecurityGroups - return nil -} diff --git a/resources/services/redshift/subnet_groups.go b/resources/services/redshift/subnet_groups.go index df7f04131..19e7b95a1 100644 --- a/resources/services/redshift/subnet_groups.go +++ b/resources/services/redshift/subnet_groups.go @@ -61,7 +61,7 @@ func RedshiftSubnetGroups() *schema.Table { Name: "tags", Description: "The list of tags for the cluster subnet group.", Type: schema.TypeJSON, - Resolver: resolveRedshiftSubnetGroupTags, + Resolver: client.ResolveTags, }, { Name: "vpc_id", @@ -73,7 +73,7 @@ func RedshiftSubnetGroups() *schema.Table { { Name: "aws_redshift_subnet_group_subnets", Description: "Describes a subnet.", - Resolver: fetchRedshiftSubnetGroupSubnets, + Resolver: schema.PathTableResolver("Subnets"), Columns: []schema.Column{ { Name: "subnet_group_cq_id", @@ -131,19 +131,6 @@ func fetchRedshiftSubnetGroups(ctx context.Context, meta schema.ClientMeta, pare } return nil } -func resolveRedshiftSubnetGroupTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(types.ClusterSubnetGroup) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set("tags", tags)) -} -func fetchRedshiftSubnetGroupSubnets(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - clusterSubnetGroup := parent.Item.(types.ClusterSubnetGroup) - res <- clusterSubnetGroup.Subnets - return nil -} func resolveRedshiftSubnetGroupSubnetSubnetAvailabilityZoneSupportedPlatforms(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { r := resource.Item.(types.Subnet) platforms := make([]*string, len(r.SubnetAvailabilityZone.SupportedPlatforms)) diff --git a/resources/services/secretsmanager/secrets.go b/resources/services/secretsmanager/secrets.go index 6be023735..e2cd1a46e 100644 --- a/resources/services/secretsmanager/secrets.go +++ b/resources/services/secretsmanager/secrets.go @@ -135,7 +135,7 @@ func SecretsmanagerSecrets() *schema.Table { Name: "tags", Description: "The list of user-defined tags associated with the secret", Type: schema.TypeJSON, - Resolver: resolveSecretsmanagerSecretsTags, + Resolver: client.ResolveTags, }, }, } @@ -227,12 +227,3 @@ func resolveSecretsmanagerSecretReplicationStatus(_ context.Context, _ schema.Cl } return diag.WrapError(resource.Set(c.Name, b)) } - -func resolveSecretsmanagerSecretsTags(_ context.Context, _ schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - r := resource.Item.(WrappedSecret) - tags := map[string]*string{} - for _, t := range r.Tags { - tags[*t.Key] = t.Value - } - return diag.WrapError(resource.Set(c.Name, tags)) -} diff --git a/resources/services/wafv2/web_acls.go b/resources/services/wafv2/web_acls.go index 2f0b7adf5..164a01046 100644 --- a/resources/services/wafv2/web_acls.go +++ b/resources/services/wafv2/web_acls.go @@ -2,7 +2,6 @@ package wafv2 import ( "context" - "encoding/json" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudfront" @@ -64,7 +63,7 @@ func Wafv2WebAcls() *schema.Table { Name: "default_action", Description: "The action to perform if none of the Rules contained in the WebACL match. ", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLDefaultAction, + Resolver: schema.PathResolver("DefaultAction"), }, { Name: "id", @@ -124,14 +123,14 @@ func Wafv2WebAcls() *schema.Table { Name: "logging_configuration", Description: "The LoggingConfiguration for the specified web ACL.", Type: schema.TypeStringArray, - Resolver: resolveWafV2WebACLRuleLoggingConfiguration, + Resolver: schema.PathResolver("LoggingConfiguration.LogDestinationConfigs"), }, }, Relations: []*schema.Table{ { Name: "aws_wafv2_web_acl_rules", Description: "A single rule, which you can use in a WebACL or RuleGroup to identify web requests that you want to allow, block, or count", - Resolver: fetchWafv2WebAclRules, + Resolver: schema.PathTableResolver("Rules"), Columns: []schema.Column{ { Name: "web_acl_cq_id", @@ -153,7 +152,7 @@ func Wafv2WebAcls() *schema.Table { Name: "statement", Description: "The AWS WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement. ", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLRuleStatement, + Resolver: schema.PathResolver("Statement"), }, { Name: "visibility_config_cloud_watch_metrics_enabled", @@ -177,13 +176,13 @@ func Wafv2WebAcls() *schema.Table { Name: "action", Description: "The action that AWS WAF should take on a web request when it matches the rule statement", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLRuleAction, + Resolver: schema.PathResolver("Action"), }, { Name: "override_action", Description: "The override action to apply to the rules in a rule group", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLRuleOverrideAction, + Resolver: schema.PathResolver("OverrideAction"), }, { Name: "labels", @@ -196,7 +195,7 @@ func Wafv2WebAcls() *schema.Table { { Name: "aws_wafv2_web_acl_post_process_firewall_manager_rule_groups", Description: "A rule group that's defined for an AWS Firewall Manager WAF policy. ", - Resolver: fetchWafv2WebAclPostProcessFirewallManagerRuleGroups, + Resolver: schema.PathTableResolver("PostProcessFirewallManagerRuleGroups"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -209,7 +208,7 @@ func Wafv2WebAcls() *schema.Table { Name: "statement", Description: "The processing guidance for an AWS Firewall Manager rule", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLPostProcessFirewallManagerRuleGroupStatement, + Resolver: schema.PathResolver("FirewallManagerStatement"), }, { Name: "name", @@ -220,7 +219,7 @@ func Wafv2WebAcls() *schema.Table { Name: "override_action", Description: "The override action to apply to the rules in a rule group", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLPostProcessFirewallManagerRuleGroupOverrideAction, + Resolver: schema.PathResolver("OverrideAction"), }, { Name: "priority", @@ -250,7 +249,7 @@ func Wafv2WebAcls() *schema.Table { { Name: "aws_wafv2_web_acl_pre_process_firewall_manager_rule_groups", Description: "A rule group that's defined for an AWS Firewall Manager WAF policy. ", - Resolver: fetchWafv2WebAclPreProcessFirewallManagerRuleGroups, + Resolver: schema.PathTableResolver("PreProcessFirewallManagerRuleGroups"), IgnoreInTests: true, Columns: []schema.Column{ { @@ -263,7 +262,7 @@ func Wafv2WebAcls() *schema.Table { Name: "statement", Description: "The processing guidance for an AWS Firewall Manager rule", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLPreProcessFirewallManagerRuleGroupStatement, + Resolver: schema.PathResolver("FirewallManagerStatement"), }, { Name: "name", @@ -274,7 +273,7 @@ func Wafv2WebAcls() *schema.Table { Name: "override_action", Description: "The override action to apply to the rules in a rule group", Type: schema.TypeJSON, - Resolver: resolveWafv2webACLPreProcessFirewallManagerRuleGroupOverrideAction, + Resolver: schema.PathResolver("OverrideAction"), }, { Name: "priority", @@ -304,7 +303,7 @@ func Wafv2WebAcls() *schema.Table { { Name: "aws_wafv2_web_acl_logging_configuration", Description: "The LoggingConfiguration for the specified web ACL.", - Resolver: fetchWafv2WebACLLoggingConfiguration, + Resolver: schema.PathTableResolver("LoggingConfiguration"), Columns: []schema.Column{ { Name: "web_acl_cq_id", @@ -326,7 +325,7 @@ func Wafv2WebAcls() *schema.Table { Name: "logging_filter", Description: "Filtering that specifies which web requests are kept in the logs and which are dropped. You can filter on the rule action and on the web request labels that were applied by matching rules during web ACL evaluation.", Type: schema.TypeJSON, - Resolver: resolveWafv2WebACLLoggingConfigurationLoggingFilter, + Resolver: schema.PathResolver("LoggingFilter"), }, { Name: "managed_by_firewall_manager", @@ -337,7 +336,7 @@ func Wafv2WebAcls() *schema.Table { Name: "redacted_fields", Description: "The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the cookie field in the firehose will be xxx. You can specify only the following fields for redaction: UriPath, QueryString, SingleHeader, Method, and JsonBody.", Type: schema.TypeJSON, - Resolver: resolveWafv2WebACLLoggingConfigurationRedactedFields, + Resolver: schema.PathResolver("RedactedFields"), }, }, }, @@ -470,55 +469,7 @@ func resolveWafv2webACLTags(ctx context.Context, meta schema.ClientMeta, resourc } return diag.WrapError(resource.Set(c.Name, outputTags)) } -func resolveWafv2webACLDefaultAction(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - webACL := resource.Item.(*WebACLWrapper) - if webACL.DefaultAction == nil { - return nil - } - data, err := json.Marshal(webACL.DefaultAction) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func fetchWafv2WebAclRules(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - webACL := parent.Item.(*WebACLWrapper) - res <- webACL.Rules - return nil -} -func resolveWafv2webACLRuleStatement(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - rule := resource.Item.(types.Rule) - if rule.Statement == nil { - return nil - } - data, err := json.Marshal(rule.Statement) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveWafv2webACLRuleAction(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - rule := resource.Item.(types.Rule) - if rule.Action == nil { - return nil - } - data, err := json.Marshal(rule.Action) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveWafv2webACLRuleOverrideAction(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - rule := resource.Item.(types.Rule) - if rule.OverrideAction == nil { - return nil - } - data, err := json.Marshal(rule.OverrideAction) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} + func resolveWafv2webACLRuleLabels(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { rule := resource.Item.(types.Rule) labels := make([]string, len(rule.RuleLabels)) @@ -527,88 +478,3 @@ func resolveWafv2webACLRuleLabels(ctx context.Context, meta schema.ClientMeta, r } return diag.WrapError(resource.Set(c.Name, labels)) } -func fetchWafv2WebAclPostProcessFirewallManagerRuleGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - webACL := parent.Item.(*WebACLWrapper) - res <- webACL.PostProcessFirewallManagerRuleGroups - return nil -} -func resolveWafv2webACLPostProcessFirewallManagerRuleGroupStatement(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - firewallManagerRuleGroup := resource.Item.(types.FirewallManagerRuleGroup) - if firewallManagerRuleGroup.FirewallManagerStatement == nil { - return nil - } - data, err := json.Marshal(firewallManagerRuleGroup.FirewallManagerStatement) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveWafv2webACLPostProcessFirewallManagerRuleGroupOverrideAction(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - firewallManagerRuleGroup := resource.Item.(types.FirewallManagerRuleGroup) - if firewallManagerRuleGroup.OverrideAction == nil { - return nil - } - data, err := json.Marshal(firewallManagerRuleGroup.OverrideAction) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func fetchWafv2WebAclPreProcessFirewallManagerRuleGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { - webACL := parent.Item.(*WebACLWrapper) - res <- webACL.PreProcessFirewallManagerRuleGroups - return nil -} -func resolveWafv2webACLPreProcessFirewallManagerRuleGroupStatement(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - firewallManagerRuleGroup := resource.Item.(types.FirewallManagerRuleGroup) - if firewallManagerRuleGroup.FirewallManagerStatement == nil { - return nil - } - data, err := json.Marshal(firewallManagerRuleGroup.FirewallManagerStatement) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func resolveWafv2webACLPreProcessFirewallManagerRuleGroupOverrideAction(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - firewallManagerRuleGroup := resource.Item.(types.FirewallManagerRuleGroup) - if firewallManagerRuleGroup.OverrideAction == nil { - return nil - } - data, err := json.Marshal(firewallManagerRuleGroup.OverrideAction) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, data)) -} -func fetchWafv2WebACLLoggingConfiguration(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, res chan<- interface{}) error { - rule := resource.Item.(*WebACLWrapper) - res <- rule.LoggingConfiguration - return nil -} -func resolveWafv2WebACLLoggingConfigurationRedactedFields(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - if conf := resource.Item.(*types.LoggingConfiguration); conf != nil { - out, err := json.Marshal(conf.RedactedFields) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, out)) - } - return nil -} -func resolveWafv2WebACLLoggingConfigurationLoggingFilter(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - if conf := resource.Item.(*types.LoggingConfiguration); conf != nil { - out, err := json.Marshal(conf.LoggingFilter) - if err != nil { - return diag.WrapError(err) - } - return diag.WrapError(resource.Set(c.Name, out)) - } - return nil -} -func resolveWafV2WebACLRuleLoggingConfiguration(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error { - if rule := resource.Item.(*WebACLWrapper); rule.LoggingConfiguration != nil { - return diag.WrapError(resource.Set(c.Name, rule.LoggingConfiguration.LogDestinationConfigs)) - } - return nil -}