I need to publish an ami to JFrog, how do I do it?

Hello All,

I am using amazon-ebs builder and then customizing the ami with some additional tool. Next, I need to publish this image to JFrog. I am using docker-import and docker-push in post-processors section, but amazon-ebs builder does not seem to like docker-import and docker-push. It needs docker as a builder. How do I accomplish this?

Thank you in advance.

You can’t push an AMI to a Docker container registry.

Amazon Machine Image - Wikipedia

Hello al1,

I am trying to push this to Jfrog artifactory, not docker registry.

My requirement is that I need to push this ami to JFrog artifactory.

my template:

{
“variables”: {
“aws_access_key”: “{{env AWS_ACCESS_KEY_ID}}”,
“aws_secret_key”: “{{env AWS_SECRET_ACCESS_KEY}}”,
“aws_region”: “us-east-1”,
“source_ami”: “ami-0c55b159cbfafe1f0”,
“ami_name”: “AMI_with_Java_{{timestamp}}”
},
“builders”: [
{
“type”: “amazon-ebs”,
“access_key”: “{{user aws_access_key}}”,
“secret_key”: “{{user aws_secret_key}}”,
“region”: “{{user aws_region}}”,
“source_ami”: “{{user source_ami}}”,
“instance_type”: “t2.micro”,
“ssh_username”: “ec2-user”,
“ami_name”: “{{user ami_name}}”
}
],
“provisioners”: [
{
“type”: “shell”,
“inline”: [
“sudo yum install -y java”
// Install any other tools you need
]
}
],
“post-processors”: [
{
“type”: “docker-import”,
“repository”: “jfrog.mycompany.com/local-images/”,
“tag”: “ami-with-java”,
},
“docker-push”
]
}

I am getting “Can only tag from Docker builder artifacts”.

“type”: “docker-import”,
“docker-push”

AMI is not compatible with docker push.

Any idea how can I accomplish pushing ami to JFrog artifactory without using docker-import and docker-push?

Just treat it as a regular binary file. Artifactory doesn’t support AMIs.

I read this on Packer’s documentation, this is exactly what I am trying to do:
A major benefit of this is that you can modify builder artifacts using shell-local and pass those modified artifacts into post-processors that may not have worked with the original builder. For example, maybe you want to export a Docker container from an amazon-ebs builder and then use Docker-push to put that Docker container into your Docker Hub account.

An EBS AMI is a snapshot of an entire EC2 instance at the block level, including the operating system. A docker image is just the application and what is needed to run it.

I think you misunderstand the statement you pasted. They are saying if you are running Docker on the EC2 instance then you can export the container image from that host to an external artefact.

Maybe start from the beginning - what are you trying to do?

Thank Al1,

I am taking a golden ami from our aws account, and adding some tools/software on this image to customize it and publish this image to Jfrog artifactory using packer.

Now I need to figure out a post-processor section (or anything that works) to publish this image to Jfrog.

{
“variables”: {
“aws_access_key”: “{{env AWS_ACCESS_KEY_ID }}”,
“aws_secret_key”: “{{env AWS_SECRET_ACCESS_KEY }}”,
“aws_region”: “us-east-1”,
“source_ami”: “ami-0c55b159cbfafe1f0”,
“ami_name”: “AMI_with_Java_{{timestamp}}”
},
“builders”: [
{
“type”: “amazon-ebs”,
“access_key”: “{{user aws_access_key }}”,
“secret_key”: “{{user aws_secret_key }}”,
“region”: “{{user aws_region }}”,
“source_ami”: “{{user source_ami }}”,
“instance_type”: “t2.micro”,
“ssh_username”: “ec2-user”,
“ami_name”: “{{user ami_name }}”
}
],
“provisioners”: [
{
“type”: “shell”,
“inline”: [
“sudo yum install -y java”
// Install any other tools you need
]
}
]
}

You would push your AMI back to AWS. As mentioned before Artifactory does not support AMIs.