-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add-VSDynamoDBTableAttributeDefinition? #27
Comments
Hey Richard, The way to think about it is that a DynamoDB Table AttributeDefinition is a single object with two properties; AttributeName and AttributeType. In PowerShell, you would need to create 2 AttributeDefinition objects for this to match, which means a call to Here are a couple ways you can accomplish this to create the DynamoDBTable you're looking for: Option 1 (cleaner view): Store AttributeDefinitions and KeySchemas in variables$dyDbAttDefs = @()
$dyDbKeySchemas = @()
$dyDbAttDefs += @("key","eventTime") | ForEach-Object {Add-VSDynamoDBTableAttributeDefinition -AttributeName $_ -AttributeType S}
$dyDbKeySchemas += Add-VSDynamoDBTableKeySchema -AttributeName key -KeyType HASH
$dyDbKeySchemas += Add-VSDynamoDBTableKeySchema -AttributeName eventTime -KeyType RANGE
$newVSDynamoDBTableSplat = @{
ProvisionedThroughput = (Add-VSDynamoDBTableProvisionedThroughput -ReadCapacityUnits 1 -WriteCapacityUnits 1)
KeySchema = $dyDbKeySchemas
AttributeDefinitions = $dyDbAttDefs
LogicalId = "MyDynamoDB"
}
New-VSDynamoDBTable @newVSDynamoDBTableSplat Option 2: One-linerNew-VSDynamoDBTable -LogicalId "MyDynamoDB" -AttributeDefinitions (Add-VSDynamoDBTableAttributeDefinition -AttributeName key -AttributeType S),(Add-VSDynamoDBTableAttributeDefinition -AttributeName eventTime -AttributeType S) -KeySchema (Add-VSDynamoDBTableKeySchema -AttributeName key -KeyType HASH),(Add-VSDynamoDBTableKeySchema -AttributeName eventTime -KeyType RANGE) -ProvisionedThroughput (Add-VSDynamoDBTableProvisionedThroughput -ReadCapacityUnits 1 -WriteCapacityUnits 1) Another thing to keep in mind is that any attributes where CloudFormation itself is expecting a specific type (i.e. Dynamo Table
|
Never mind Nate. I think my issues are partially related to having extra spaces in my editor, and then my script failing between parameters. |
Thanks Nate. I missed your reply. Will read it now 👍 |
Thanks again. I was trying to accomplish the one liner method. I appreciate your taking the time to show me the splatting method too. |
I'm glad you're liking VaporShell!! Happy to help whenever it's needed! Not sure if you have pre-existing CloudFormation templates spun up prior to using VaporShell, but I'm currently working on adding functionality to reverse-engineer an existing CloudFormation template into a VaporShell script that would create it. Should hopefully have it released with the next version pretty soon! |
That sounds great. I am trying to bring in my templates as I go. I only have a few. I'm finding it easiest to look at the original serverless yml files, and then try to replicate into my vaporshell script. At the same time, learning git, and reorganizing my development environment, so plenty on board. I also was looking recently at sam local (and docker), but I think I will just concentrate on scripts to build & teardown on aws as needed. |
Gotcha, that makes sense! If you'd like to follow along with the progress of that add'l functionality, I've created Issue #28 to track that. Feel free to subscribe to updates there to follow along if you'd like! |
Hi Nate,
I'm hoping you have a minute to help me with creating some attributes for a dynamodb table? I am struggling with how to do it.
I want these properties for my table:
AttributeDefinitions: - AttributeName: key AttributeType: S - AttributeName: eventTime AttributeType: S KeySchema: - AttributeName: key KeyType: HASH - AttributeName: eventTime KeyType: RANGE ProvisionedThroughput: ReadCapacityUnits: 1 WriteCapacityUnits: 1
I thought I could do this, but it doesn't seem to work when I vaporize
Cheers, Richard
The text was updated successfully, but these errors were encountered: