func()

in tflint-ruleset-aws-serverless/rules/aws_appsync_graphql_api_tracing.go [44:79]


func (r *AwsAppsyncGraphqlAPITracingRule) Check(runner tflint.Runner) error {
	return runner.WalkResources(r.resourceType, func(resource *configs.Resource) error {
		body, _, diags := resource.Config.PartialContent(&hcl.BodySchema{
			Attributes: []hcl.AttributeSchema{
				{
					Name:     r.attributeName,
					Required: true,
				},
			},
		})

		if diags.HasErrors() {
			runner.EmitIssue(
				r,
				fmt.Sprintf("\"%s\" is not present.", r.attributeName),
				body.MissingItemRange,
			)
			return nil
		}

		attribute := body.Attributes[r.attributeName]
		var xrayTracingEnabled string
		err := runner.EvaluateExpr(attribute.Expr, &xrayTracingEnabled, nil)

		return runner.EnsureNoError(err, func() error {
			if xrayTracingEnabled != "true" {
				runner.EmitIssueOnExpr(
					r,
					fmt.Sprintf("\"%s\" should be set to true.", r.attributeName),
					attribute.Expr,
				)
			}
			return nil
		})
	})
}