Skip to content

Commit

Permalink
Adding the tags in the creation of the dynamo db tables (#66)
Browse files Browse the repository at this point in the history
* Adding the tags in the creation of the dynamo db tables

* Adding the method WithTags so we can add to the struct the tags

* Adding the missing comment

* Remove the .gitignore

* Revert go.sum
  • Loading branch information
piclemx authored and ucirello committed Jan 9, 2020
1 parent ba994ae commit 13d585d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,13 @@ func WithCustomPartitionKeyName(s string) CreateTableOption {
}
}

// WithTags changes the tags of the table. If not specified, the table will have empty tags.
func WithTags(tags []*dynamodb.Tag) CreateTableOption {
return func(opt *createDynamoDBTableOptions) {
opt.tags = tags
}
}

// WithProvisionedThroughput changes the billing mode of DynamoDB
// and tells DynamoDB to operate in a provisioned throughput mode instead of pay-per-request
func WithProvisionedThroughput(provisionedThroughput *dynamodb.ProvisionedThroughput) CreateTableOption {
Expand Down Expand Up @@ -744,6 +751,10 @@ func (c *Client) createTable(opt *createDynamoDBTableOptions) (*dynamodb.CreateT
createTableInput.ProvisionedThroughput = opt.provisionedThroughput
}

if opt.tags != nil {
createTableInput.Tags = opt.tags
}

return c.dynamoDB.CreateTable(createTableInput)
}

Expand Down
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
1 change: 1 addition & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ type createDynamoDBTableOptions struct {
provisionedThroughput *dynamodb.ProvisionedThroughput
tableName string
partitionKeyName string
tags []*dynamodb.Tag
}

0 comments on commit 13d585d

Please sign in to comment.