{"id":2098,"date":"2019-04-20T19:32:41","date_gmt":"2019-04-20T10:32:41","guid":{"rendered":"https:\/\/test.ji0vwl.net\/?p=2098"},"modified":"2020-02-14T14:19:06","modified_gmt":"2020-02-14T05:19:06","slug":"lightsail%e3%82%a4%e3%83%b3%e3%82%b9%e3%82%bf%e3%83%b3%e3%82%b9%e3%82%92aws-cli%e3%81%a7%e8%87%aa%e5%8b%95%e3%83%90%e3%83%83%e3%82%af%e3%82%a2%e3%83%83%e3%83%97%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/ji0vwl.net\/index.php\/2019\/04\/20\/2098\/","title":{"rendered":"Lightsail\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092AWS CLI\u3067\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b"},"content":{"rendered":"<p>\u5f53Blog\u3092\u52d5\u304b\u3057\u3066\u3044\u308b<a href=\"https:\/\/aws.amazon.com\/jp\/lightsail\/\">Amazon Lightsail<\/a>\u306f\u3001\u4eca\u307e\u3067\u6c17\u4ed8\u3044\u305f\u6642\u306b\u624b\u52d5\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f<a href=\"https:\/\/aws.amazon.com\/jp\/cli\/\">AWS CLI<\/a>\u3092\u4f7f\u3063\u3066\u81ea\u52d5\u30d0\u30c3\u30c3\u30af\u30a2\u30c3\u30d7\u306b\u30c8\u30e9\u30a4\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30d9\u30b9\u30c8\u306a\u3084\u308a\u65b9\u3067\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001Linux\u306e\u30b5\u30fc\u30d0\u30fc\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u8d77\u52d5\u3057\u3066\u3044\u3066\u3082\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u308c\u308b\u306e\u3067\u3001\u81ea\u5206\u81ea\u8eab\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u81ea\u5206\u81ea\u8eab\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<h4>1. AWS CLI\u7528\u306eIAM\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3059\u308b<\/h4>\n<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089AWS\u3092\u64cd\u4f5c\u3059\u308bAWS CLI\u7528\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306fLightsail\u3092\u64cd\u4f5c\u3057\u307e\u3059\u304c\u3001EC2\u3084S3\u306a\u3069\u4ed6\u306eAWS\u30b5\u30fc\u30d3\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u5834\u5408\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n<h5>-1. \u30b5\u30fc\u30d3\u30b9 &#8211; IAM<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2101 size-full\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/a4bf944146f6c7330bb1e55d00d45c00.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/p>\n<h5>-2. \u30e6\u30fc\u30b6\u30fc &#8211; \u30e6\u30fc\u30b6\u3092\u8ffd\u52a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2109 size-full\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/65bb9af1ef764a6ae288428d56783579-1.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/h5>\n<h5>-3. \u9069\u5f53\u306a\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u5165\u529b\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3088\u308b\u30a2\u30af\u30bb\u30b9\u306b\u30c1\u30a7\u30c3\u30af<\/h5>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2103\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/bc48a812a9a10f3636672c89e05b07e8.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/p>\n<h5>-4. \u65e2\u5b58\u306e\u30dd\u30ea\u30b7\u30fc\u3092\u76f4\u63a5\u30a2\u30bf\u30c3\u30c1 &#8211; PowerUserAccess \u6a29\u9650\u3092\u4ed8\u4e0e<\/h5>\n<p><a href=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/5f9f790a631de085ec7a0a17a7aaa790.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2104\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/5f9f790a631de085ec7a0a17a7aaa790.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/a><\/p>\n<h5>-5. \u4f55\u3082\u305b\u305a\u3001\u6b21\u306e\u30b9\u30c6\u30c3\u30d7:\u78ba\u8a8d<a href=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/a3e338c73d9e504bdb4d43ceca12e02e.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2105\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/a3e338c73d9e504bdb4d43ceca12e02e.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/a><\/h5>\n<h5>-6. \u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210<a href=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/b6d53c073c55266216719ad0edcbbea7.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2106\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/b6d53c073c55266216719ad0edcbbea7.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/a><\/h5>\n<h5>-7. \u30a2\u30af\u30bb\u30b9\u30ad\u30fcID\u3068\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u53d6\u5f97<\/h5>\n<p><strong>\u30a2\u30af\u30bb\u30b9\u30ad\u30fcID<\/strong>\u3068<strong>\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/strong>\u306f\u3001AWS CLI\u306e\u521d\u671f\u8a2d\u5b9a\u3067\u4f7f\u7528\u3059\u308b\u306e\u3067\u63a7\u3048\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2127\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/fdd0aac9b82022cd4fbbc4caf89ee59e-1.jpg\" alt=\"\" width=\"800\" height=\"541\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>2. AWS CLI\u3092\u3044\u308c\u308b<\/h4>\n<h5>-1. AWS CLI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h5>\n<p>Lightsail\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306bSSH\u30ed\u30b0\u30a4\u30f3\u3057\u3001pip\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u5bfe\u8c61\u306eOS\u306fCentOS7\u3067\u3059\u3002<\/p>\n<pre>$ sudo -i\r\n# curl \"https:\/\/bootstrap.pypa.io\/get-pip.py\" -o \"get-pip.py\"\r\n# python get-pip.py\r\n# pip install awscli --upgrade --ignore-installed six\r\n# pip install --upgrade pip\r\n# pip install requests --ignore-installed\r\n# pip install --upgrade --force-reinstall 'requests==2.6.0'\r\n<\/pre>\n<h5>-2. AWS CLI\u306e\u521d\u671f\u8a2d\u5b9a<\/h5>\n<p>\u5148\u307b\u3069\u53d6\u5f97\u3057\u305f\u3001<strong>\u30a2\u30af\u30bb\u30b9\u30ad\u30fcID<\/strong>\u3068<strong>\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/strong>\u3001Lightsail\u306e\u30ea\u30fc\u30b8\u30e7\u30f3\uff08\u4f8b\u3048\u3070ap-northeast-1a\u306a\u3089\u3001<strong>ap-northeast-1<\/strong>\uff09\u3001<strong>json<\/strong> \u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre># aws configure\r\nAWS Access Key ID [None]: AKIARCxxxxxxxxxxxxxxxxx\r\nAWS Secret Access Key [None]: ufr5j0juyyyyyyyyyyyyyyyyyyyyyyyyyy\r\nDefault region name [None]: ap-northeast-1\r\nDefault output format [None]: json\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>3. Lightsail \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210<\/h4>\n<p>AWS CLI\u3067\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u540d\uff08<strong>CentOS-512MB-Tokyo-2<\/strong>\uff09\u3068\u3001\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u540d\uff08<strong>CentOS-512MB-Tokyo-2-Auto-yyyyMMdd<\/strong>\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u540d\u306f\u91cd\u8907\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u672b\u5c3e\u306b\u5e74\u6708\u65e5\u3092\u4ed8\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2111\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/04\/521357eafd165918b30fdda977578b29.jpg\" alt=\"\" width=\"800\" height=\"606\" \/><\/p>\n<p>today=$(date &#8220;+%Y%m%d&#8221;)<\/p>\n<p>aws lightsail create-instance-snapshot &#8211;instance-name <strong>CentOS-512MB-Tokyo-2<\/strong> &#8211;instance-snapshot-name <strong>CentOS-512MB-Tokyo-2-Auto-${today}<\/strong><\/p>\n<pre># vim \/root\/autobackup.sh<\/pre>\n<pre>#!\/bin\/bash\r\n\r\ntoday=$(date \"+%Y%m%d\")\r\naws lightsail create-instance-snapshot --instance-name CentOS-512MB-Tokyo-2 --instance-snapshot-name CentOS-512MB-Tokyo-2-Auto-${today}\r\nexit 0\r\n----------------\r\n:wq<\/pre>\n<pre># chmod 700 \/root\/autobackup.sh<\/pre>\n<p>&nbsp;<\/p>\n<h4>4. \u5b9a\u6642\u5b9f\u884c\u7528\u306b noanacron\u3092\u3044\u308c\u308b<\/h4>\n<p>\u3059\u3067\u306b\u5165\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u30015. \u3078\u3002<\/p>\n<pre># yum -y install cronie-noanacron\r\n# yum -y remove cronie-anacron<\/pre>\n<h4><\/h4>\n<p>&nbsp;<\/p>\n<h4>5. \u4f5c\u6210\u3057\u305f autobackup.sh \u3092 \u9031\u4e00\u3067\u5b9f\u884c\u3055\u305b\u308b<\/h4>\n<p>\/etc\/cron.d\/dailyjobs \u3092\u7de8\u96c6\u3057\u3001<strong>AWS_CONFIG_FILE=&#8221;\/root\/.aws\/config&#8221;<\/strong>\u3068\u3001weekly \u672b\u5c3e\u306b\u3001<strong>&amp;&amp; \/root\/autobackup.sh<\/strong> \u3092\u4ed8\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre># vim \/etc\/cron.d\/dailyjobs<\/pre>\n<pre># Run the daily, weekly, and monthly jobs if cronie-anacron is not installed\r\nSHELL=\/bin\/bash\r\nPATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin\r\nMAILTO=hogehoge@ji0vwl.com\r\nAWS_CONFIG_FILE=\"\/root\/.aws\/config\"\r\n\r\n# run-parts\r\n02 4 * * * root [ ! -f \/etc\/cron.hourly\/0anacron ] &amp;&amp; run-parts \/etc\/cron.daily\r\n22 4 * * 0 root [ ! -f \/etc\/cron.hourly\/0anacron ] &amp;&amp; run-parts \/etc\/cron.weekly &amp;&amp; \/root\/autobackup.sh\r\n42 4 1 * * root [ ! -f \/etc\/cron.hourly\/0anacron ] &amp;&amp; run-parts \/etc\/cron.monthly\r\n----------------\r\n:wq\r\n<\/pre>\n<pre># systemctl restart crond\r\n<\/pre>\n<p>\u6bce\u9031\u65e5\u66dc\u65e5\u3001\u5348\u524d4:22\u3054\u308d\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306b\u3088\u308b\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u3067\u3001\u3044\u3064\u3053\u306e\u30b5\u30fc\u30d0\u30fc\u304c\u901d\u3063\u3066\u30821\u9031\u9593\u524d\u306e\u72b6\u614b\u306b\u306f\u5fa9\u5143\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53Blog\u3092\u52d5\u304b\u3057\u3066\u3044\u308bAmazon Lightsail\u306f\u3001\u4eca\u307e\u3067\u6c17\u4ed8\u3044\u305f\u6642\u306b\u624b\u52d5\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306fAWS CLI\u3092\u4f7f\u3063\u3066\u81ea\u52d5\u30d0\u30c3\u30c3\u30af\u30a2\u30c3\u30d7\u306b\u30c8\u30e9\u30a4\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30d9 &hellip; <a href=\"https:\/\/ji0vwl.net\/index.php\/2019\/04\/20\/2098\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Lightsail\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092AWS CLI\u3067\u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2098","post","type-post","status-publish","format-standard","hentry","category-server"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts\/2098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/comments?post=2098"}],"version-history":[{"count":0,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts\/2098\/revisions"}],"wp:attachment":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/media?parent=2098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/categories?post=2098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/tags?post=2098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}