Skip to content

Instantly share code, notes, and snippets.

@dalice
Last active November 4, 2015 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalice/40544c999788832531c2 to your computer and use it in GitHub Desktop.
Save dalice/40544c999788832531c2 to your computer and use it in GitHub Desktop.
AWS Lambdaを使ってさくらのクラウドのディスクのアーカイブを取得する http://itfun.jp/2015/11/aws-lambda.html
import commands
import datetime
def _(cmd):
return commands.getoutput(cmd)
def lambda_handler(event, context):
access_token = "access_token"
access_token_secret = "access_token_secret"
zone ="tk1v" #is1a:石狩第1ゾーン,is1b:石狩第2ゾーン,tk1a:東京第1ゾーン,tk1v:サンドボックス
disk_id = "DISK ID"
days = datetime.datetime.today().strftime("%Y-%m-%d")
cmds ='''curl --user "%s":"%s" -X POST -d '{"Archive":{"Name":"%s","SourceDisk":{"ID":"%s"}}}' https://secure.sakura.ad.jp/cloud/zone/%s/api/cloud/1.1/archive'''
print _(cmds % (access_token,access_token_secret,'DiskbackUP_' + days,disk_id,zone))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment