Comments (7)
pip install --upgrade --no-cache awscli-local
Thanks alot ,I got resolved my issue by using the above querry.
Thanks@david93111
from awscli-local.
I noticed that aws
also installs a .cmd file. This is just a batch file that subsequently runs the awslocal script.
The install for awslocal
should also install such a file.
from awscli-local.
Workaround @fullstack74
Create a .cmd file with the following contents:
REM env_dict['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', '_not_needed_locally_')
REM env_dict['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', '_not_needed_locally_')
SET AWS_ACCESS_KEY_ID=_not_needed_locally_
SET AWS_SECRET_ACCESS_KEY=_not_needed_locally_
aws.cmd %*
from awscli-local.
Thanks for reporting @fullstack74 @gregsdennis .
The install for awslocal should also install such a file.
Would any of you be able to provide such a .cmd
file? Thanks!
from awscli-local.
Same error for Windows 10, definitely should add this cmd creation for Python.
Thanks a lot, @gregsdennis , for pointing out the aws.cmd file, that solve part of the issue but not every variable is accounted in your script so you have to configure your AWS CLI for default region and other stuff.
What i did was look what the AWS command line was doing, basicaly they have all the logic in an clidriver inside the site-packages that the aws for linux file and the aws.cmd share.
So, based on how awscli original script files do things, I create a new file that uses the same code for telling windows to execute the python code as a script and have to add to subprocess.Popen the shell=true flag in order to make it work when no arguments are given (the aws normal cli script manages the command missing part) and my awslocal.cmd file repeat all the logic in the original file , for me it's working properly (on Window 10, but should also work for 7) and basically the whole file looks like:
@echo OFF
REM="""
setlocal
set PythonExe=""
set PythonExeFlags=
for %%i in (cmd bat exe) do (
for %%j in (python.%%i) do (
call :SetPythonExe "%%~$PATH:j"
)
)
for /f "tokens=2 delims==" %%i in ('assoc .py') do (
for /f "tokens=2 delims==" %%j in ('ftype %%i') do (
for /f "tokens=1" %%k in ("%%j") do (
call :SetPythonExe %%k
)
)
)
%PythonExe% -x %PythonExeFlags% "%~f0" %*
exit /B %ERRORLEVEL%
goto :EOF
:SetPythonExe
if not ["%~1"]==[""] (
if [%PythonExe%]==[""] (
set PythonExe="%~1"
)
)
goto :EOF
"""
# ===================================================
# Python script starts here
# ===================================================
import os
import sys
import subprocess
import six
from threading import Thread
PARENT_FOLDER = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
if os.path.isdir(os.path.join(PARENT_FOLDER, '.venv')):
sys.path.insert(0, PARENT_FOLDER)
from localstack_client import config
def get_service():
for param in sys.argv[1:]:
if not param.startswith('-'):
return param
def get_service_endpoint():
service = get_service()
if service == 's3api':
service = 's3'
return config.get_service_endpoints().get(service)
def usage():
print(__doc__.strip())
def to_str(s):
if six.PY3 and not isinstance(s, six.string_types):
s = s.decode('utf-8')
return s
def run(cmd, env={}):
def output_reader(pipe, out):
with pipe:
for line in iter(pipe.readline, b''):
line = to_str(line)
out.write(line)
out.flush()
process = subprocess.Popen(cmd, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env, shell=True)
Thread(target=output_reader, args=[process.stdout, sys.stdout]).start()
Thread(target=output_reader, args=[process.stderr, sys.stderr]).start()
process.wait()
sys.exit(process.returncode)
def main():
if len(sys.argv) > 1 and sys.argv[1] == '-h':
return usage()
# get service and endpoint
endpoint = get_service_endpoint()
service = get_service()
if not endpoint and service:
print('ERROR: Unable to find LocalStack endpoint for service "%s"' % service)
return sys.exit(1)
# prepare cmd args
cmd_args = list(sys.argv)
cmd_args[0] = 'aws'
if endpoint:
cmd_args.insert(1, '--endpoint-url=%s' % endpoint)
if 'https' in endpoint:
cmd_args.insert(2, '--no-verify-ssl')
# prepare env vars
env_dict = os.environ.copy()
env_dict['PYTHONWARNINGS'] = 'ignore:Unverified HTTPS request'
env_dict['AWS_DEFAULT_REGION'] = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
env_dict['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', '_not_needed_locally_')
env_dict['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', '_not_needed_locally_')
# run the command
run(cmd_args, env_dict)
if __name__ == '__main__':
sys.exit(main())
@whummer i don't know if this is the best soultion, or there are others better, i'm not a python expert , but if you think this can work easily you can centralize the logic of this script in other file that both your linux command file and this cmd file share when executed and should work very similar to the original awscli script.
from awscli-local.
@david93111 thanks for putting that together. My script was obviously suited to my direct needs, and just to get it working.
from awscli-local.
Thanks for reporting @gregsdennis @david93111 . This should be fixed in 8878701 . Can you please give it a try with the latest version 0.5
of the pip package (pip install --upgrade --no-cache awscli-local
)? Please report here if the problem persists. Thanks
from awscli-local.
Related Issues (20)
- Please allow us to change the localstack port HOT 1
- s3api not automatic wrap localstack endpoint HOT 2
- Please pass HOME env variable. HOT 3
- awslocal vs aws HOT 3
- Deploying OpenSearch doesn't create `/_dashboards/`? HOT 3
- [Deleted]
- Cannot get a live stream of logs using awslocal logs tail --follow HOT 1
- Error when using 'awslocal configure list' HOT 5
- awslocal with LOCALSTACK_HOST - Invalid endpoint HOT 4
- awslocal fails with the instance name HOT 1
- [bug]: Can't add url config for lambda in local stack using aws-sdk
- awscli-local doesn't read a default region from ~/.aws/config HOT 2
- Awslocal cli: Exception while calling ecs.CreateCluster: 'EcrStore' object has no attribute 'clusters' HOT 1
- When using the environment variable EDGE_PORT it is still using the default port of 4566 to connect HOT 4
- Not using pager. HOT 2
- Add support for installing with Homebrew HOT 1
- `AWS_ENDPOINT_URL` overrides the endpoint URL of aws command HOT 3
- Why not use this? alias awslocal='aws --endpoint-url=http://localhost:4566' HOT 1
- delete-secret --force-delete-without recovery doesn't work HOT 1
- segfault caused by os.execvpe in windows HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awscli-local.