Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get it to use my existing DynamoDB table #265

Open
matthewkogan opened this issue Sep 11, 2024 · 0 comments
Open

Can't get it to use my existing DynamoDB table #265

matthewkogan opened this issue Sep 11, 2024 · 0 comments

Comments

@matthewkogan
Copy link

I can't seem to get Flask-Session to use my existing DynamoDB table. It works fine locally, but not once deployed to AWS.

Here's my setup code:

endpoint_url = 'http://localhost:8000' if not os.getenv('BUILD_ENV') else None
dynamodb_resource = boto3.resource(
    'dynamodb',
    region_name='eu-west-1',
    endpoint_url=endpoint_url
)

app.config.update(
    {
        "SESSION_TYPE": "dynamodb",
	"SESSION_DYNAMODB": dynamodb_resource,
	"SESSION_DYNAMODB_TABLE": "my-sessions"
    }
)

Session(app)

I can see that it's just trying to create a new table instead of using the one I've already set up for it:
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the CreateTable operation: User: arn:aws:sts::[redacted]:assumed-role/my-task-role/[redacted] is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:eu-west-1:[redacted]:table/my-sessions because no identity-based policy allows the dynamodb:CreateTable action

I have checked that all the role my app is running with has all the necessary permissions on the table.

I can see that there is code committed since 0.8.0 was released that adds a SESSION_DYNAMODB_TABLE_EXISTS parameter. Is this what I need? If so, when is there likely to be a new release that includes this? Or is there another solution?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant