Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
CNJR-3169: Add marketplace tags to AMIs
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsaunders committed Jan 5, 2024
1 parent 32ae33a commit 8da875b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion build-ami.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ if [ ! -f conjur-appliance.tar.gz ]; then
docker pull $IMAGE
docker save $IMAGE > conjur-appliance.tar
gzip conjur-appliance.tar
else
# If we didn't pull the docker image because
# an archive existed locally, load it
# so we can extract the pas releas file.
IMAGE="$(docker load < conjur-appliance.tar.gz|sed 's/^Loaded image: //')"
fi

# Extract pas_release from the docker image
pas_release="$(docker run \
--rm \
--entrypoint bash \
${IMAGE} \
-c 'cat /opt/conjur/etc/PAS_RELEASE')"

echo "Fetching latest Amazon Linux 2 AMI..."
export AMI=$(summon docker run --rm --env-file @SUMMONENVFILE \
mesosphere/aws-cli ec2 describe-images --filters '[
Expand All @@ -32,7 +44,11 @@ export PACKER_LOG=1
summon docker run \
-v $(pwd):/opt/ \
--env-file @SUMMONENVFILE -e AMI \
hashicorp/packer:full build -var "appliance_image_tag=$TAG" /opt/packer.json | tee packer.out
hashicorp/packer:full build \
-var "appliance_image_tag=$TAG" \
-var "pas_release=${pas_release}" \
/opt/packer.json \
| tee packer.out

# write the AMI ID to files for smoke tests archiving
ami_id=$(tail -3 packer.out | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }')
Expand Down
3 changes: 3 additions & 0 deletions packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"source_ami": "{{env `AMI`}}",
"appliance_image_tag": null,
"pas_release": null,
"instance_type": "m3.medium"
},
"builders": [{
Expand All @@ -26,6 +27,8 @@
}],
"tags": {
"DAP/version": "{{user `appliance_image_tag`}}",
"marketplace_version": "{{user `pas_release`}}",
"marketplace_component": "conjur_appliance",
"created": "{{timestamp}}"
}
}],
Expand Down

0 comments on commit 8da875b

Please sign in to comment.