Skip to content

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

@matthewkogan

Description

@matthewkogan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions