awscli-plugin-execute-api
Plugin to configure a single AWS CLI operation to invoke an API Gateway / Lambda method
Quick Start
Install with pip
$ pip install awscli-plugin-execute-api
If you installed awscli with Homebrew, use its bundled Python:
$ /usr/local/opt/awscli/libexec/bin/pip install awscli-plugin-execute-api
Register the plugin
$ aws configure set plugins.execute-api awscli_plugin_execute_api
Configure an operation endpoint
First configure a profile for the IAM with execute-api:Invoke permission:
$ export AWS_PROFILE=myprofile
$ aws configure
AWS Access Key ID [None]: AKIA...
AWS Secret Access Key [None]: pWim...
Default region name [None]: us-east-1
Default output format [None]: json
Next configure the plugin for an operation and its API Gateway invocation URL:
$ aws configure set dynamodb.update-table https://m303r7o808.execute-api.us-east-1.amazonaws.com/Prod/update-table
You can review or manually configure `$HOME/.aws/config`...
[plugins]
execute-api = awscli_plugin_execute_api
[profile myprofile]
region = us-east-1
output = json
dynamodb =
update-table = https://m303r7o808.execute-api.us-east-1.amazonaws.com/Prod/update-table
Run an operation
Now run a command:
$ aws dynamodb update-table --table-name $TABLE_NAME --sse-specification Enabled=false
An error occurred (ValidationException) when calling the UpdateTable operation: Custom error from Lambda handler
You can use the `--debug` flag to verify the endpoint...
$ aws dynamodb update-table --debug --table-name $TABLE_NAME
Plugin awscli_plugin_execute_api: Config [myprofile] dynamodb.update-table => URL https://m303r7o808.execute-api.us-east-1.amazonaws.com/Prod/update-table
Plugin awscli_plugin_execute_api: renamed X-Amz-Target DynamoDB_20120810.UpdateTable
$ aws dynamodb describe-table --debug --table-name $TABLE_NAME
Plugin awscli_plugin_execute_api: Config [myprofile] dynamodb.describe-table not found
Motivation
For security reasons we'd like to give an IAM user access to a limited subset of an AWS API call functionality. For example on the dynamodb update-table operation we'd like to allow a user to modify:
- Global indexes
But disallow them to modify:
- Provisioned throughput
- Streams
- Server side encryption
A "serverless" solution includes:
-
IAM User
- Policy that disallows
dynamodb:UpdateTable - Policy that allows
execute-api:Invokeon an API Gateway resource - Access keys
- Policy that disallows
-
API Gateway Method
- URL to POST an
update-tablerequest - AWS_IAM authorization
- URL to POST an
-
Lambda Function
- Policy that allows
dynamodb:UpdateTable - Code that validates and performs
update-tablerequest
- Policy that allows
-
AWS CLI
- Custom endpoint URL for
dynamodb update-tablecommand - Request signature for API Gateway
- Custom endpoint URL for
This plugin registers a URL for a single CLI operation and automatically uses it.
$ aws configure set dynamodb.update-table https://m303r7o808.execute-api.us-east-1.amazonaws.com/Prod/update-table
$ aws dynamodb update-table --table-name $TABLE_NAME --sse-specification Enabled=false
An error occurred (ValidationException) when calling the UpdateTable operation: Modifying SSESpecification is not allowed
Troubleshooting
IAM
The CLI user needs API execution permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"arn:aws:execute-api:us-east-1:303718836660:m303r7o808/*/POST/update-table"
]
}
]
}
Lambda
The CLI operation is in the X-Target header, since X-Amz-Target
Credits
Metadata
Release files for awscli-plugin-execute-api 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| awscli_plugin_execute_api-0.2.1.tar.gz | 3.5 kB | Without provenance | Details for awscli_plugin_execute_api-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| awscli_plugin_execute_api-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for awscli_plugin_execute_api-0.2.1-py3-none-any.whl |
Total release size: 11.7 kB
Release files / awscli_plugin_execute_api-0.2.1.tar.gz
| Download URL | awscli_plugin_execute_api-0.2.1.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f33033e5d868238a109d0cc937043260377e8d9f54372999bafa0145d75203f
|
|
BLAKE2b-256 checksum How to use checksums |
609b77c3f6c88e1f55e3970e20846e0f4d1fc08431bda7087f3e69ff3ee38271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Release files / awscli_plugin_execute_api-0.2.1-py3-none-any.whl
| Download URL | awscli_plugin_execute_api-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
407f6e7e6757e4c84802da99cda31d972a6dc31c163155bc1f90f90feec7fc0a
|
|
BLAKE2b-256 checksum How to use checksums |
9961691008ad790062bf0624c96e11823b6e0d40d773d60c295b09612f5b2ab9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for awscli-plugin-execute-api 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.