Skip to main content

awscurl Donate Donate Donate

PyPI Build Status Docker Hub

Edit with gitpod Edit with vscode Edit with github codespaces

curl-like tool with AWS Signature Version 4 request signing.

Features

  • performs requests to AWS services with request signing using curl interface
  • supports IAM profile credentials

Overview

Requests to AWS API must be signed (see Signing AWS API Requests) automates the process of signing and makes requests to AWS as simple as a standard curl command.

Installation

pip install awscurl

Installation from source (bleeding edge)

pip install git+https://github.com/okigan/awscurl

Installation via Homebrew for MacOS

brew install awscurl

Running via Docker

docker pull okigan/awscurl # or via docker pull ghcr.io/okigan/awscurl 

or via Github docker registry

docker pull ghcr.io/okigan/awscurl 

then

$ docker run --rm -it okigan/awscurl --access_key ACCESS_KEY  --secret_key SECRET_KEY --service s3 s3://...

# or allow access to local credentials as following
$ docker run --rm -it -v "$HOME/.aws:/root/.aws" okigan/awscurl --service s3 s3://...

To shorten the length of docker commands use the following alias:

alias awscurl='docker run --rm -ti -v "$HOME/.aws:/root/.aws" -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SECURITY_TOKEN -e AWS_PROFILE okigan/awscurl'

This will allow you to run awscurl from within a Docker container as if it was installed on the host system:

awscurl

Examples

  • Call S3: List bucket content

    $ awscurl --service s3 'https://awscurl-sample-bucket.s3.amazonaws.com' | tidy -xml -iq
    <?xml version="1.0" encoding="utf-8"?>
    <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
      <Name>awscurl-sample-bucket</Name>
      <Prefix></Prefix>
      <Marker></Marker>
      <MaxKeys>1000</MaxKeys>
      <IsTruncated>false</IsTruncated>
      <Contents>
        <Key>awscurl-sample-file.txt</Key>
        <LastModified>2017-07-25T21:27:38.000Z</LastModified>
        <ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
        <Size>0</Size>
        <StorageClass>STANDARD</StorageClass>
      </Contents>
    </ListBucketResult>
    
  • Call EC2:

    $ awscurl --service ec2 'https://ec2.amazonaws.com?Action=DescribeRegions&Version=2013-10-15' | tidy -xml -iq 
    <?xml version="1.0" encoding="utf-8"?>
    <DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
    
      <requestId>96511ccd-2d6d-4d63-ad9b-6be6f2c9874d</requestId>
      <regionInfo>
        <item>
          <regionName>eu-north-1</regionName>
          <regionEndpoint>ec2.eu-north-1.amazonaws.com</regionEndpoint>
        </item>
        <item>
          <regionName>ap-south-1</regionName>
          <regionEndpoint>ec2.ap-south-1.amazonaws.com</regionEndpoint>
        </item>
      </regionInfo>
    </DescribeRegionsResponse>
    
  • Call API Gateway:

    $ awscurl --service execute-api -X POST -d @request.json \
      https://<prefix>.execute-api.us-east-1.amazonaws.com/<resource>
    

Options

usage: __main__.py [-h] [-v] [-i] [-X REQUEST] [-d DATA] [-H HEADER] [-k] [--fail-with-body] [--data-binary] [--region REGION] [--profile PROFILE] [--service SERVICE]
                   [--access_key ACCESS_KEY] [--secret_key SECRET_KEY] [--security_token SECURITY_TOKEN] [--session_token SESSION_TOKEN] [-L] [-o <file>]
                   uri

Curl AWS request signing

positional arguments:
  uri

options:
  -h, --help            show this help message and exit
  -v, --verbose         verbose flag (default: False)
  -i, --include         include headers in the output (default: False)
  -X REQUEST, --request REQUEST
                        Specify request command to use (default: GET)
  -d DATA, --data DATA  HTTP POST data (default: )
  -H HEADER, --header HEADER
                        HTTP header (default: None)
  -k, --insecure        Allow insecure server connections when using SSL (default: False)
  --fail-with-body      Fail on HTTP errors but save the body (default: False)
  --data-binary         Process HTTP POST data exactly as specified with no extra processing whatsoever. (default: False)
  --region REGION       AWS region [env var: AWS_DEFAULT_REGION] (default: us-east-1)
  --profile PROFILE     AWS profile [env var: AWS_PROFILE] (default: default)
  --service SERVICE     AWS service (default: execute-api)
  --access_key ACCESS_KEY
                        [env var: AWS_ACCESS_KEY_ID] (default: None)
  --secret_key SECRET_KEY
                        [env var: AWS_SECRET_ACCESS_KEY] (default: None)
  --security_token SECURITY_TOKEN
                        [env var: AWS_SECURITY_TOKEN] (default: None)
  --session_token SESSION_TOKEN
                        [env var: AWS_SESSION_TOKEN] (default: None)
  -L, --location        Follow redirects (default: False)
  -o <file>, --output <file>
                        Write to file instead of stdout (default: )

 In general, command-line values override environment variables which override defaults.

If you do not specify the --access_key or --secret_key (or environment variables), awscurl will attempt to use the credentials you set in ~/.aws/credentials. If you do not specify a --profile or AWS_PROFILE, awscurl uses default.

Who uses awscurl

Star History

Star History Chart

Related projects

Last but not least

Metadata

Release files for awscurl 0.44

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awscurl 0.44
File Size Uploaded
awscurl-0.44.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awscurl 0.44
File Interpreter ABI Platform
awscurl-0.44-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / awscurl-0.44.tar.gz

Download URL awscurl-0.44.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
13056e867ac33f556f29d3662102bfc3c40259ea037c6d817c5914dbb2bbd948
BLAKE2b-256 checksum
How to use checksums
c8777da6af880d56aed4a4023bb7c725e15c72a3088afd729ffd373eed0f5a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / awscurl-0.44-py3-none-any.whl

Download URL awscurl-0.44-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c4980aac5fef28f2dec56b81900d7cda065fe7491a2bb4215e05e740b5fab6b
BLAKE2b-256 checksum
How to use checksums
71a5cb59ec794afd7b2ab462504f4076e2f926fdd1e4b5df2689f7d5f3732a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.44 This release

2 release files

0.43

2 release files

0.42

2 release files

0.41

2 release files

0.40

2 release files

0.39

2 release files

0.38

2 release files

0.37

2 release files

0.36

2 release files

0.35

2 release files

0.34

2 release files

0.33

2 release files

0.32

2 release files

0.31

2 release files

0.30

2 release files

0.29

2 release files

0.28

2 release files

0.27

2 release files

0.26

2 release files

0.24

2 release files

0.23

2 release files

0.22

2 release files

0.21

2 release files

0.20

2 release files

0.19

2 release files

0.18

3 release files

0.17

1 release file

0.16

1 release file

0.15

1 release file

0.14

1 release file

0.13

1 release file

0.12

1 release file

0.11

1 release file

0.10

1 release file

0.9

1 release file

0.8

2 release files

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page