Skip to content

Instantly share code, notes, and snippets.

@ambakshi
Last active April 24, 2017 14:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambakshi/d17ad18e0532530359f9 to your computer and use it in GitHub Desktop.
Save ambakshi/d17ad18e0532530359f9 to your computer and use it in GitHub Desktop.
Accessing sdb from the awscli
$ aws configure set preview.sdb true
$ aws sdb create-domain skv
$ aws sdb put-attributes --domain-name skv --item-name ami_idx --attributes Name=app-mwios-asg,Value=1
$ aws sdb put-attributes --domain-name skv --item-name ami_idx --attributes Name=app-ccand-asg,Value=5

$ aws sdb get-attributes --domain-name skv --item-name ami_idx --attribute-names app-mwios-asg
{
"Attributes": [
    {
        "Name": "app-mwios-asg",
        "Value": "1"
    }
]
}

$ aws sdb get-attributes --domain-name skv --item-name ami_idx
{
"Attributes": [
    {
        "Name": "app-mwios-asg",
        "Value": "1"
    },
    {
        "Name": "app-ccand-asg",
        "Value": "5"
    }
]
}

# Atomically increment a number via CAS (compare and swap)
$ VAL=$(aws sdb get-attributes --domain-name skv --item-name ami_idx --attribute-names app-mwios-asg --query 'Attributes[*].Value' --output text)
$ NEWVAL=$(( $VAL + 1 ))
$ aws sdb put-attributes --domain-name skv --item-name ami_idx --attributes Name=app-mwios-asg,Value=$NEWVAL --expected Name=app-mwios-asg,Value=$VAL,Exists=true
@madankumar-t
Copy link

Hey
Thanks for the comamnds , but i was confused what are the values of ami_idx and app-mwios-asg in your case

as per my understanding instance id is ami_idx and app-mwios-asg is asg group attached

please confirm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment