-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ aws cloudformation provider (#4105)
* ⭐️ cloudformation provider * Use CloudFormation as term for the config Co-authored-by: Tim Smith <[email protected]> * 🧹 handle case where template node has no content --------- Co-authored-by: Tim Smith <[email protected]>
- Loading branch information
1 parent
de49696
commit 54cecba
Showing
24 changed files
with
2,393 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
|
||
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-reference.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package config | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin" | ||
"go.mondoo.com/cnquery/v11/providers/cloudformation/provider" | ||
) | ||
|
||
var Config = plugin.Provider{ | ||
Name: "cloudformation", | ||
ID: "go.mondoo.com/cnquery/v11/providers/cloudformation", | ||
Version: "11.0.0", | ||
ConnectionTypes: []string{provider.DefaultConnectionType}, | ||
Connectors: []plugin.Connector{ | ||
{ | ||
Name: "cloudformation", | ||
Use: "cloudformation PATH", | ||
Short: "AWS CloudFormation template or AWS SAM template", | ||
MinArgs: 1, | ||
MaxArgs: 1, | ||
Discovery: []string{}, | ||
Flags: []plugin.Flag{}, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package connection | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/aws-cloudformation/rain/cft" | ||
"github.com/aws-cloudformation/rain/cft/parse" | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory" | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin" | ||
) | ||
|
||
var _ plugin.Connection = (*CloudformationConnection)(nil) | ||
|
||
type CloudformationConnection struct { | ||
plugin.Connection | ||
Conf *inventory.Config | ||
asset *inventory.Asset | ||
// Add custom connection fields here | ||
path string | ||
cftTemplate cft.Template | ||
} | ||
|
||
func NewCloudformationConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*CloudformationConnection, error) { | ||
conn := &CloudformationConnection{ | ||
Connection: plugin.NewConnection(id, asset), | ||
Conf: conf, | ||
asset: asset, | ||
} | ||
// initialize your connection here | ||
cc := asset.Connections[0] | ||
path := cc.Options["path"] | ||
conn.path = path | ||
|
||
f, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
|
||
cftTemplate, err := parse.Reader(f) | ||
if err != nil { | ||
return nil, err | ||
} | ||
conn.cftTemplate = cftTemplate | ||
|
||
return conn, nil | ||
} | ||
|
||
func (c *CloudformationConnection) Name() string { | ||
return "cloudformation" | ||
} | ||
|
||
func (c *CloudformationConnection) Asset() *inventory.Asset { | ||
return c.asset | ||
} | ||
|
||
func (c *CloudformationConnection) CftTemplate() cft.Template { | ||
return c.cftTemplate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package main | ||
|
||
import ( | ||
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin/gen" | ||
"go.mondoo.com/cnquery/v11/providers/cloudformation/config" | ||
) | ||
|
||
func main() { | ||
gen.CLI(&config.Config) | ||
} |
Oops, something went wrong.