Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Adding DynamoDB Resource For Creation
Browse files Browse the repository at this point in the history
**Why:**

* allows you to create a dynamodb table via a CRD

**This change addresses the need by:**

* closes #6

Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Aug 2, 2018
1 parent 3db23a4 commit f79f484
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/dynamodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: operator.aws/v1alpha1
kind: DynamoDB
metadata:
name: dynamodb-table
spec:
tableName: dynamodb-table
hashAttribute:
name: user_id
type: S
rangeAttribute:
name: created_at
type: S
readCapacityUnits: 5
writeCapacityUnits: 5
95 changes: 95 additions & 0 deletions models/dynamodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: operator.aws/v1alpha1
kind: ModelDefinition
metadata:
name: DynamoDBResource
spec:
kind: DynamoDB
type: Spec # can be Spec or Data
queue: true
useCloudFormation: true
resource:
name: dynamodb
plural: dynamodbs
shortNames:
- name: ddb
- name: ddbs
- name: dynamo
- name: dynamotable
- name: dynamotables
body:
schema:
title: DynamoDB
type: object
properties:
- key: tableName
type: string
description: |
TableName is the name of the DynamoDB Table to be created.
structKey: TableName
templateKey: TableName
- key: rangeAttribute
type: object
description: |
RangeAttribute is the configuration for the range attribute.
structKey: RangeAttribute
templateKey: RangeAttribute
properties:
- key: Name
type: string
description: |
Name is the name of the range attribute on the table.
structKey: Name
templateKey: RangeAttributeName
- key: Type
type: string
description: |
Type is the kind of range attribute that should be used.
structKey: Type
templateKey: RangeAttributeType
- key: readCapacityUnits
type: int
description: |
ReadCapacityUnits specifies the read capacity of the table.
structKey: ReadCapacityUnits
templateKey: ReadCapacityUnits
- key: writeCapacityUnits
type: int
description: |
WriteCapacityUnits specifies the write capacity of the table.
structKey: WriteCapacityUnits
templateKey: WriteCapacityUnits
- key: hashAttribute
type: object
description: |
HashAttribute is the configuration for the hash attribute on the table.
structKey: HashAttribute
templateKey: HashAttribute
properties:
- key: Name
type: string
description: |
Name is the name of the hashing attribute on the table.
structKey: Name
templateKey: HashAttributeName
- key: Type
type: string
description: |
Type is the kind of hash attribute that should be used.
structKey: Type
templateKey: HashAttributeType
output:
schema:
type: object
properties:
- key: tableName
type: string
description: |
TableName is the output tablename incase it changed
structKey: TableName
templateKey: TableName
- key: tableARN
type: string
description: |
TableARN is the full Amazon ARN for the table created
structKey: TableARN
templateKey: TableArn
5 changes: 5 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
awsclient "github.com/christopherhein/aws-operator/pkg/client/clientset/versioned/typed/operator.aws/v1alpha1"
"github.com/christopherhein/aws-operator/pkg/config"
"github.com/christopherhein/aws-operator/pkg/operator/cloudformationtemplate"
"github.com/christopherhein/aws-operator/pkg/operator/dynamodb"
"github.com/christopherhein/aws-operator/pkg/operator/s3bucket"
opkit "github.com/christopherhein/operator-kit"
"k8s.io/api/core/v1"
Expand Down Expand Up @@ -44,6 +45,7 @@ func (c *Server) Run(stopChan chan struct{}) {
resources := []opkit.CustomResource{
cloudformationtemplate.Resource,
s3bucket.Resource,
dynamodb.Resource,
}
err = opkit.CreateCustomResources(*context, resources)
if err != nil {
Expand Down Expand Up @@ -81,6 +83,9 @@ func (c *Server) Run(stopChan chan struct{}) {

s3controller := s3bucket.NewController(config, context, awsClientset)
s3controller.StartWatch(v1.NamespaceAll, stopChan)

ddbcontroller := dynamodb.NewController(config, context, awsClientset)
ddbcontroller.StartWatch(v1.NamespaceAll, stopChan)
}

func getClientConfig(kubeconfig string) (*rest.Config, error) {
Expand Down

0 comments on commit f79f484

Please sign in to comment.