Can we have jq installed by default in aws v2 cli docker image?
Problem
Is your feature request related to a problem? Please describe. We commonly use jq to manipulate json as input or pick properties from aws command output in shell script. It will be really good if we can include jq in official docker image of v2 like what Azure cli does. Describe the solution you'd like include jq program in aws v2 docker image Describe alternatives you've considered We currently build our own custom image for v1 to have jq installed. Additional context
Unverified for your environment
Select your OS to check compatibility.
2 Fixes
Include jq in AWS CLI v2 Docker Image
The official AWS CLI v2 Docker image does not include jq, which is a lightweight and flexible command-line JSON processor. This omission limits users' ability to manipulate JSON output directly within the container, leading to the need for custom images or additional processing steps.
Awaiting Verification
Be the first to verify this fix
- 1
Modify Dockerfile for AWS CLI v2
Update the Dockerfile used to build the AWS CLI v2 image to include the installation of jq. This can be achieved by adding a command to install jq using the package manager available in the base image.
bashRUN apt-get update && apt-get install -y jq - 2
Build the Updated Docker Image
After modifying the Dockerfile, build the Docker image to ensure jq is included. Use the Docker build command to create a new image with the updated configuration.
bashdocker build -t aws-cli-v2-with-jq . - 3
Test the New Docker Image
Run a container from the newly built image and test if jq is available. Execute a simple jq command to verify its functionality.
bashdocker run --rm aws-cli-v2-with-jq jq --version - 4
Push the Updated Image to Repository
Once verified, push the updated Docker image to a container registry (e.g., Docker Hub or AWS ECR) for easy access and deployment.
bashdocker push your-repo/aws-cli-v2-with-jq - 5
Document the Changes
Update any relevant documentation to inform users of the new image and how to use jq with the AWS CLI v2 Docker container.
bashecho 'AWS CLI v2 with jq is now available at your-repo/aws-cli-v2-with-jq'
Validation
To confirm the fix worked, run the new Docker image and execute 'jq --version' to check if jq is installed. Additionally, test a sample AWS CLI command piped to jq to ensure it processes JSON output correctly.
Sign in to verify this fix
1 low-confidence fix
Include jq in AWS CLI v2 Docker Image
The AWS CLI v2 Docker image does not include jq by default, limiting users' ability to manipulate JSON output directly within the container. This is a common requirement for users who need to process AWS command outputs efficiently in shell scripts.
Awaiting Verification
Be the first to verify this fix
- 1
Modify Dockerfile for AWS CLI v2
Edit the Dockerfile used to build the AWS CLI v2 image to include the installation of jq. This will ensure that jq is available in the image by default.
bashRUN apt-get update && apt-get install -y jq - 2
Rebuild the Docker Image
After modifying the Dockerfile, rebuild the Docker image to apply the changes. This will create a new version of the AWS CLI v2 image that includes jq.
bashdocker build -t aws-cli-v2-custom . - 3
Test the New Image
Run a container using the newly built image and test if jq is installed correctly by executing 'jq --version'. This will confirm that jq is available for use.
bashdocker run --rm aws-cli-v2-custom jq --version - 4
Push the Custom Image to Repository
If the tests are successful, push the custom Docker image to a container registry (e.g., Docker Hub or AWS ECR) for easier access and deployment.
bashdocker push your-repo/aws-cli-v2-custom - 5
Update Documentation
Update any relevant documentation to inform users about the availability of jq in the new AWS CLI v2 Docker image and how to use it.
N/AN/A
Validation
To confirm the fix worked, run a container from the new AWS CLI v2 image and execute a command that uses jq to process JSON output, such as 'aws ec2 describe-instances | jq .'. If jq processes the output correctly, the installation is successful.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep