ã¿ãªãããããã«ã¡ã¯
ãã¯ãã«ã«ãã¼ã ã®å®®æ¾¤ã§ãã
ãã¯ãã«ã«ãã¼ã ã®å®®æ¾¤ã§ãã
ä»åã¯ãWindowsã«"EC2 API Tools"ãå°å
¥ãã¦ãAPI ãå©ç¨ãã¦ã¤ã³ã¹ã¿ã³ã¹ãç«ã¡ä¸ãããã¨æãã¾ãã
Amazon EC2 API Toolsã¨ã¯ï¼
Amazon Web Servicesã®Amazon EC2ãAPIã§æä½ããããã®ã³ãã³ãã©ã¤ã³ãã¼ã«ã§ãã
ç§éããã使ã£ã¦ããManagement Consoleã¯ãè£ã§APIãå®è¡ãã¦åä½ããã¦ãã¾ãã
ç§éããã使ã£ã¦ããManagement Consoleã¯ãè£ã§APIãå®è¡ãã¦åä½ããã¦ãã¾ãã
ï¼ï¼æºå
Amazon EC2 API Tools(以ä¸API Tools)ãã¤ã³ã¹ãã¼ã«ããçºã«ãå¿
è¦ãªä»¥ä¸ã®ãã®ãç¨æãã¾ãã
- AWSã¢ã«ã¦ã³ãID
- ã¢ã¯ã»ã¹ãã¼ID
- ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼
- X509証ææ¸
- ç§å¯éµãã¡ã¤ã«
Management Consoleãå©ç¨ãã¦ããå ´åãå³ä¸ã®ãã«ãã¦ã³ã¡ãã¥ã¼ããã"Security Credential"ãé¸æãããã¨ã§ã
å¿ è¦ãªæ å ±ãåå¾ã§ãã¾ãã
å¿ è¦ãªæ å ±ãåå¾ã§ãã¾ãã
ï¼ï¼ã¤ã³ã¹ãã¼ã«
â
ï¼ãã¦ã³ãã¼ã
API ToolsãAWSã®å
¬å¼ãã¼ã¸ãããã¦ã³ãã¼ããã¾ãã
ã¾ããAPI Toolsã¯Javaã«ããåä½ãã¦ããããJavaãã¤ã³ã¹ãã¼ã«ããå¿
è¦ãããã¾ãã
ãã¡ãã®ãªã³ã¯ããã©ãã¨ä»¥ä¸ã®ãµã¤ãã«ç§»åãã¾ãã®ã§ãããããJavaãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
ãã¡ãã®ãªã³ã¯ããã©ãã¨ä»¥ä¸ã®ãµã¤ãã«ç§»åãã¾ãã®ã§ãããããJavaãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
â
¡ï¼ã¤ã³ã¹ãã¼ã«
- ãã¦ã³ãã¼ãããAPI Toolsã"C:"ã«å±éãã¾ãã
- å±éãããã©ã«ãã«ã¢ã¯ã»ã¹ãã¼ã¨ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ãé ç½®ãã¦ããã¾ãã
- ç°å¢å¤æ°ã®è¨å®
ãã¡ã¤ã«ãå±éããã ãã§ã¯Windowsã®ã³ãã³ãããã³ããã§ã¯ã³ãã³ããå©ç¨ãããã¨ãã§ãã¾ããã
ãã®ããã以ä¸ã®ããã«ç°å¢å¤æ°ãè¨å®ãã¦ã³ãã³ããå®è¡ã§ããããã«ãã¾ãã
ãã®ããã以ä¸ã®ããã«ç°å¢å¤æ°ãè¨å®ãã¦ã³ãã³ããå®è¡ã§ããããã«ãã¾ãã
Javaã®ã¤ã³ã¹ãã¼ã«ããã¦ãããã©ã«ããæå® â»ç°å¢ã«ãã£ã¦ç°ãªãå ´åãããã¾ãã C:>set JAVA_HOME=C:"Program Files (x86)Javajre7"
API Toolsã®ãã©ã«ããæå® C:>set EC2_HOME=C:ec2-api-tools
API Toolsã®ã³ãã³ããæ ¼ç´ããã¦ãããã©ã«ããæå® C:>set PATH=%PATH%;ec2-api-toolsbin
使ç¨ãããªã¼ã¸ã§ã³ãæå® C:>set EC2_URL=https://ec2.ap-northeast-1.amazonaws.com
å©ç¨ããã¢ã«ã¦ã³ãã®ã¢ã¯ã»ã¹ãã¼ã¨ã·ã¼ã¯ã¬ããã¢ã¯ã»ã¹ãã¼ãæå® C:ec2-api-tools>set EC2_PRIVATE_KEY=%EC2_HOME%pk.pem C:ec2-api-tools>set EC2_CERT=%EC2_HOME%cert.pem
- ããããã¡ã¤ã«ã®ä½æ
ç°å¢å¤æ°ãã³ãã³ãããã³ããã§å®è¡ããå ´åãéãã¦ãã¾ãã¨å度ç°å¢å¤æ°ãè¨å®ããªããã°ãªãã¾ããã
ãã®æéãçãããã«ãç°å¢å¤æ°è¨å®ã®ããããã¡ã¤ã«ãä½æãã¾ãã
è¤æ°ã®AWSã¢ã«ã¦ã³ãããªã¼ã¸ã§ã³ã使ã£ã¦ããå ´åã¯ãåå¥ã«ç¨æãã¦ããã¨é常ã«ä¾¿å©ã§ãã
ãã¡ã¤ã«åã¯".bat"å½¢å¼ã§ä½æãã¾ãã
ãã®æéãçãããã«ãç°å¢å¤æ°è¨å®ã®ããããã¡ã¤ã«ãä½æãã¾ãã
è¤æ°ã®AWSã¢ã«ã¦ã³ãããªã¼ã¸ã§ã³ã使ã£ã¦ããå ´åã¯ãåå¥ã«ç¨æãã¦ããã¨é常ã«ä¾¿å©ã§ãã
ãã¡ã¤ã«åã¯".bat"å½¢å¼ã§ä½æãã¾ãã
â»ãªã¼ã¸ã§ã³ã¯ä½¿ç¨ããããªã¼ã¸ã§ã³ãè¨è¿°ãã¦ãã ããã
â»ä½æããããããã¡ã¤ã«ã¯ã³ãã³ãããã³ããã®ãã¼ã ãã£ã¬ã¯ããªã«é ç½®ãã¦ãã ããã
â»ä½æããããããã¡ã¤ã«ã¯ã³ãã³ãããã³ããã®ãã¼ã ãã£ã¬ã¯ããªã«é ç½®ãã¦ãã ããã
ï¼ï¼API Toolsã®å®è¡
- ããããã¡ã¤ã«ã®å®è¡
ã³ãã³ãããã³ãããããå
ã»ã©ä½æããããããã¡ã¤ã«ãå®è¡ãã¾ãã
ããããã¡ã¤ã«ãå®è¡ãããã¨ã§ãç°å¢å¤æ°ãè¨å®ããã¾ãã
ããããã¡ã¤ã«ãå®è¡ãããã¨ã§ãç°å¢å¤æ°ãè¨å®ããã¾ãã
- åä½ç¢ºèª
âec2verâã¨ã³ãã³ããå®è¡ãããã¼ã¸ã§ã³ã表示ãããã°API Toolsãåãã¦ããã¨ç¢ºèªã§ãã¾ãã
ï¼ï¼ã¤ã³ã¹ã¿ã³ã¹ã®èµ·å
ããããã¯å®éã«ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãã¦ä½¿ããããã«ãããã¨æãã¾ãã
â
ï¼ãã¼ãã¢ã®ä½æ
- ãã¼ãã¢ã®ä¸è¦§ã表示
C:Userskei_miyazawa>ec2-describe-keypairs
- ãã¼ãã¢ã®ä½æ
C:Userskei_miyazawa>ec2-add-keypair demo_key | find /V "KEYPAIR" > %EC2_HOME%demo_key.pemâ»ãã¼ã«ã«ã«ä¿åãããã¼ã¯ã¤ã³ã¹ã¿ã³ã¹ã«ãã°ã¤ã³ããéã«å©ç¨ãã¾ãã®ã§å¤§åã«ä¿ç®¡ãã¦ãã ããã â ¡ï¼ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãã®ä½æ
- ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãã®ä¸è¦§ã表示
ec2-describe-group
- ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãã®ä½æ
ec2-add-group demo_sg
- ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãã®è¨å®
ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãã§æ¥ç¶ã許å¯ãããã¼ããæå®ãã¾ãã
ä»åã¯ICMPã¨HTTPãRDPã許å¯ãã¾ãã
ä»åã¯ICMPã¨HTTPãRDPã許å¯ãã¾ãã
ec2-authorize demo_sg -P icmp -t -1:-1 -s 0.0.0.0/0 ec2-authorize demo_sg -P tcp -p 80 ec2-authorize demo_sg -P tcp -p 3389ã-s 202.215.74.59/32
â
¢ï¼ã¤ã³ã¹ã¿ã³ã¹ã®èµ·å
- èµ·åã«å©ç¨ããAMIãæ¢ã
ec2-describe-images
ããã§ã¯AMIã大éã«è¡¨ç¤ºãããè¦ã¤ãããã¨ãé£ããã®ã§ã以ä¸ã®ããã«ãªãã·ã§ã³ããã¤ãã³ãã³ãã§"find"ã使ãæ¡ä»¶ãçµã£ã¦è¡¨ç¤ºããããã¨ã§ãã¾ãã
ä¾1ï¼Amazonã®æä¾ãã¦ããã¤ã¡ã¼ã¸ããFedora8ã®32bitã®ã¤ã¡ã¼ã¸ãæ¢ãã
ec2-describe-images --owner amazon | find "fedora-8-i386"ä¾2ï¼èªåã®ã¢ã«ã¦ã³ãã§ä½æããAMIãæ¢ãã¨ãã¯ä»¥ä¸ã®ããã«ãã¾ãã
ec2-describe-images --owner ã¢ã«ã¦ã³ããã³ãã¼ | find "ãã¼ã¯ã¼ã"
- AMIããã¤ã³ã¹ã¿ã³ã¹ãèµ·å
å
ç¨æ¢ããWindowsAMIï¼ami-2ae95f2bï¼ãå©ç¨ãã¦ãã¤ã³ã¹ã¿ã³ã¹ãèµ·åãããã¨æãã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ãèµ·åããããã«ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ãèµ·åããããã«ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
ec2-run-instances ami-2ae95f2b
ãã®ããã«ãªãã·ã§ã³ç¡ãã§èµ·åããã¨ãããã©ã«ãã®ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãããã¼ãã¢ãªããsmallã¤ã³ã¹ã¿ã³ã¹ã§èµ·åãã¦ãã¾ãã¾ãã
以ä¸ã®ããã«è©³ç´°ãæå®ãã¦èµ·åãããã¨ãã§ãã¾ãã
以ä¸ã®ããã«è©³ç´°ãæå®ãã¦èµ·åãããã¨ãã§ãã¾ãã
ec2-run-instances AMIå -g ã»ãã¥ãªãã£ã¼ã°ã«ã¼ã -k ãã¼ã㢠-n åæ° -t ã¤ã³ã¹ã¿ã³ã¹ã¿ã¤ã
â
£ï¼Elastic IPã®å²ãå½ã¦
- ElasticIPã®ä¸è¦§ã表示
ec2-describe-addresses
- Elastic IPã®å²ãå½ã¦
ec2-associate-address -i ã¤ã³ã¹ã¿ã³ã¹ID Elastic IP
- Elastic IPã®åãå¤ã
ec2-disassosiate-address Elastic IPâ ¤ï¼ã¤ã³ã¹ã¿ã³ã¹ã®åæ¢ãåé¤
- ã¤ã³ã¹ã¿ã³ã¹ãåæ¢ãã
ec2-stop-instances ã¤ã³ã¹ã¿ã³ã¹ID
- ã¤ã³ã¹ã¿ã³ã¹ãåé¤ãã
ec2-terminale-instances ã¤ã³ã¹ã¿ã³ã¹ID
ï¼ï¼ã¾ã¨ã
å®éã«ã¤ã³ã¹ãã¼ã«ãè¡ããå©ç¨ãã¦ã¿ãã¨ãLinuxã¨åæ§ã«åä½ããã¾ãããããããTabã®è£å®æ©è½ãªã©ã使ããªãã¨ãããæ®å¿µãªæã§ãã
Windowsã使ã£ã¦ããã¨ãã¤ãManagement Consoleã使ã£ã¦ãã¾ããã¡ã§ãããELB(Elastic Load Balancing)ã®SSL証ææ¸ã®æ´æ°ã¯ELBã®API Toolsã使ããªãã¨ä½æ¥ãã§ãã¾ããã
ãã®ããã«ãAPI Toolsã使ãå ´é¢ã¯å¿ ãç¾ããã®ã§ãå ¥ãã¦ããã«è¶ãããã¨ã¯ãªãã¨æãã¾ãã
Amazonã®ã¯ã©ã¦ããå©ç¨ãã¦ãããªãããã®æ©ä¼ã«âWindowsâã«API Toolsãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã¦ã¯ãããã§ããããã ãåèã¾ã§ã«ãé¢é£ããã³ãã³ããã¾ã¨ãã表ãä½æè´ãã¾ããã
å 容 | ã³ãã³ã |
---|---|
ãªã¼ã¸ã§ã³ä¸è¦§ | ec2-describe-regions |
ãã¼ãã¢ä¸è¦§ | ec2-describe-keypairs |
ãã¼ãã¢ä½æ | ec2-add-keypair KeyPairå |
ãã¼ãã¢åé¤ | ec2-delete-keypair KeyPairå |
ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãä¸è¦§ | ec2-describe-group |
ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãä½æ | ec2-add-group ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãå |
ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãåé¤ | ec2-delete-group ã»ãã¥ãªãã£ã¼ã°ã«ã¼ãå |
AMIã®ä¸è¦§ | ec2-describe-images |
ã¤ã³ã¹ã¿ã³ã¹ã®ä¸è¦§ | ec2-describe-instances |
ã¤ã³ã¹ã¿ã³ã¹ã®èµ·å | ec2-run-instances AMIå |
ã¤ã³ã¹ã¿ã³ã¹Start | ec2-start-instances ã¤ã³ã¹ã¿ã³ã¹ID |
ã¤ã³ã¹ã¿ã³ã¹Stop | ec2-stop-instances ã¤ã³ã¹ã¿ã³ã¹ID |
ã¤ã³ã¹ã¿ã³ã¹Terminate | ec2-terminate-instances ã¤ã³ã¹ã¿ã³ã¹ID |
Elastic IPä¸è¦§ | ec2-describe-addresses |
Elastic IPåãä»ã | ec2-associate-address -i ã¤ã³ã¹ã¿ã³ã¹ID Elastic IP |
Elastic IPåãå¤ã | ec2-disassosiate-address Elastic IP |