Getting permissions exception when calling amazondax service - aws-lambda

I'm using the amazondax service from an AWS Lambda method, and getting an exception that indicates missing permissions - but I don't know what permissions are necessary for this. Both the Lambda method and my DAX cluster are setup with the same VPC subnets and security groups. I'm getting the following exception:
[ERROR] 2018-12-11T23:06:50.457Z 70c80374-fd99-11e8-bac1-318371e7b8ed Failed to retrieve endpoints
Traceback (most recent call last):
File "/var/task/amazondax/Cluster.py", line 211, in _pull
new_endpoints = self._pull_from(ip, port)
File "/var/task/amazondax/Cluster.py", line 222, in _pull_from
endpoints = client.endpoints()
File "/var/task/amazondax/DaxClient.py", line 192, in endpoints
return self._decode_result('endpoints', None, Assemblers.endpoints_455855874_1, tube)
File "/var/task/amazondax/DaxClient.py", line 227, in _decode_result
return self._handle_error(operation_name, tube)
File "/var/task/amazondax/DaxClient.py", line 233, in _handle_error
raise DaxServiceError(operation_name, message, codes, *exc_info)
amazondax.DaxError.DaxServiceError: An error occurred (Unknown) when calling the endpoints operation: Client does not have permission to invoke Endpoints
I assume the last line "Client does not have permission..." is the key to this, but I'm having trouble figuring out exactly what permission(s) are required.
Here is the code that is breaking:
dax = amazondax.AmazonDaxClient(session, region_name='us-east-1', endpoint_url='mydaxcluster.blahblahblah.cache.amazonaws.com:8111')

You will need to add "dax:" permissions for the operations you need to the policy associated with the IAM user used in the session.

Related

Google People API: reading "other contacts" with addresses

I need to read addresses of "other contacts". Docs say that in order to do this, READ_SOURCE_TYPE_PROFILE should be set. However, when doing it like this:
service = googleapiclient.discovery.build('people', 'v1', credentials=credentials)
resource = service.otherContacts()
request = resource.list(
readMask='names,emailAddresses,phoneNumbers,addresses',
sources='READ_SOURCE_TYPE_PROFILE',
pageSize=1000
)
request.execute()
... I am getting the following error: Must request READ_SOURCE_TYPE_CONTACT. Full traceback:
Traceback (most recent call last):
File "C:\Users\Leo\workspace\gapitest\main.py", line 22, in <module>
response = request.execute()
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\http.py", line 937, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://people.googleapis.com/v1/otherContacts?readMask=names%2CemailAddresses%2CphoneNumbers&sources=READ_SOURCE_TYPE_PROFILE&pageSize=1000&alt=json returned "Must request READ_SOURCE_TYPE_CONTACT". Details: "Must request READ_SOURCE_TYPE_CONTACT">
What am I doing wrong?
It seems that what you are seeing might be a bug.
I have filed this issue on Issue Tracker here so feel free to star it and eventually add a comment, as any updates shall be posted there.
According to Google's documentation:
Specifying READ_SOURCE_TYPE_PROFILE without specifying READ_SOURCE_TYPE_CONTACT is not permitted.
Setting both READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE should resolve this issue.

ERROR: for mysql a bytes-like object is required, not 'str' using docker-compose and laravel sail

I’ve rebooted my system and then run all my containers using the vendor/bin/sail up command, the only one that failed to reload was MySQL. The error is the following :
ERROR: for mysql a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 261, in _raise_for_status
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.25/containers/afdd1cbf7f45d9b20612bca
f73eef1b0bc1dd631bc6aa3dcfbf630c64e8a3662/start
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/compose/service.py", line 625, in start_container
container.start()
File "/usr/lib/python3/dist-packages/compose/container.py", line 241, in start
return self.client.start(self.id, **options)
File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/lib/python3/dist-packages/docker/api/container.py", line 1095, in start
self._raise_for_status(res)
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/usr/lib/python3/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'Ports are not available: listen tcp 0.0.0.0:3306: bind: An attempt was made
to access a socket in a way forbidden by its access permissions.'")
I’m running this container on ubuntu server 20.04.
It might fix the problem if you provide an absolute path to your nginx/mysql conf file. I haven't tried the solution yet.

graphlab create: unable to start cluster in aws

At the moment I'm trying to create a cluster in aws ec2 with Graphlab Create. The code is as follows:
import graphlab as gl
ec2config = gl.deploy.Ec2Config(region='us-west-2', instance_type='m3.large',
aws_access_key_id='secret-acces-key-id',
aws_secret_access_key='secret-access-key')
ec2 = gl.deploy.ec2_cluster.create(name='Test Cluster',
s3_path='s3://test-big-data-2016', ec2_config=ec2config, idle_shutdown_timeout=3600, num_hosts=1)
When the above code is executed I get the following error:
Traceback (most recent call last):
File "test.py", line 59, in
ec2 = gl.deploy.ec2_cluster.create(name='Test Cluster', s3_path='s3://test-big-data-2016', ec2_config=ec2config, idle_shutdown_timeout=36000, num_hosts=1)
File "/Users/remco/anaconda/envs/gl-env/lib/python2.7/site-packages/graphlab/deploy/ec2_cluster.py", line 83, in create
cluster.start()
File "/Users/remco/anaconda/envs/gl-env/lib/python2.7/site-packages/graphlab/deploy/ec2_cluster.py", line 233, in start
self.idle_shutdown_timeout
File "/Users/remco/anaconda/envs/gl-env/lib/python2.7/site-packages/graphlab/deploy/_executionenvironment.py", line 372, in _start_commander_host
raise RuntimeError('Unable to start host(s). Please terminate '
RuntimeError: Unable to start host(s). Please terminate manually from the AWS console.
When I look in EC2 Management Console a new instance is launched and running. But still getting the error in the terminal.
I really don't know what I'm doing wrong here. I followed the exact instructions from: https://turi.com/learn/userguide/deployment/pipeline-example.html

Forbidden Error on get_thing_shadow with boto3, aws iot and alexa

I am running a custom alexa skill with flask-ask that connects to aws iot.
Using same credentials work when running the script on local machine and using ngrok to assign to Alexa skill endpoint. But when I use zappa to upload as lambda, I get the following:
File "/var/task/main.py", line 48, in get_shadow
res=client.get_thing_shadow(thingName="test_light")
File "/var/runtime/botocore/client.py", line 253, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 543, in _make_api_call
raise error_class(parsed_response, operation_name)
ClientError: An error occurred (ForbiddenException) when calling the GetThingShadow operation: Forbidden
When using ngrok, the skill works completely fine. What am I missing here? Help!
The problem was VPC access. I had to provide the role the VPC access policy and it worked.

Django on IIS with Multiple Sites: How To Make ISAPI.py Cooperate

Python 2.6.2 / Django 1.0.2 on Win 2003 Standard IIS 6.
IIs is running two django sites with the following directory structure:
root/http/WEBSITE1
root/http/WEBSITE2
Both sites have their own application pools; each site has it's own pyISAPIe.dll instance.
WEBSITE1 is accessible (serving test django page). However, the browser produces the following for WEBSITE2:
Internal Server Error
An error occurred processing this request.
Request handler failed
Traceback (most recent call last):
File "D:\Python26\lib\site-packages\Http\Isapi.py", line 67, in Request
return RunWSGI(Handler, Base=Base)
File "D:\Python26\lib\site-packages\Http\WSGI.py", line 155, in RunWSGI
Result = Application(Environ, StartResponse)
File "D:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in call
response = self.get_response(request)
File "D:\Python26\lib\site-packages\django\core\handlers\base.py", line 122, in get_response
return self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "D:\Python26\lib\site-packages\django\core\handlers\base.py", line 166, in handle_uncaught_exception
return callback(request, **param_dict)
File "D:\Python26\lib\site-packages\django\views\defaults.py", line 23, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "D:\Python26\lib\site-packages\django\template\loader.py", line 81, in get_template
source, origin = find_template_source(template_name)
File "D:\Python26\lib\site-packages\django\template\loader.py", line 74, in find_template_source
raise TemplateDoesNotExist, name
django.template.TemplateDoesNotExist: 500.html
It seems to me that "Isapi.py" located in root/pytho26/Lib/site-packages/Http has everything to do with this because of the "os.environ["DJANGO_SETTINGS_MODULE"] = "WEBSITE1.settings"
How can I modify this file or position it so that both sites run independently.
For anyone interested, the solution lies here
http://groups.google.com/group/pyisapie/browse_thread/thread/b67e861c85e1b26a
Follow option #3 to the letter and you will be able to run multiple IIS sites.

Resources