package dynamo

import "github.com/gravitational/teleport/lib/backend/dynamo"

Package dynamodbDynamoDBBackend implements DynamoDB storage backend for Teleport auth service, similar to etcd backend.

dynamo package implements the DynamoDB storage back-end for the auth server. Originally contributed by https://github.com/apestel

limitations:

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

const (

	// BackendName is the name of this backend
	BackendName = "dynamodb"

	// DefaultReadCapacityUnits specifies default value for read capacity units
	DefaultReadCapacityUnits = 10

	// DefaultWriteCapacityUnits specifies default value for write capacity units
	DefaultWriteCapacityUnits = 10
)

Functions

func GetName

func GetName() string

GetName() is a part of backend API and it returns DynamoDB backend type as it appears in `storage/type` section of Teleport YAML

func New

func New(params backend.Params) (backend.Backend, error)

New returns new instance of DynamoDB backend. It's an implementation of backend API's NewFunc

Types

type DynamoConfig

type DynamoConfig struct {
	// Region is where DynamoDB Table will be used to store k/v
	Region string `json:"region,omitempty"`
	// AWS AccessKey used to authenticate DynamoDB queries (prefer IAM role instead of hardcoded value)
	AccessKey string `json:"access_key,omitempty"`
	// AWS SecretKey used to authenticate DynamoDB queries (prefer IAM role instead of hardcoded value)
	SecretKey string `json:"secret_key,omitempty"`
	// Tablename where to store K/V in DynamoDB
	Tablename string `json:"table_name,omitempty"`
	// ReadCapacityUnits is Dynamodb read capacity units
	ReadCapacityUnits int64 `json:"read_capacity_units"`
	// WriteCapacityUnits is Dynamodb write capacity units
	WriteCapacityUnits int64 `json:"write_capacity_units"`
}

DynamoConfig structure represents DynamoDB confniguration as appears in `storage` section of Teleport YAML

func (*DynamoConfig) CheckAndSetDefaults

func (cfg *DynamoConfig) CheckAndSetDefaults() error

CheckAndSetDefaults is a helper returns an error if the supplied configuration is not enough to connect to DynamoDB

type DynamoDBBackend

type DynamoDBBackend struct {
	*log.Entry
	DynamoConfig
	// contains filtered or unexported fields
}

DynamoDBBackend struct

func (*DynamoDBBackend) AcquireLock

func (b *DynamoDBBackend) AcquireLock(token string, ttl time.Duration) error

AcquireLock for a token

func (*DynamoDBBackend) Clock

func (b *DynamoDBBackend) Clock() clockwork.Clock

Clock returns wall clock

func (*DynamoDBBackend) Close

func (b *DynamoDBBackend) Close() error

Close the DynamoDB driver

func (*DynamoDBBackend) CompareAndSwapVal

func (b *DynamoDBBackend) CompareAndSwapVal(path []string, key string, val []byte, prevVal []byte, ttl time.Duration) error

CompareAndSwapVal compares and swap values in atomic operation

func (*DynamoDBBackend) CreateVal

func (b *DynamoDBBackend) CreateVal(path []string, key string, val []byte, ttl time.Duration) error

CreateVal create a key with defined value

func (*DynamoDBBackend) DeleteBucket

func (b *DynamoDBBackend) DeleteBucket(path []string, key string) error

DeleteBucket remove all prefixed keys WARNING: there is no bucket feature, deleting "bucket" mean a deletion one by one

func (*DynamoDBBackend) DeleteKey

func (b *DynamoDBBackend) DeleteKey(path []string, key string) error

DeleteKey remove a key

func (*DynamoDBBackend) GetItems

func (b *DynamoDBBackend) GetItems(path []string, opts ...backend.OpOption) ([]backend.Item, error)

GetItems is a function that returns keys in batch

func (*DynamoDBBackend) GetKeys

func (b *DynamoDBBackend) GetKeys(path []string, opts ...backend.OpOption) ([]string, error)

GetKeys retrieve all keys matching specific path

func (*DynamoDBBackend) GetVal

func (b *DynamoDBBackend) GetVal(path []string, key string) ([]byte, error)

GetVal retrieve a value from a key

func (*DynamoDBBackend) ReleaseLock

func (b *DynamoDBBackend) ReleaseLock(token string) error

ReleaseLock for a token

func (*DynamoDBBackend) UpsertItems

func (b *DynamoDBBackend) UpsertItems(bucket []string, items []backend.Item) error

func (*DynamoDBBackend) UpsertVal

func (b *DynamoDBBackend) UpsertVal(path []string, key string, val []byte, ttl time.Duration) error

UpsertVal update or create a key with defined value (refresh TTL if already exist)

Source Files

doc.go dynamo.go dynamodbbk.go

Version
v3.2.17+incompatible (latest)
Published
Feb 4, 2021
Platform
linux/amd64
Imports
17 packages
Last checked
1 month ago

Tools for package owners.