Skip to content

Commit

Permalink
more aws cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavgerchev committed Jun 11, 2024
1 parent 096547e commit e69a642
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
6 changes: 1 addition & 5 deletions providers/aws/connection/awsec2ebsconn/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ func NewAwsEbsConnection(id uint32, conf *inventory.Config, asset *inventory.Ass
return c, errors.Wrap(err, "unable to validate")
}

// In case of an error, c.Close() needs this:
asset.Connections[0].Options["scanner-id"] = c.scannerInstance.Id
asset.Connections[0].Options["scanner-region"] = c.scannerInstance.Region

// 4. setup the volume for scanning
// check if we got the no setup override option. this implies the target volume is already attached to the instance
// this is used in cases where we need to test a snapshot created from a public marketplace image. the volume gets attached to a brand
Expand Down Expand Up @@ -153,14 +149,14 @@ func NewAwsEbsConnection(id uint32, conf *inventory.Config, asset *inventory.Ass
asset.Connections[0].Options["createdBy"] = "Mondoo"
}
}

if conf.Options[snapshot.NoSetup] == "true" {
conf.PlatformId = awsec2.MondooInstanceID(i.AccountID, targetRegion, convert.ToString(instanceinfo.InstanceId))
}
asset.PlatformIds = []string{conf.PlatformId}
asset.Connections[0].Options["device-name"] = volLocation
c.deviceLocation = volLocation

log.Debug().Interface("info", c.target).Str("type", c.targetType).Msg("target")
deviceConn, err := device.NewDeviceConnection(id, &inventory.Config{
Type: "device",
PlatformId: conf.PlatformId,
Expand Down
9 changes: 0 additions & 9 deletions providers/aws/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,6 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba

case string(awsec2ebsconn.EBSConnectionType):
conn, err = awsec2ebsconn.NewAwsEbsConnection(connId, conf, asset)
if conn.Asset() != nil && len(conn.Asset().Connections) > 0 && conn.Asset().Connections[0].Options["mounted"] != "" {
// if we've already done all the mounting work, then reassign the connection
// to be the filesystem connection so we use the right connection down the line
deviceConn := conn.(*awsec2ebsconn.AwsEbsConnection).DeviceProvider
conn = deviceConn
req.Asset = deviceConn.Asset()
req.Asset.Connections[0] = deviceConn.Conf
asset = req.Asset
}
default:
conn, err = connection.NewAwsConnection(connId, asset, conf)
}
Expand Down

0 comments on commit e69a642

Please sign in to comment.