Commit Graph
18747 Commits
Author SHA1 Message Date
trujillo-adamandrita 3ddaae6e68 Apply suggestions from code review
Co-authored-by: rita <[email protected]>
2025-01-31 14:09:46 -08:00
trujillo-adam cf46ce621f remaining packer content 2025-01-29 16:14:35 -08:00
trujillo-adam 0c0f7a6c41 Merge pull request #13282 from hashicorp/docs/packer-seo-templates-batch1
Docs/packer seo templates batch1
2025-01-29 10:41:19 -08:00
trujillo-adam f46a4351e6 Apply suggestions from code review 2025-01-29 10:36:05 -08:00
trujillo-adamandRose M Koron f86801abc6 Apply suggestions from code review
Co-authored-by: Rose M Koron <[email protected]>
2025-01-29 08:33:36 -08:00
trujillo-adam 88478059d6 Merge pull request #13283 from hashicorp/docs/packer-seo-templates-batch2
packer-seo-templates-batch2
2025-01-29 08:15:58 -08:00
trujillo-adamandBrian McClain ad18e70980 Apply suggestions from code review
Co-authored-by: Brian McClain <[email protected]>
2025-01-29 08:15:40 -08:00
trujillo-adam 2929047d88 contextual and datatime functions 2025-01-28 14:59:40 -08:00
trujillo-adam 75678c5de2 file functions references 2025-01-28 12:15:44 -08:00
trujillo-adam 953c814ad5 crypto and collection functions references 2025-01-28 11:22:54 -08:00
trujillo-adam 54da4b047f hcl templates content except functions 2025-01-28 09:44:33 -08:00
trujillo-adam a9ada1d19d hcl template blocks 2025-01-27 14:44:31 -08:00
trujillo-adam c5036e233d Merge pull request #13273 from hashicorp/docs/packer-seo-provs
updated provisioners reference topics
2025-01-24 14:18:57 -08:00
trujillo-adamandBrian McClain f62463ef26 Apply suggestions from code review
Co-authored-by: Brian McClain <[email protected]>
2025-01-24 14:14:46 -08:00
trujillo-adam b42e78ae1a Merge pull request #13272 from hashicorp/docs/packer-seo-builders-plugins
Docs/packer seo builders plugins
2025-01-24 14:13:26 -08:00
trujillo-adamandBrian McClain 9fd83c155c Apply suggestions from code review
Co-authored-by: Brian McClain <[email protected]>
2025-01-24 14:08:16 -08:00
trujillo-adam 85ff38ff38 Merge pull request #13267 from hashicorp/docs/packer-seo-ds-ref
seo improvements data sources references
2025-01-24 13:55:35 -08:00
trujillo-adamandBrian McClain 9cf014fa08 Apply suggestions from code review
Co-authored-by: Brian McClain <[email protected]>
2025-01-24 13:50:20 -08:00
trujillo-adam ba3c07bf66 legacy json template ref 2025-01-24 12:28:52 -08:00
trujillo-adam 7645ee0ff4 updated provisioners reference topics 2025-01-23 19:41:57 -08:00
trujillo-adam da35666689 buiders, plugins, and some top-level pages 2025-01-23 16:02:43 -08:00
trujillo-adam 711a38bdd4 intro articles 2025-01-23 11:02:12 -08:00
trujillo-adam 8eb277b122 seo improvements data sources references 2025-01-21 19:30:41 -08:00
Devashish 2e609231b4 website: add docs for the hcp-sbom provisioner 2025-01-21 16:57:50 -05:00
Jenna Goldstrich 8dcd9fe1a5 Ensure org ID is set and move UploadSbom to api package 2025-01-21 16:57:50 -05:00
Jenna Goldstrich 347c57306c hcp: use enum for HCP SBOM upload
Since the protos for uploading an SBOM for a build have been changed to
use an enumeration instead of a plain string with the latest revisions
to the HCP Packer SBOM support feature, we update how we reference those
values for the SBOM format to use that enum instead.
2025-01-21 16:57:50 -05:00
Lucas Bajolet 619c524afb command: exit non-zero if uploading to HCP failed
In the current state, a Packer build that succeeds but fails to push its
metadata to HCP for reasons other than a lack of artifact will always
succeed from the perspective of a user invoking `packer build`.

This can be a bit misleading, as users may expect their artifacts to
appear on HCP Packer if their build succeeded on Packer Core, so this
commit changes this behaviour, instead reporting HCP errors as a real
error if the build failed, so packer returns a non-zero error code if
this happens.
2025-01-21 16:57:50 -05:00
Lucas Bajolet 9b3f29faf9 hcp: wrap completeBuild to mark as failed on error
When a build cannot be completed without errors, the build state was
left as running, unless the build explicitly failed, which meant that
HCP Packer would be responsible for changing the status after the
heartbeats for the build stopped being sent for two 5m periods.

This commit changes this behaviour, by explicitly marking the build as
failed if something did not work while trying to complete a build on HCP
Packer, even if the local Packer core build succeeded before that.
2025-01-21 16:57:50 -05:00
Jenna Goldstrich 362c547211 hcp: integrate SBOM upload to HCP code
Since packer now supports keeping track of SBOMs produced during a
build, we add the code to integrate those changes into the internal/hcp
package, so we do upload them on build completion.
2025-01-21 16:57:50 -05:00
Lucas Bajolet a8c9467463 packer_test: add integration tests for hcp-sbom 2025-01-21 16:57:50 -05:00
Devashish a353260f5d packer: add hcp-sbom provisioner
The hcp-sbom provisioner is a provisioner that acts essentially like a
download-only file provisioner, which also verifies the file downloaded
is a SPDX/CycloneDX JSON-encoded SBOM file, and sets up its upload to
HCP Packer later on.
2025-01-21 16:57:50 -05:00
Lucas Bajolet 56400f27cb packer_test: add gob/pb test suite
With the draft to support both gob and protobuf as serialisation formats
for Packer, along with the SDK changes that propel them, we add a series
of tests that make sure the logic that picks which protocol is solid and
functional.

These tests rely on building several versions of the tester plugin, with
and without protobuf support, to then install them in the tests as
needed to test the logic of Packer using packer build with them, and
templates that require multiple plugins.
2025-01-21 16:44:03 -05:00
Lucas Bajolet 9f6f0ba6a2 packer: pick protobuf/gob for serialisation (#13025)
As we're trying to move away from gob for serialising data over the
wire, this commit adds the capability for Packer to pick dynamically
between gob or protobuf for the serialisation format to communicate with
plugins.

As it stands, if all the plugins discovered are compatible with
protobuf, and we have not forced gob usage, protobuf will be the
serialisation format picked.

If any plugin is not compatible with protobuf, gob will be used for
communicating with all the plugins that will be used over the course of
a command.
2025-01-21 16:44:03 -05:00
Lucas Bajolet 9f3e32b9fc hcl2template: add support for raw aws secrets
As the SDK now supports it in the context of legacy templating engine,
we add support in HCL2 for the aws_secretsmanager_raw function, which
gets the raw value of a secret from aws secrets manager.
2025-01-21 14:39:49 -05:00
Jenna Goldstrich cf6a82fae8 Make error less brittle to fix upcoming error with HCP SDK Go changing how we return 404 error 2025-01-21 11:33:32 -08:00
Lucas Bajolet dddc1fb356 go.mod: bump Packer plugin SDK to v0.6.0
Since the version 0.6.0 of the plugin SDK was released yesterday, we
bump packer to use this version.
This change adds new functions to use within Packer regarding AWS
secretsmanager, along with changes to how plugins can communicate
over-the-wire (e.g. using protobuf/msgpack for serialising
configurations instead of gob).
2025-01-21 11:29:53 -05:00
Joban 2ff129cd34 fix(example): make UUIDv4 example RFC compliant
# Description

The output of the example on [uuidv4 Function](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/uuid/uuidv4) is not a valid RFC compliant UUIDv4. It indicates the usage of the `uuidv4()` function and outputs `b5ee72a3-54dd-c4b8-551c-4bdc0204cedb` which is not a valid UUIDv4.

I've corrected the example to output a UUIDv4 conforming to the RFC as such `xxxxxxxx-xxxx-4xxx-Nxxx-xxxxxxxxxxxx`, where:

- The 13th character is always `4` (indicating version 4).
- The 17th character must be either `8`, `9`, `a`, or `b` (indicating the first character of the variant).

# Changes

```diff
- b5ee72a3-54dd-c4b8-551c-4bdc0204cedb
+ 9fc99a70-7cd5-482d-bb2b-03af016e4e94
```

Replaces the old UUID output with a valid RFC compliant UUIDv4.

# References

- [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
- [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562)

# Misc.

To make sure this wasn't an issue with the `uuidv4()` function within Hashicorp's [packer](https://github.com/hashicorp/packer) I tested the function in the following way:

### Command executed:

```ps
> .\packer.exe inspect .\uuid.pkr.hcl
```

### Contents of the _uuid.pkr.hcl_ file:

```hcl
locals {
  uuid_0 = uuidv4()
  uuid_1 = uuidv4()
  uuid_2 = uuidv4()
  uuid_3 = uuidv4()
  uuid_4 = uuidv4()
  uuid_5 = uuidv4()
  uuid_6 = uuidv4()
  uuid_7 = uuidv4()
  uuid_8 = uuidv4()
  uuid_9 = uuidv4()
}
```

### Output:

```ps
Packer Inspect: HCL2 mode

> input-variables:


> local-variables:

local.uuid_0: "90877db8-5519-46ea-ae15-7dfb92594064"
local.uuid_1: "fe6a4649-97d9-4686-b981-3295175f941a"
local.uuid_2: "9944d83d-dab2-4cfb-a1db-572d19271e7a"
local.uuid_3: "547cddb7-c979-4b87-90d0-2bd9b68858b5"
local.uuid_4: "c13dc47a-552c-4dfb-a75d-2f63bb248b41"
local.uuid_5: "3db1ce29-bdde-4642-b010-1a41d47c22a3"
local.uuid_6: "4a020460-edd1-471d-b8a2-5956c0c68257"
local.uuid_7: "1845bf87-6908-4fc0-8f11-b5b4f36c60a7"
local.uuid_8: "f5c7e552-b799-45f3-8172-46162eadfd89"
local.uuid_9: "057c2eaf-6769-4a8d-90c8-775aec80496a"

> builds:
```
2025-01-21 10:13:57 -05:00
Martin Grogan cb4965d53a hcl2template: add anytrue function
this function add the hcl2 anytrue function which takes a collection and
return true if any of the element is true.
2025-01-21 10:07:10 -05:00
Martin Grogan 476ddc3810 hcl2template: add alltrue function
add an hcl2 function that return true if all the value in a collection
are true, this function was derived from terraform codebase
2025-01-21 10:07:10 -05:00
Gustavo Cruz 7f64ca11f6 fix: packer validate unsupported type error
`packer validate` would output the same error message four times per
unsupported root block type found in a template (e.g., 'src' instead of
'source'). This behavior was due to a function being called four times
for each file on each stage of the parsing.
2025-01-21 10:06:45 -05:00
dependabot[bot] 3826a94758 build(deps): bump golang.org/x/net in /packer_test/common/plugin_tester
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.23.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-01-21 09:49:43 -05:00
dependabot[bot] 8b2a3ccdf3 build(deps): bump github.com/hashicorp/hcp-sdk-go
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.112.0 to 0.131.0.
- [Release notes](https://github.com/hashicorp/hcp-sdk-go/releases)
- [Changelog](https://github.com/hashicorp/hcp-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcp-sdk-go/compare/v0.112.0...v0.131.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcp-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-01-21 09:49:04 -05:00
hashicorp-tsccr[bot] ea9d02d596 Result of tsccr-helper -log-level=info gha update .github/ 2025-01-20 17:25:44 -05:00
Lucas Bajolet f24c978d46 go.mod: bump go-git to v5.13.0
Version 5.11.0 of the go-git library is vulnerable to two CVEs as
reported by our scanners.

Both are not impacting Packer since we only use go-git to read values
from a local Git repository, but still we upgrade our version to 5.13.0
so those reports don't apply to us.
2025-01-06 15:48:15 -05:00
Lucas Bajolet 783d5113ba release: ignore AWS SDK vulnerability for release
The reported AWS S3 vulnerability was inherited from the go-getter
module that Packer uses for downloading files from external sources.

This vulnerability only impacts S3 uploads, therefore Packer is not
vulnerable itself as go-getter only downloads such blobs.

Since the change required to fix this advisory would be to bump the AWS
SDK to v2, this being a major change, is not something to do lightly, so
we opted to ignore this advisory for now so it doesn't block upcoming
releases.
2025-01-06 15:12:19 -05:00
Martin Grogan 024bf7259a docs: make TMPDIR clickable
The option is less visible than the other one and by adding the quote,
it creates an anchor that will make it easier to link.
2024-12-23 15:18:33 -05:00
Lucas Bajolet 77bf0282a7 go.mod: bump golang.org/x/net to v0.33.0
The version of golang.org/x/net that we're using (v0.25.0) is vulnerable
to GO-2024-3333, a DoS vulnerability.
Packer is not particularly vulnerable to this, as we are not a hosted
service, but since security scanners report this, and the fix is rather
simple, we address it today.
2024-12-20 13:47:18 -05:00
dependabot[bot] 38f081c9ed build(deps): bump golang.org/x/crypto
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.31.0.
- [Commits](https://github.com/golang/crypto/compare/v0.21.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-12-20 11:11:20 -05:00
Martin Grogan 5940ab6d64 docs: put hcl2 example in first tab 2024-12-20 10:39:32 -05:00
Lucas Bajolet b6141fd532 command: copy AWS plugin structures for upgrade
The hcl2_upgrade command transforms a JSON template into an HCL2
template for use with Packer.

The command is quite fragile already, but given that this is the last
remaining fragment that causes Packer to depend on the AWS SDK directly,
we can do away with it.

This commit therefore imports the definitions for AWS access config, so
we can extract this information from the JSON template, and include it
in the definition of the output source for AWS, since we manage this one
differently from other sources.

This allows us to not depend on the AWS plugin directly, which in turn
makes Packer not need to link with the AWS plugin when compiling the
executable.
We are still depending on the AWS SDK for now since the SDK exposes a
aws_secretsmanager function that can be used for interpolation (legacy
JSON interpolation to be clear), so this cannot be removed from now, but
we should consider some form of remediation in the future.
2024-12-17 17:42:58 -05:00