Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix aws.efs.filesystem resource (add init) #3147

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading