Skip to content

Commit

Permalink
🐛 fix aws.efs.filesystem resource (add init) (#3147)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Christoph Hartmann <[email protected]>
Co-authored-by: Tim Smith <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2024
1 parent 62e4a0e commit cfb0a75
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions providers/aws/resources/aws_efs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v10/llx"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/util/convert"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/util/jobpool"
"go.mondoo.com/cnquery/v10/providers/aws/connection"
Expand Down Expand Up @@ -115,6 +116,44 @@ func (a *mqlAwsEfsFilesystem) kmsKey() (*mqlAwsKmsKey, error) {
return a.GetKmsKey().Data, nil
}

func initAwsEfsFilesystem(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) {
if len(args) > 2 {
return args, nil, nil
}

if len(args) == 0 {
if ids := getAssetIdentifier(runtime); ids != nil {
args["name"] = llx.StringData(ids.name)
args["arn"] = llx.StringData(ids.arn)
}
}

if args["arn"] == nil {
return nil, nil, errors.New("arn required to fetch efs filesystem")
}

// load all efs filesystems
obj, err := CreateResource(runtime, "aws.efs", map[string]*llx.RawData{})
if err != nil {
return nil, nil, err
}
efs := obj.(*mqlAwsEfs)

rawResources := efs.GetFilesystems()
if err != nil {
return nil, nil, err
}

arnVal := args["arn"].Value.(string)
for i := range rawResources.Data {
fs := rawResources.Data[i].(*mqlAwsEfsFilesystem)
if fs.Arn.Data == arnVal {
return args, fs, nil
}
}
return nil, nil, errors.New("efs filesystem does not exist")
}

func (a *mqlAwsEfsFilesystem) backupPolicy() (interface{}, error) {
conn := a.MqlRuntime.Connection.(*connection.AwsConnection)
id := a.Id.Data
Expand Down

0 comments on commit cfb0a75

Please sign in to comment.