Created
March 16, 2021 11:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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