diff --git a/scripts/ec2-ami/create-ec2-ami.sh b/scripts/ec2-ami/create-ec2-ami.sh index cbd333eeb..d75463743 100755 --- a/scripts/ec2-ami/create-ec2-ami.sh +++ b/scripts/ec2-ami/create-ec2-ami.sh @@ -17,7 +17,7 @@ MACHINE_NAME=$4 IMG_DIR="build/tmp/deploy/images/${MACHINE_NAME}" -TESTDATA_JSON="${IMG_DIR}/${IMAGE_NAME}-${MACHINE_NAME}.testdata.json" +TESTDATA_JSON="${IMG_DIR}/${IMAGE_NAME}-${MACHINE_NAME}.rootfs.testdata.json" DISTRO=$(jq -r '.DISTRO' $TESTDATA_JSON) DISTRO_CODENAME=$(jq -r '.DISTRO_CODENAME' $TESTDATA_JSON) @@ -38,19 +38,16 @@ echo TARGET_ARCH=$TARGET_ARCH echo IMAGE_ROOTFS_SIZE=$IMAGE_ROOTFS_SIZE echo AMI_DISK_SIZE_GB=$AMI_DISK_SIZE_GB -echo "Converting ${IMAGE_NAME}.rootfs.wic.vhdx to raw format" -qemu-img convert -f vhdx -O raw ${IMG_DIR}/${IMAGE_NAME}.rootfs.wic.vhdx ${IMG_DIR}/${IMAGE_NAME}.rootfs.raw - -echo "Pushing image ${IMAGE_NAME}.rootfs.raw to s3://${IMPORT_BUCKET_NAME}" -aws s3 cp ${IMG_DIR}/${IMAGE_NAME}.rootfs.raw s3://${IMPORT_BUCKET_NAME} +echo "Pushing image ${IMAGE_NAME}.wic.vhdx to s3://${IMPORT_BUCKET_NAME}" +aws s3 cp ${IMG_DIR}/${IMAGE_NAME}.wic.vhdx s3://${IMPORT_BUCKET_NAME} cat < image-import.json { "Description": "ewaol docker image", - "Format": "raw", + "Format": "vhd", "UserBucket": { "S3Bucket": "${IMPORT_BUCKET_NAME}", - "S3Key": "${IMAGE_NAME}.rootfs.raw" + "S3Key": "${IMAGE_NAME}.wic.vhdx" } } EOF @@ -88,6 +85,7 @@ else echo "Architecture not supported" exit 1 fi +DESCRIPTION=$(echo "DISTRO=$DISTRO;DISTRO_CODENAME=$DISTRO_CODENAME;DISTRO_NAME=$DISTRO_NAME;DISTRO_VERSION=$DISTRO_VERSION;BUILDNAME=$BUILDNAME;TARGET_ARCH=$ARCHITECTURE;IMAGE_NAME=$IMAGE_NAME" | cut -c -255) cat < register-ami.json { @@ -103,7 +101,7 @@ cat < register-ami.json } } ], - "Description": "DISTRO=$DISTRO;DISTRO_CODENAME=$DISTRO_CODENAME;DISTRO_NAME=$DISTRO_NAME;DISTRO_VERSION=$DISTRO_VERSION;BUILDNAME=$BUILDNAME;TARGET_ARCH=$ARCHITECTURE;IMAGE_NAME=$IMAGE_NAME", + "Description": "$DESCRIPTION", "RootDeviceName": "/dev/sda1", "BootMode": "uefi", "VirtualizationType": "hvm", @@ -111,7 +109,7 @@ cat < register-ami.json } EOF -AMI_NAME="${IMAGE_NAME}-${DISTRO}-${DISTRO_CODENAME}-${DISTRO_VERSION}-${BUILDNAME}-${ARCHITECTURE}" +AMI_NAME=$(echo "${IMAGE_NAME}-${DISTRO}-${DISTRO_CODENAME}-${DISTRO_VERSION}-${BUILDNAME}-${ARCHITECTURE}" | cut -c -128 | sed -e s/+/-/g) IMAGE_ID=$(aws ec2 describe-images --filters Name=name,Values=${AMI_NAME} | jq -r '.Images[].ImageId') if [ "$IMAGE_ID" != "" ]; then echo "Deregistering existing image $IMAGE_ID"