Comments (11)
it seems that it is related to dynamodb_tables that i misconfigured
from slam.
i have this database model using PynamoDB:
class UserEmailViewIndex(GlobalSecondaryIndex):
class Meta:
index_name = "email_view_index"
read_capacity_units = 1
write_capacity_units = 1
projection = AllProjection()
email = UnicodeAttribute(hash_key=True)
class User(Model):
class Meta:
table_name = os.environ.get('STAGE') + '.Users'
region = boto3.Session().region_name
host = 'http://localhost:8000' \
if not os.environ.get('LAMBDA_TASK_ROOT') else None
id = UnicodeAttribute(hash_key=True)
first_name = UnicodeAttribute()
last_name = UnicodeAttribute()
email = UnicodeAttribute()
password = UnicodeAttribute()
address = MapAttribute()
gender = UnicodeAttribute()
mobile_number = UnicodeAttribute()
birthday = UnicodeAttribute()
accepted_terms = MapAttribute()
email_view_index = UserEmailViewIndex()
date_created = UTCDateTimeAttribute()
date_updated = UTCDateTimeAttribute()
last_login = UTCDateTimeAttribute()
class PurchaseUserViewIndex(GlobalSecondaryIndex):
class Meta:
index_name = "user_view_index"
read_capacity_units = 1
write_capacity_units = 1
projection = AllProjection()
user_id = UnicodeAttribute(hash_key=True)
class Purchase(Model):
class Meta:
table_name = os.environ.get('STAGE') +'.Purchases'
region = boto3.Session().region_name
host = 'http://localhost:8000' \
if not os.environ.get('LAMBDA_TASK_ROOT') else None
id = UnicodeAttribute(hash_key=True)
user_id = UnicodeAttribute()
amount = NumberAttribute()
store_name = UnicodeAttribute()
card_number = UnicodeAttribute()
transaction_date = UnicodeAttribute()
transaction_type = UnicodeAttribute()
num_of_entries = NumberAttribute(default=0)
campaign = MapAttribute()
user_view_index = PurchaseUserViewIndex()
date_created = UTCDateTimeAttribute()
and i have this in slam.yaml
file:
dynamodb_tables:
Purchases:
attributes:
id: "S"
user_id: "S"
key: "id"
read_throughput: 1
write_throughput: 1
global_secondary_indexes:
user_view_index:
key: ["user_id"]
project: "all"
read_throughput: 1
write_throughput: 1
Users:
attributes:
id: "S"
email: "S"
key: "id"
read_throughput: 1
write_throughput: 1
global_secondary_indexes:
email_view_index:
key: ["email"]
project: "all"
read_throughput: 1
write_throughput: 1
and i have this error in AWS CloudFormation: Value of property GlobalSecondaryIndexes must be of type List
can you check if my config is correct? thanks
from slam.
@kuronaru This was a bug on my side. Please upgrade slam to latest release and retry.
from slam.
still no luck, i can't deploy my project because of the dynamo_table config in yaml
from slam.
i think there's something wrong with the projection.
i checked the template generated by slam template
and the
"Projection": { "ProjectionType": "KEYS_ONLY" },
from slam.
I will run a complete example later when I have a bit of time. Do you know what is the error with the projection portion of the cloudformation template?
from slam.
i was able to deploy now after re-updating all the libraries in requirements.txt and i checked the template again and the ProjectionType
is still set as KEYS_ONLY
though i set it as all
i checked the logs by slam logs --tail
$ slam logs --tail
May 24 13:48:50 START RequestId: a7cf6548-4044-11e7-9534-17871a9c07ee Version: $LATEST
May 24 13:48:58 Failed to query items: An error occurred (AccessDeniedException) on request (PN8ILQLJ53EEIS2BQ9TNIBDKJNVV4KQNSO5AEMVJF66Q9ASUAAJG) on table (dev.Users) when calling the Query operation: : QueryError
is the template generating the policies right or i need to configure in the AWS console for this?
i also noticed that in API Gateway Resources at AWS Console it looks like the screenshot unlike using serverless:
is it normal to look like that?
please bear with me
from slam.
The project problem ended up being another bug. The documentation indicated you should use project
, but in the code, I was using projection
. I updated the code to match the documentation.
The API Gateway configuration is correct. I plan to eventually add support for authorization at the gateway level, but at this point, authorization can only be provided in the WSGI application.
from slam.
thanks for the response.
any idea what causes the QueryError like what in the slam logs
?
from slam.
@kuronaru is that line in the log generated by your application? I'm not familiar with that log format. In any case, there is an AccessDeniedException
. It would be useful if you let that exception bubble up, so that the log will show a complete error message and a stack trace.
from slam.
I had the same issue, and it turned out to be a issue with the yml file. In the following section you need to add;
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:DescribeTable
Resource:
- "arn:aws:dynamodb:{YOUR-TABLE}/index/*"
In summary, you need to add specific permissions to the index to be able to query the GSI.
from slam.
Related Issues (16)
- What is between it and the Docker difference HOT 2
- Getting an exit code 100: virtualenv error on build HOT 1
- Issues with zip file missing dependencies HOT 4
- flask module missing? HOT 8
- AWS Credentials HOT 2
- I'm getting InvalidBucketName when running under an aws account with restricted permissions HOT 3
- 'async' (and 'invoke') are now Python keywords. HOT 2
- S3 Bucket naming conventions have changed HOT 1
- expose lambda version as an environment variable
- Add cli option to specify the name of the yaml config file to use
- separate the deploy and publish options into separate commands
- Users Forum? HOT 5
- the dynamodb permissions on the lambda are too wide
- Enhancements HOT 4
- Failing to deploy HOT 50
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 slam.