<@ULVA73B9P> if I deploy my flow with push=True, a...
# ask-marvin
m
@Marvin if I deploy my flow with push=True, a docker image is created and pushed wherever I specified. In my case I push it to an AWS ECR repository. Is it possible to delete this image with prefect, maybe when I delete the deployment? And another question: can I delete a deployment via prefect cli/ API ?
m
Regarding your first question about deleting a docker image that was pushed to an AWS ECR repository when you delete the deployment, it seems that there's not an automated way to accomplish this directly with Prefect. The process of building and pushing the docker image as part of the deployment is mentioned in the Prefect documentation, but it doesn't cover the deletion of the image from the registry. You may have to delete the image manually from AWS ECR or create a separate automated process for this purpose. As for your second question on deleting a deployment via Prefect CLI or API, you can use the Prefect CLI to create a deployment which implicitly indicates that deletion might also be possible via the CLI or API. However, the specific command or API call to delete a deployment isn't directly provided in the documentation excerpts or the GitHub issues search results. For precise details on deleting deployments through the CLI or API, I would suggest checking the latest Prefect documentation regarding deployment management or examining the Prefect CLI help by running
prefect deployment --help
to see if a delete command is available. If you want more detailed instructions on deleting a Prefect deployment or docker images, or if you have any other questions, please let me know, and I can search for more specific information.
n
as for deleting deployments you can do
+1 to marvins answer on the delete image from registry bit
m
Thank you, I will now use the following command in my github action to delete the created images before I am allowed to delete the other infrastructure like ecr repo with pulumi: 👍
Copy code
aws ecr batch-delete-image \
        --repository-name ${{ github.event.inputs.ecr-repo-name }} \
        --image-ids "$(aws ecr list-images --repository-name ${{ github.event.inputs.ecr-repo-name }} \
        --query 'imageIds[*]' --output json )" || true