Last active
November 4, 2015 23:37
-
-
Save dalice/40544c999788832531c2 to your computer and use it in GitHub Desktop.
AWS Lambdaを使ってさくらのクラウドのディスクのアーカイブを取得する http://itfun.jp/2015/11/aws-lambda.html
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
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