-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support using custom KMS keys to build private stemcells #31
Conversation
as we paused the aws light stemcell builder tests. in the publish pipeline. |
5a6af98
to
4d66c9b
Compare
When building a private stemcells, the builder currently uses a managed KMS key which is default AWS account key. Using this key prevents sharing stemcells across accounts. Therefore we add the custom KMS key support.
4d66c9b
to
fed3ae5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
We're seeing failures with the drivers test. This may well be an issue with our setup, I'm still investigating. Posting the info here for posterity: Test script#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$( cd "$(dirname "${0}")" && pwd )"
source "${SCRIPT_DIR}/utils.sh"
tmp_dir="$(mktemp -d /tmp/stemcell_builder.XXXXXXX)"
trap '{ rm -rf ${tmp_dir}; }' EXIT
# US Regions
# shellcheck disable=SC2154
export AWS_ACCESS_KEY_ID="${access_key}"
# shellcheck disable=SC2154
export AWS_SECRET_ACCESS_KEY="${secret_key}"
# shellcheck disable=SC2154
export AWS_BUCKET_NAME="${bucket_name}"
# shellcheck disable=SC2154
export AWS_REGION="${region}"
export AWS_ROLE_ARN="${role_arn:-}"
# shellcheck disable=SC2154
export AWS_DESTINATION_REGION="${copy_region}"
# shellcheck disable=SC2154
export AWS_KMS_KEY_ID="${kms_key_id}"
# Fixtures
# shellcheck disable=SC2154
export S3_MACHINE_IMAGE_URL="${uploaded_machine_image_url}"
export S3_MACHINE_IMAGE_FORMAT="${uploaded_machine_image_format:=RAW}"
# shellcheck disable=SC2154
export EBS_VOLUME_ID="${existing_volume_id}"
# shellcheck disable=SC2154
export EBS_SNAPSHOT_ID="${existing_snapshot_id}"
# shellcheck disable=SC2154
export AMI_FIXTURE_ID="${ami_fixture_id}"
echo "Downloading machine image"
export MACHINE_IMAGE_PATH="${tmp_dir}/image.iso"
export MACHINE_IMAGE_FORMAT="RAW"
wget http://tinycorelinux.net/7.x/x86_64/archive/7.1/TinyCorePure64-7.1.iso \
-O "${MACHINE_IMAGE_PATH}"
echo "Running driver tests"
(
cd builder-src
# Run all driver specs in parallel to reduce test time
spec_count="$(grep "It(" -r driver | wc -l)"
go run github.com/onsi/ginkgo/v2/ginkgo -nodes "${spec_count}" -r driver
) Test output
|
Quoting from email:
Unfortunately both hard-coding a known aws account id, as well as fetching one via awsAccount = os.Getenv("AWS_ACCOUNT")
if awsAccount == "" {
GinkgoWriter.Printf("AWS_ACCOUNT was empty, attempting sts.GetCallerIdentity()")
session, err := session.NewSession()
Expect(err).NotTo(HaveOccurred())
result, err := sts.New(session).GetCallerIdentity(&sts.GetCallerIdentityInput{})
Expect(err).NotTo(HaveOccurred())
awsAccount = *result.Account
GinkgoWriter.Printf("GetCallerIdentity() return %s", awsAccount)
}
Expect(awsAccount).ToNot(BeEmpty(), "AWS_ACCOUNT must be set") Results in errors:
Perhaps there are additional constraints on the |
We fixed a couple of the test failures here by limiting which tests are using the sharing functionality. But the two tests that are testing sharing and kms keys still get this:
|
When building a private stemcell, the aws light stemcell builder currently uses a managed KMS key which is default AWS account key. Using this key prevents sharing stemcells across accounts. Therefore we add the custom KMS key support.
This PR belongs to Issue #30 and it relevant for building FPIS light stemcells.