Skip to content

Commit

Permalink
website: add docs for the hcp-sbom provisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
devashish-patel authored and lbajolet-hashicorp committed Jan 21, 2025
1 parent 2edc265 commit 2213e5e
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions website/content/community-plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HashiCorp maintainers for advice on how to get started contributing.
## Provisioners

- File
- HCP SBOM
- InSpec
- PowerShell
- Shell
Expand Down
130 changes: 130 additions & 0 deletions website/content/docs/provisioners/hcp-sbom.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
description: |
The `hcp-sbom` Packer provisioner downloads an SBOM file from the guest VM and
sends it to HCP Packer when the build is done.
page_title: HCP SBOM - Provisioners
---

<BadgesHeader>
<PluginBadge type="official"/>
</BadgesHeader>

# HCP SBOM Provisioner

Type: `hcp-sbom`

The `hcp-sbom` Packer provisioner downloads an SBOM file from the guest machine
and sends it to HCP Packer when the build is complete (only if the template is
HCP-enabled). The SBOM file is automatically removed at the end of the process.
If you want to retain a copy of the SBOM file, you can specify the
`destination` option in the provisioner.

Currently, we support `CycloneDX` and `SPDX` SBOM formats in `JSON`.

## Basic Example


In HCL2:

```hcl
provisioner "hcp-sbom" {
source = "/tmp/sbom_cyclonedx.json"
destination = "./sbom/sbom_cyclonedx.json"
}
```

In JSON:

```json
{
"type": "hcp-sbom",
"source": "/tmp/sbom_cyclonedx.json",
"destination": "./sbom/sbom_cyclonedx.json"
}
```



## Configuration Reference

Required Parameters:

@include 'provisioner/hcp-sbom/Config-required.mdx'

Optional Parameters:

@include '/provisioner/hcp-sbom/Config-not-required.mdx'

## Example Usage


In HCL2:

```hcl
packer {
required_plugins {
docker = {
version = ">= 1.0.0"
source = "github.com/hashicorp/docker"
}
}
}
source "docker" "ubuntu" {
image = "ubuntu:20.04"
commit = true
}
build {
sources = ["source.docker.ubuntu"]
hcp_packer_registry {
bucket_name = "test-bucket"
}
provisioner "shell" {
inline = [
"apt-get update -y",
"apt-get install -y curl gpg",
"bash -c \"$(curl -sSL https://install.mondoo.com/sh)\"",
"cnquery sbom --output cyclonedx-json --output-target /tmp/sbom_cyclonedx.json",
]
}
provisioner "hcp-sbom" {
source = "/tmp/sbom_cyclonedx.json"
destination = "./sbom"
}
}
```

In JSON:

```json
{
"builders": [
{
"type": "docker",
"image": "ubuntu:20.04",
"commit": true
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"apt-get update -y",
"apt-get install -y curl",
"bash -c \"$(curl -sSL https://install.mondoo.com/sh)\"",
"cnquery sbom --output cyclonedx-json --output-target /tmp/sbom_cyclonedx.json"
]
},
{
"type": "hcp-sbom",
"source": "/tmp/sbom_cyclonedx.json",
"destination": "./sbom"
}
]
}
```
1 change: 1 addition & 0 deletions website/content/docs/provisioners/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following provisioners are included with Packer:
- [Breakpoint](/packer/docs/provisioners/breakpoint) - pause until the user presses `Enter` to resume
a build.
- [File](/packer/docs/provisioners/file) - upload files to machines image during a build.
- [HCP SBOM](/packer/docs/provisioners/hcp-sbom) - download SBOM file to machines and send to HCP Packer during a build.
- [Shell](/packer/docs/provisioners/shell) - run shell scripts on the machines image during a build.
- [Local Shell](/packer/docs/provisioners/shell-local) - run shell scripts on the host running Packer
during a build.
Expand Down
4 changes: 4 additions & 0 deletions website/data/docs-nav-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,10 @@
"title": "File",
"path": "provisioners/file"
},
{
"title": "HCP SBOM",
"path": "provisioners/hcp-sbom"
},
{
"title": "PowerShell",
"path": "provisioners/powershell"
Expand Down

0 comments on commit 2213e5e

Please sign in to comment.