Using PowerShell for common AWS SimpleDB operations

#Create SimpleDB client

Add-Type -Path "C:\AWS SDK\1.3.8.0\bin\AWSSDK.dll"
$sdb=[Amazon.AWSClientFactory]::CreateAmazonSimpleDBClient('Key Id', 'Secret Key')

#Create Domain

$req = (new-object Amazon.SimpleDB.Model.CreateDomainRequest).WithDomainName('Contacts')
$sdb.CreateDomain($req)

#List Domains

$req = (new-object Amazon.SimpleDB.Model.ListDomainsRequest)
$sdb.ListDomains($req)

#Insert Item

$req = (new-object Amazon.SimpleDB.Model.PutAttributesRequest).WithDomainName('Contacts').WithItemName('user1');
$req.Attribute.Add((new-object Amazon.SimpleDB.Model.ReplaceableAttribute).WithName('FirstName').WithValue('Konstantin'))
$req.Attribute.Add((new-object Amazon.SimpleDB.Model.ReplaceableAttribute).WithName('LastName').WithValue('Vlasenko'))
$sdb.PutAttributes($req)

#Query All Items

$req = (new-object Amazon.SimpleDB.Model.SelectRequest).WithSelectExpression('select * from Contacts')
$sdb.Select($req)

#Query Item

$req = (new-object Amazon.SimpleDB.Model.SelectRequest).WithSelectExpression('select * from Contacts where itemName()="user1"')
$sdb.Select($req)
Advertisements

One thought on “Using PowerShell for common AWS SimpleDB operations

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s