aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.11k stars 4.02k forks source link

Ambiguous JSON object required for `ecr put-image` #8620

Open AndrewCharlesHay opened 3 months ago

AndrewCharlesHay commented 3 months ago

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

RyanFitzSimmonsAK commented 2 months ago

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.

github-actions[bot] commented 1 month ago

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.

AndrewCharlesHay commented 4 weeks ago

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!

haofeif commented 2 weeks ago

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

RyanFitzSimmonsAK commented 1 week ago

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?

github-actions[bot] commented 3 days ago

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.