Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions deploy/aws/cloudformation/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Metadata:
default: Hypeman
Parameters:
- HypemanVersion
- HypemanVersionSha256
- HypemanCliVersion
- HypemanBranch
ParameterLabels:
Expand Down Expand Up @@ -68,6 +69,8 @@ Metadata:
default: Hypeman data volume throughput
HypemanVersion:
default: Hypeman release
HypemanVersionSha256:
default: Hypeman release installer digest
HypemanBranch:
default: Hypeman source branch
HypemanCliVersion:
Expand Down Expand Up @@ -152,7 +155,12 @@ Parameters:
HypemanVersion:
Type: String
Default: v0.3.0
Description: Hypeman API release tag, or latest. Ignored when HypemanBranch is set.
Description: Hypeman API release tag, or latest. Ignored when HypemanBranch is set. Also pins the installer script used during provisioning.
HypemanVersionSha256:
Type: String
Default: fa98e8a2e21a173daaf33a2f788eb146f8e48de67940ea5ef91d8261c4269ef6
AllowedPattern: "^[0-9a-f]{64}$"
Description: SHA-256 of scripts/install.sh at HypemanVersion. Update this together with HypemanVersion, otherwise provisioning refuses to run the installer.
HypemanBranch:
Type: String
Default: ""
Expand Down Expand Up @@ -509,7 +517,24 @@ Resources:
else
export CLI_VERSION="${HypemanCliVersion}"
fi
curl -fsSL https://raw.githubusercontent.com/kernel/hypeman/main/scripts/install.sh | bash
# No checksum is published for the installer itself, so the digest is pinned
# as a parameter and checked before the script runs as root.
if [ "${HypemanVersion}" = "latest" ]; then
# Read the tag from the releases/latest redirect: piping that JSON into a
# reader that exits after the first match kills curl with SIGPIPE, and
# pipefail turns that into an aborted bootstrap.
installer_tag="$(curl -fsSLo /dev/null -w '%{url_effective}' https://github.com/kernel/hypeman/releases/latest)"
installer_tag="${!installer_tag##*/tag/}"
else
installer_tag="${HypemanVersion}"
fi
case "${!installer_tag}" in
v*) ;;
*) echo "could not resolve a pinned release tag for the installer" >&2; exit 1 ;;
esac
curl -fsSL -o /tmp/hypeman-install.sh "https://raw.githubusercontent.com/kernel/hypeman/${!installer_tag}/scripts/install.sh"
echo "${HypemanVersionSha256} /tmp/hypeman-install.sh" | sha256sum -c - || { echo "installer checksum mismatch, refusing to run it" >&2; exit 1; }
bash /tmp/hypeman-install.sh

install -d -m 755 /etc/systemd/system/hypeman.service.d
cat >/etc/systemd/system/hypeman.service.d/cloudformation.conf <<EOF
Expand Down
4 changes: 3 additions & 1 deletion deploy/aws/cloudformation/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ func TestCloudFormationLaunchContract(t *testing.T) {
assertGetAtt(t, requireField(t, hostLaunchTemplate, "Version"), "NestedVirtualizationLaunchTemplate.VersionNumber")

userData := nodeText(requireField(t, hostProperties, "UserData"))
assertContains(t, userData, "curl -fsSL https://raw.githubusercontent.com/kernel/hypeman/main/scripts/install.sh | bash")
assertContains(t, userData, "raw.githubusercontent.com/kernel/hypeman/${!installer_tag}/scripts/install.sh")
assertContains(t, userData, `echo "${HypemanVersionSha256} /tmp/hypeman-install.sh" | sha256sum -c -`)
assertContains(t, userData, "installer checksum mismatch")
assertContains(t, userData, `if [ -n "${DataVolumeThroughput}" ]; then`)
assertContains(t, userData, `Environment="CAPACITY__DISK_IO=${DataVolumeThroughput}MB/s"`)
assertContains(t, userData, "xfsprogs")
Expand Down