Skip to content

Commit

Permalink
Merge branch 'main' into resource_import
Browse files Browse the repository at this point in the history
  • Loading branch information
mati007thm authored Jul 4, 2024
2 parents 7199fd6 + 7233095 commit 4d0ea10
Show file tree
Hide file tree
Showing 40 changed files with 1,736 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ linters:
- unconvert
- unparam
- unused
- vet
- govet
9 changes: 6 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
# Copyright (c) Mondoo, Inc.
# SPDX-License-Identifier: BUSL-1.1

---
version: 2
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
Expand Down Expand Up @@ -57,4 +60,4 @@ release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
disable: true
75 changes: 75 additions & 0 deletions docs/data-sources/assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_assets Data Source - terraform-provider-mondoo"
subcategory: ""
description: |-
The asset data source allows you to fetch assets from a space.
---

# mondoo_assets (Data Source)

The asset data source allows you to fetch assets from a space.

## Example Usage

```terraform
provider "mondoo" {}
data "mondoo_assets" "assets_data" {
space_id = "my-space-1234567"
}
output "asset_mrns" {
description = "MRNs of the assets"
value = [for asset in data.mondoo_assets.assets_data.assets : asset.mrn]
}
output "asset_names" {
description = "Names of the assets"
value = [for asset in data.mondoo_assets.assets_data.assets : asset.name]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `space_id` (String) The unique identifier of the space.
- `space_mrn` (String) The unique Mondoo Resource Name (MRN) of the space.

### Read-Only

- `assets` (Attributes List) The list of assets in the space. (see [below for nested schema](#nestedatt--assets))

<a id="nestedatt--assets"></a>
### Nested Schema for `assets`

Read-Only:

- `annotations` (Attributes List) The annotations/tags of the asset. (see [below for nested schema](#nestedatt--assets--annotations))
- `asset_type` (String) The type of the asset.
- `id` (String) The unique identifier of the asset.
- `mrn` (String) The unique Mondoo Resource Name (MRN) of the asset.
- `name` (String) The name of the asset.
- `reference_ids` (List of String) The reference IDs of the asset.
- `score` (Attributes) The overall score of the asset. (see [below for nested schema](#nestedatt--assets--score))
- `state` (String) The current state of the asset.
- `updated_at` (String) The timestamp when the asset was last updated.

<a id="nestedatt--assets--annotations"></a>
### Nested Schema for `assets.annotations`

Read-Only:

- `key` (String) The key of the annotation.
- `value` (String) The value of the annotation.


<a id="nestedatt--assets--score"></a>
### Nested Schema for `assets.score`

Read-Only:

- `grade` (String) The grade of the asset.
- `value` (Number) The score value of the asset.
12 changes: 11 additions & 1 deletion docs/data-sources/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ Organization data source
provider "mondoo" {}
data "mondoo_organization" "org" {
id = "reverent-ride-275852"
id = "your-org-1234567"
}
output "org_mrn" {
description = "MRN of the organization"
value = data.mondoo_organization.org.mrn
}
output "org_name" {
description = "Name of the organization"
value = data.mondoo_organization.org.name
}
output "org_id" {
description = "ID of the organization"
value = data.mondoo_organization.org.id
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
54 changes: 54 additions & 0 deletions docs/data-sources/policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_policy Data Source - terraform-provider-mondoo"
subcategory: ""
description: |-
Data source for policies and querypacks
---

# mondoo_policy (Data Source)

Data source for policies and querypacks

## Example Usage

```terraform
data "mondoo_policy" "policy" {
space_id = "your-space-1234567"
catalog_type = "ALL" # available options: "ALL", "POLICY", "QUERYPACK"
assigned_only = true
}
output "policies_mrn" {
value = [for policy in data.mondoo_policy.policy.policies : policy.policy_mrn]
description = "The MRN of the policies in the space according to the filter criteria."
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `assigned_only` (Boolean) Only return enabled policies if set to `true`
- `catalog_type` (String) Catalog type of either `ALL`, `POLICY` or `QUERYPACK`. Defaults to `ALL`
- `space_id` (String) Space ID
- `space_mrn` (String) Space MRN

### Read-Only

- `policies` (Attributes List) List of policies (see [below for nested schema](#nestedatt--policies))

<a id="nestedatt--policies"></a>
### Nested Schema for `policies`

Read-Only:

- `action` (String) Policies can be set to `Null`, `IGNORE` or `ACTIVE`
- `assigned` (Boolean) Determines if a policy is enabled or disabled
- `created_at` (String) Timestamp of policy creation
- `is_public` (Boolean) Determines if a policy is public or private
- `policy_mrn` (String) Unique policy Mondoo Resource Name
- `policy_name` (String) Policy name
- `updated_at` (String) Timestamp of policy update
- `version` (String) Version
7 changes: 6 additions & 1 deletion docs/data-sources/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "mondoo_org" {
provider "mondoo" {}
resource "mondoo_space" "test" {
org_id = var.mondoo_org.value
org_id = var.mondoo_org
name = "test-space"
}
Expand All @@ -42,6 +42,11 @@ output "space_mrn" {
description = "The MRN of the space"
value = data.mondoo_space.space.mrn
}
output "space_id" {
description = "The ID of the space"
value = data.mondoo_space.space.id
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
54 changes: 54 additions & 0 deletions docs/resources/custom_framework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_custom_framework Resource - terraform-provider-mondoo"
subcategory: ""
description: |-
Set custom Compliance Frameworks for a Mondoo Space.
---

# mondoo_custom_framework (Resource)

Set custom Compliance Frameworks for a Mondoo Space.

## Example Usage

```terraform
provider "mondoo" {
region = "us"
}
variable "mondoo_org" {
description = "The Mondoo Organization ID"
type = string
default = "my-org-1234567"
}
variable "my_custom_framework" {
description = "Path to the custom policy file. The file must be in MQL format."
type = string
default = "framework.mql.yaml"
}
# Create a new space
resource "mondoo_space" "my_space" {
name = "Custom Framework Space"
org_id = var.mondoo_org
}
resource "mondoo_custom_framework" "compliance_framework_example" {
space_id = mondoo_space.my_space.id
data_url = var.my_custom_framework
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `data_url` (String) URL to the custom Compliance Framework data.
- `space_id` (String) Mondoo Space Identifier.

### Read-Only

- `mrn` (String) Mondoo Resource Name.
47 changes: 47 additions & 0 deletions docs/resources/framework_assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mondoo_framework_assignment Resource - terraform-provider-mondoo"
subcategory: ""
description: |-
Set Compliance Frameworks for a Mondoo Space.
---

# mondoo_framework_assignment (Resource)

Set Compliance Frameworks for a Mondoo Space.

## Example Usage

```terraform
provider "mondoo" {
region = "us"
}
variable "mondoo_org" {
description = "The Mondoo Organization ID"
type = string
default = "my-org-1234567"
}
# Create a new space
resource "mondoo_space" "my_space" {
name = "Framework Space"
org_id = var.mondoo_org
}
resource "mondoo_framework_assignment" "compliance_framework_example" {
space_id = mondoo_space.my_space.id
framework_mrn = ["//policy.api.mondoo.app/frameworks/cis-controls-8",
"//policy.api.mondoo.app/frameworks/iso-27001-2022"]
enabled = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `enabled` (Boolean) Enable or disable the Compliance Framework.
- `framework_mrn` (List of String) Compliance Framework MRN.
- `space_id` (String) Mondoo Space Identifier.
15 changes: 15 additions & 0 deletions examples/data-sources/mondoo_assets/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
provider "mondoo" {}

data "mondoo_assets" "assets_data" {
space_id = "my-space-1234567"
}

output "asset_mrns" {
description = "MRNs of the assets"
value = [for asset in data.mondoo_assets.assets_data.assets : asset.mrn]
}

output "asset_names" {
description = "Names of the assets"
value = [for asset in data.mondoo_assets.assets_data.assets : asset.name]
}
8 changes: 8 additions & 0 deletions examples/data-sources/mondoo_assets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
mondoo = {
source = "mondoohq/mondoo"
version = ">= 0.4.0"
}
}
}
14 changes: 12 additions & 2 deletions examples/data-sources/mondoo_organization/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
provider "mondoo" {}

data "mondoo_organization" "org" {
id = "reverent-ride-275852"
id = "your-org-1234567"
}

output "org_mrn" {
description = "MRN of the organization"
value = data.mondoo_organization.org.mrn
}
}

output "org_name" {
description = "Name of the organization"
value = data.mondoo_organization.org.name
}

output "org_id" {
description = "ID of the organization"
value = data.mondoo_organization.org.id
}
10 changes: 10 additions & 0 deletions examples/data-sources/mondoo_policy/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data "mondoo_policy" "policy" {
space_id = "your-space-1234567"
catalog_type = "ALL" # available options: "ALL", "POLICY", "QUERYPACK"
assigned_only = true
}

output "policies_mrn" {
value = [for policy in data.mondoo_policy.policy.policies : policy.policy_mrn]
description = "The MRN of the policies in the space according to the filter criteria."
}
8 changes: 8 additions & 0 deletions examples/data-sources/mondoo_policy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
mondoo = {
source = "mondoohq/mondoo"
version = ">= 0.4.0"
}
}
}
7 changes: 6 additions & 1 deletion examples/data-sources/mondoo_space/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variable "mondoo_org" {
provider "mondoo" {}

resource "mondoo_space" "test" {
org_id = var.mondoo_org.value
org_id = var.mondoo_org
name = "test-space"
}

Expand All @@ -27,3 +27,8 @@ output "space_mrn" {
description = "The MRN of the space"
value = data.mondoo_space.space.mrn
}

output "space_id" {
description = "The ID of the space"
value = data.mondoo_space.space.id
}
Loading

0 comments on commit 4d0ea10

Please sign in to comment.