Skip to content

Instantly share code, notes, and snippets.

@Madh93
Created March 16, 2021 11:56
Show Gist options
  • Save Madh93/b6d72db23f3bc181180c8f0410dcb6a9 to your computer and use it in GitHub Desktop.
Save Madh93/b6d72db23f3bc181180c8f0410dcb6a9 to your computer and use it in GitHub Desktop.
Update a DynamoDB global secondary index provisioned throughput using AWS SDK for Go
package main
import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
)
const (
TableName = "MyTable"
TableIndexName = "MyIndex"
ReadCapacityUnits = 1
WriteCapacityUnits = 2
)
func main() {
sess, _ := session.NewSession()
svc := dynamodb.New(sess)
result, err := svc.UpdateTable(&dynamodb.UpdateTableInput{
TableName: aws.String(TableName),
GlobalSecondaryIndexUpdates: []*dynamodb.GlobalSecondaryIndexUpdate{
{
Update: &dynamodb.UpdateGlobalSecondaryIndexAction{
IndexName: aws.String(TableIndexName),
ProvisionedThroughput: &dynamodb.ProvisionedThroughput{
ReadCapacityUnits: aws.Int64(ReadCapacityUnits),
WriteCapacityUnits: aws.Int64(WriteCapacityUnits),
},
},
},
},
})
if err != nil {
log.Panic(err)
}
log.Print(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment