Skip to content

How to specify a JSON file path correctly in AWS CLI on Windows?

0

CLI JSON Path How to specify a JSON file path correctly in AWS CLI on Windows? I wrote --cli-input-json C:\path\to\file.json but get “file not found.” Do I need quotes or escape characters? What’s the proper syntax for Windows?

1 Answer
1
Accepted Answer

When referencing a JSON file in AWS CLI on Windows, you need to use the file:// prefix before the file path. Here are the correct ways to specify a JSON file path:

  1. Using forward slashes:
--cli-input-json file://C:/path/to/file.json
  1. Using escaped backslashes:
--cli-input-json file://C:\\path\\to\\file.json
  1. If your path contains spaces, enclose the entire path in quotes:
--cli-input-json "file://C:/path/to/my file.json"

The most common issues when specifying file paths in Windows are:

  • Missing the file:// prefix
  • Using unescaped backslashes
  • Having spaces between file:// and the beginning of the path

For simplicity, you can also navigate to the directory containing your JSON file using the cd command, and then use a relative path:

--cli-input-json file://file.json

Remember that the path should follow Windows conventions (backslashes), but you need to either escape them or use forward slashes when specifying them in the AWS CLI.
Sources
In AWS CLI, how do I reference a path to a JSON file that is stored on my PC's local drive? | AWS re:Post
Update AMI image pipelines from the AWS CLI - EC2 Image Builder
Walkthrough: Use the AWS CLI with Run Command - AWS Systems Manager
Create a container image pipeline from the AWS CLI - EC2 Image Builder

answered 9 months ago
EXPERT
reviewed 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.