aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Ambiguous JSON object required for `ecr put-image`

Open AndrewCharlesHay opened this issue 1 year ago • 5 comments

Describe the issue

I'm trying to pass the following JSON object in the --image-manifest argument to tag a helm chart but I keep getting the following error:

An error occurred (InvalidParameterException) when calling the PutImage operation: Invalid parameter at 'ImageManifest' failed to satisfy constraint: 'Invalid JSON syntax'

The documentation gives an example of a JSON object related to Docker that mine JSON closely resembles but there is never any definition of what is required. I just have to guess and hope that it matches the expectations.

{
  "schemaVersion": 2,
  "config": {
    "mediaType": "application/vnd.cncf.helm.config.v1+json",
    "digest": "sha256:34cd28a1b9b3237128a0dd0f7c03edc36c112887b4e491ea6f3d6fe469ac4a86",
    "size": 151
  },
  "layers": [
    {
      "mediaType": "application/vnd.cncf.helm.chart.content.v1.tar+gzip",
      "digest": "sha256:777d773fa08d8a7b256dc78d9ee5dfa96b2fc8dee66d531f831bd7ef098b2dc2",
      "size": 4513
    }
  ],
  "annotations": {
    "org.opencontainers.image.created": "2024-04-04T14:44:40Z",
    "org.opencontainers.image.description": "BMS | Worflow Platform Service",
    "org.opencontainers.image.title": "svc-bms-wkfptf",
    "org.opencontainers.image.version": "1.6.0"
  },
  "mediaType": "application/vnd.cncf.helm.config.v1+json"
}

Links

https://docs.aws.amazon.com/cli/latest/reference/ecr/put-image.html

AndrewCharlesHay avatar Apr 04 '24 15:04 AndrewCharlesHay

Hi @AndrewCharlesHay, thanks for reaching out. I did some testing, and it seems that the issue is related to mediaType. If I change "mediaType": "application/vnd.cncf.helm.config.v1+json" to match the example you referenced, the JSON is accepted as valid. We have a few related issues (https://github.com/aws/aws-sdk/issues/193, https://github.com/boto/boto3/issues/3295), and they were able to bypass this issue using ImageManifestMediaType, rather than having it inside the manifest. In my testing, that workaround did not work for me. Assuming it doesn't work for you either, I can reach out to the service team for more information about the intended syntax for Helm charts here.

RyanFitzSimmonsAK avatar Apr 30 '24 20:04 RyanFitzSimmonsAK

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar May 10 '24 21:05 github-actions[bot]

Hi @RyanFitzSimmonsAK

Sorry for the late response. My issue is that it's not an image though it's a Helm Chart so the ImageManifestMediaType isn't applicable. If you could reach out to the team that would be great!

AndrewCharlesHay avatar Jun 10 '24 14:06 AndrewCharlesHay

Hi I have the same issue. In my case i want to apply the "latest" tag to my HELM chart on ECR

aws ecr put-image --repository-name XXXXXX --image-tag latest --image-manifest "$MANIFEST"

An error occurred (InvalidParameterException) when calling the PutImage operation: Invalid parameter at 'ImageManifest' failed to satisfy constraint: 'Invalid JSON syntax'

and my imageManifest was getting from

MANIFEST=$(aws ecr batch-get-image --repository-name XXXXX --image-ids imageTag="version-number" --output text --query 'images[].imageManifest')

the output of my MANIFEST is as below :

{
    "schemaVersion":2,
    "config":{
        "mediaType":"application/vnd.cncf.helm.config.v1+json",
        "digest":"sha256:91df0fe079fe78dasfdsafsadfsadfasdfafdasdfasf",
        "size":126
    },
    "layers":[{
        "mediaType":"application/vnd.cncf.helm.chart.content.v1.tar+gzip",
        "digest":"sha256:a3ead2ddsadfasdfsafaefsfdsfafafsafasasf",
        "size":11223
    }]
 }

thanks for your help and please keep this response open until you find the root cause. Same here it is for a HELM chart not a docker image

haofeif avatar Jun 22 '24 03:06 haofeif

Hey, before I reach out to the service team, could you take a look at https://docs.aws.amazon.com/AmazonECR/latest/userguide/push-oci-artifact.html, and let me know if this process works for you?

RyanFitzSimmonsAK avatar Jun 25 '24 20:06 RyanFitzSimmonsAK

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Jul 05 '24 20:07 github-actions[bot]

Hey, before I reach out to the service team, could you take a look at https://docs.aws.amazon.com/AmazonECR/latest/userguide/push-oci-artifact.html, and let me know if this process works for you?

the problem occurred when following the document as shown above. So it is still the issue @RyanFitzSimmonsAK

haofeif avatar Jul 10 '24 00:07 haofeif

can you pls help to reopen the ticket ?

haofeif avatar Jul 10 '24 00:07 haofeif

I've reached out to the service team, and will update you when I know more.

Ticket # for internal use : P140579689

RyanFitzSimmonsAK avatar Jul 11 '24 20:07 RyanFitzSimmonsAK

The service team confirmed the following :

The way to push a helm manifest is to not include the mediaType in the manifest and specify --image-manifest-media-type application/vnd.oci.image.manifest.v1+json in the put-image command. ECR only allows two values for the mediaType of the manifest application/vnd.oci.image.manifest.v1+json or application/vnd.docker.distribution.manifest.v2+json for manifest that is not an image index.

They also suggested looking into the Helm CLI for this use case.

Please let me know if this works for you or if you have any follow-up questions.

RyanFitzSimmonsAK avatar Jul 11 '24 21:07 RyanFitzSimmonsAK

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Jul 21 '24 22:07 github-actions[bot]