{"id":2393,"date":"2025-03-24T08:47:31","date_gmt":"2025-03-23T23:47:31","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2393"},"modified":"2025-03-24T08:47:54","modified_gmt":"2025-03-23T23:47:54","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91aws-cli%e3%81%a7rds%e3%82%92%e5%ae%8c%e5%85%a8%e5%88%b6%e5%be%a1%ef%bc%8113%e3%81%ae%e5%ae%9f%e8%b7%b5%e7%9a%84%e3%81%aa%e3%82%b3%e3%83%9e%e3%83%b3","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2393","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011AWS CLI\u3067RDS\u3092\u5b8c\u5168\u5236\u5fa1\uff0113\u306e\u5b9f\u8df5\u7684\u306a\u30b3\u30de\u30f3\u30c9\u30fb\u81ea\u52d5\u5316\u30fb\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">AWS CLI\u3067RDS\u3092\u64cd\u4f5c\u3059\u308b\u57fa\u790e\u77e5\u8b58<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">AWS CLI\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u8a8d\u8a3c\u8a2d\u5b9a\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-2\">RDS\u95a2\u9023\u306e\u4e3b\u306aAWS CLI\u30b3\u30de\u30f3\u30c9\u4e00\u89a7<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-3\">\u57fa\u672c\u7684\u306a\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8aac\u660e<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-4\">13\u306e\u5b9f\u8df5\u7684\u306aRDS\u64cd\u4f5c\u30b3\u30de\u30f3\u30c9\u5b9f\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-5\">\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\u30fb\u8d77\u52d5\u30fb\u505c\u6b62\u306e\u30b3\u30de\u30f3\u30c9<\/a>      <\/li>      <li>        <a href=\"#i-6\">\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3068\u30ea\u30b9\u30c8\u30a2\u306e\u30b3\u30de\u30f3\u30c9<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u8a2d\u5b9a\u3068\u5909\u66f4\u30b3\u30de\u30f3\u30c9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u30e1\u30c8\u30ea\u30af\u30b9\u53d6\u5f97\u306e\u30b3\u30de\u30f3\u30c9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">AWS CLI\u3092\u4f7f\u3063\u305fRDS\u306e\u81ea\u52d5\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u30b9\u30af\u30ea\u30d7\u30c8\u30b7\u30a7\u30eb\u306b\u3088\u308b\u5b9a\u671f\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u81ea\u52d5\u5316<\/a>      <\/li>      <li>        <a href=\"#i-11\">\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u4f5c\u6210\u306e\u81ea\u52d5\u5316\u3068\u4e16\u4ee3\u7ba1\u7406<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-12\">CloudWatch\u3068\u9023\u643a\u3057\u305f\u76e3\u8996\u306e\u81ea\u52d5\u5316<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-13\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-14\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-15\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8003\u616e\u3057\u305fIAM\u30dd\u30ea\u30b7\u30fc\u8a2d\u5b9a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-16\">\u5927\u898f\u6a21\u74b0\u5883\u3067\u306e\u904b\u7528\u7ba1\u7406\u306e\u30b3\u30c4<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-17\">\u767a\u5c55RDS\u904b\u7528\u7ba1\u7406\u624b\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-18\">\u8907\u6570\u74b0\u5883\u306e\u4e00\u62ec\u7ba1\u7406\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-19\">CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3068\u306e\u7d71\u5408\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">AWS CLI\u3067RDS\u3092\u64cd\u4f5c\u3059\u308b\u57fa\u790e\u77e5\u8b58<\/h2>\n\n\n\n<p>AWS CLI\u3092\u4f7f\u7528\u3057\u3066RDS\u3092\u64cd\u4f5c\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u4f5c\u696d\u3092\u52b9\u7387\u5316\u3057\u3001\u81ea\u52d5\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001AWS CLI\u306b\u3088\u308bRDS\u64cd\u4f5c\u306e\u57fa\u790e\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">AWS CLI\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u8a8d\u8a3c\u8a2d\u5b9a\u65b9\u6cd5<\/h3>\n\n\n\n<p>AWS CLI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u9069\u5207\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304b\u3089\u59cb\u3081\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>AWS CLI\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Windows\uff08PowerShell\uff09\u306e\u5834\u5408\nmsiexec.exe \/i https:\/\/awscli.amazonaws.com\/AWSCLIV2.msi\n\n# macOS\uff08Homebrew\uff09\u306e\u5834\u5408\nbrew install awscli\n\n# Linux\uff08Amazon Linux, RHEL\uff09\u306e\u5834\u5408\nsudo yum install -y aws-cli<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u5bfe\u8a71\u5f62\u5f0f\u3067\u8a8d\u8a3c\u60c5\u5831\u3092\u8a2d\u5b9a\naws configure\n\n# \u5fc5\u8981\u306a\u60c5\u5831:\n# AWS Access Key ID: [\u30a2\u30af\u30bb\u30b9\u30ad\u30fcID]\n# AWS Secret Access Key: [\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc]\n# Default region name: [\u30ea\u30fc\u30b8\u30e7\u30f3\u540d \u4f8b: ap-northeast-1]\n# Default output format: [\u51fa\u529b\u5f62\u5f0f \u4f8b: json]<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u73fe\u5728\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\naws configure list\n\n# \u7279\u5b9a\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\naws configure list --profile your-profile-name<\/pre>\n\n\n\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IAM\u30e6\u30fc\u30b6\u30fc\u306b\u306f\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u6a29\u9650\u306e\u307f\u3092\u4ed8\u4e0e<\/li>\n\n\n\n<li>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u5b9a\u671f\u7684\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u5171\u6709\u74b0\u5883\u3067\u306f\u540d\u524d\u4ed8\u304d\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">RDS\u95a2\u9023\u306e\u4e3b\u306aAWS CLI\u30b3\u30de\u30f3\u30c9\u4e00\u89a7<\/h3>\n\n\n\n<p>RDS\u306e\u64cd\u4f5c\u306b\u4f7f\u7528\u3059\u308b\u4e3b\u8981\u306a\u30b3\u30de\u30f3\u30c9\u3092\u30ab\u30c6\u30b4\u30ea\u5225\u306b\u6574\u7406\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><strong>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u7ba1\u7406<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4e00\u89a7\u8868\u793a\naws rds describe-db-instances\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8a73\u7d30\u60c5\u5831\u53d6\u5f97\naws rds describe-db-instances --db-instance-identifier your-instance-name\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\naws rds create-db-instance \\\n    --db-instance-identifier test-instance \\\n    --db-instance-class db.t3.micro \\\n    --engine mysql \\\n    --master-username admin \\\n    --master-user-password your_password<\/pre>\n\n\n\n<p><strong>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u64cd\u4f5c<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210\naws rds create-db-snapshot \\\n    --db-snapshot-identifier snapshot-name \\\n    --db-instance-identifier instance-name\n\n# \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4e00\u89a7\u8868\u793a\naws rds describe-db-snapshots\n\n# \u81ea\u52d5\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u8a2d\u5b9a\u5909\u66f4\naws rds modify-db-instance \\\n    --db-instance-identifier instance-name \\\n    --backup-retention-period 7<\/pre>\n\n\n\n<p><strong>\u30d1\u30e9\u30e1\u30fc\u30bf\u7ba1\u7406<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\naws rds create-db-parameter-group \\\n    --db-parameter-group-name custom-params \\\n    --db-parameter-group-family mysql8.0 \\\n    --description \"Custom parameter group\"\n\n# \u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5909\u66f4\naws rds modify-db-parameter-group \\\n    --db-parameter-group-name custom-params \\\n    --parameters \"ParameterName=max_connections,ParameterValue=1000,ApplyMethod=immediate\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u57fa\u672c\u7684\u306a\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8aac\u660e<\/h3>\n\n\n\n<p>AWS CLI\u306eRDS\u30b3\u30de\u30f3\u30c9\u306f\u4ee5\u4e0b\u306e\u57fa\u672c\u69cb\u6587\u306b\u5f93\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws rds &lt;\u30b3\u30de\u30f3\u30c9&gt; [\u30aa\u30d7\u30b7\u30e7\u30f3]<\/pre>\n\n\n\n<p><strong>\u4e3b\u8981\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u89e3\u8aac<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5171\u901a\u30d1\u30e9\u30e1\u30fc\u30bf<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--region<\/code>: \u64cd\u4f5c\u5bfe\u8c61\u306e\u30ea\u30fc\u30b8\u30e7\u30f3<\/li>\n\n\n\n<li><code>--profile<\/code>: \u4f7f\u7528\u3059\u308b\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u540d<\/li>\n\n\n\n<li><code>--output<\/code>: \u51fa\u529b\u5f62\u5f0f\uff08json, text, table\uff09<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u95a2\u9023<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--db-instance-identifier<\/code>: \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u8b58\u5225\u5b50<\/li>\n\n\n\n<li><code>--db-instance-class<\/code>: \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30bf\u30a4\u30d7<\/li>\n\n\n\n<li><code>--engine<\/code>: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a8\u30f3\u30b8\u30f3<\/li>\n\n\n\n<li><code>--availability-zone<\/code>: \u30a2\u30d9\u30a4\u30e9\u30d3\u30ea\u30c6\u30a3\u30be\u30fc\u30f3<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u95a2\u9023<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--backup-retention-period<\/code>: \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u4fdd\u6301\u671f\u9593<\/li>\n\n\n\n<li><code>--preferred-backup-window<\/code>: \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30a6\u30a3\u30f3\u30c9\u30a6<\/li>\n\n\n\n<li><code>--db-snapshot-identifier<\/code>: \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u8b58\u5225\u5b50<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u95a2\u9023<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--vpc-security-group-ids<\/code>: \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7ID<\/li>\n\n\n\n<li><code>--master-username<\/code>: \u30de\u30b9\u30bf\u30fc\u30e6\u30fc\u30b6\u30fc\u540d<\/li>\n\n\n\n<li><code>--master-user-password<\/code>: \u30de\u30b9\u30bf\u30fc\u30d1\u30b9\u30ef\u30fc\u30c9<\/li>\n<\/ul>\n\n\n\n<p><strong>\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u306e\u30d2\u30f3\u30c8<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--dry-run<\/code>: \u5b9f\u969b\u306e\u5b9f\u884c\u306a\u3057\u3067\u69cb\u6587\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li><code>--generate-cli-skeleton<\/code>: JSON\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u751f\u6210<\/li>\n\n\n\n<li><code>--filters<\/code>: \u51fa\u529b\u7d50\u679c\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># JSON\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u751f\u6210\naws rds create-db-instance --generate-cli-skeleton &gt; create-instance.json\n\n# \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\naws rds create-db-instance --cli-input-json file:\/\/create-instance.json<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u3092\u62bc\u3055\u3048\u308b\u3053\u3068\u3067\u3001AWS CLI\u3092\u4f7f\u7528\u3057\u305fRDS\u306e\u52b9\u7387\u7684\u306a\u904b\u7528\u7ba1\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u305f\u5177\u4f53\u7684\u306a\u904b\u7528\u30b7\u30ca\u30ea\u30aa\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-4\">13\u306e\u5b9f\u8df5\u7684\u306aRDS\u64cd\u4f5c\u30b3\u30de\u30f3\u30c9\u5b9f\u4f8b<\/h2>\n\n\n\n<p>\u5b9f\u52d9\u3067\u983b\u7e41\u306b\u4f7f\u7528\u3055\u308c\u308b\u5177\u4f53\u7684\u306aRDS\u64cd\u4f5c\u30b3\u30de\u30f3\u30c9\u3092\u3001\u5b9f\u8df5\u7684\u306a\u30b7\u30ca\u30ea\u30aa\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\u30fb\u8d77\u52d5\u30fb\u505c\u6b62\u306e\u30b3\u30de\u30f3\u30c9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u672c\u756a\u74b0\u5883\u7528\u306eMySQL RDS\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u9ad8\u53ef\u7528\u6027\u306e\u672c\u756a\u74b0\u5883\u7528RDS\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\naws rds create-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --db-instance-class db.r5.xlarge \\\n    --engine mysql \\\n    --engine-version 8.0.28 \\\n    --master-username admin \\\n    --master-user-password \"YourSecurePassword123!\" \\\n    --allocated-storage 100 \\\n    --storage-type gp3 \\\n    --multi-az \\\n    --vpc-security-group-ids sg-1234567890abcdef0 \\\n    --backup-retention-period 7 \\\n    --preferred-backup-window \"03:00-04:00\" \\\n    --preferred-maintenance-window \"Mon:04:00-Mon:05:00\" \\\n    --tags Key=Environment,Value=Production\n\n# \u4f5c\u6210\u72b6\u6cc1\u306e\u78ba\u8a8d\naws rds describe-db-instances \\\n    --db-instance-identifier prod-mysql \\\n    --query 'DBInstances[0].DBInstanceStatus'<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4e00\u6642\u505c\u6b62\uff08\u958b\u767a\u74b0\u5883\u5411\u3051\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b3\u30b9\u30c8\u524a\u6e1b\u306e\u305f\u3081\u306e\u505c\u6b62\naws rds stop-db-instance \\\n    --db-instance-identifier dev-mysql\n\n# \u505c\u6b62\u72b6\u614b\u306e\u78ba\u8a8d\naws rds describe-db-instances \\\n    --db-instance-identifier dev-mysql \\\n    --query 'DBInstances[0].[DBInstanceStatus,DBInstanceClass]'<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u518d\u8d77\u52d5\uff08\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u5f8c\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u8a2d\u5b9a\u5909\u66f4\u3092\u53cd\u6620\u3059\u308b\u305f\u3081\u306e\u518d\u8d77\u52d5\naws rds reboot-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --force-failover\n\n# \u518d\u8d77\u52d5\u72b6\u6cc1\u306e\u76e3\u8996\naws rds describe-events \\\n    --source-identifier prod-mysql \\\n    --source-type db-instance \\\n    --duration 123<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3068\u30ea\u30b9\u30c8\u30a2\u306e\u30b3\u30de\u30f3\u30c9<\/h3>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>\u624b\u52d5\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e1\u30b8\u30e3\u30fc\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u524d\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\naws rds create-db-snapshot \\\n    --db-snapshot-identifier prod-mysql-pre-upgrade \\\n    --db-instance-identifier prod-mysql \\\n    --tags Key=Purpose,Value=PreUpgrade\n\n# \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u4f5c\u6210\u306e\u9032\u6357\u78ba\u8a8d\naws rds describe-db-snapshots \\\n    --db-snapshot-identifier prod-mysql-pre-upgrade \\\n    --query 'DBSnapshots[0].Status'<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304b\u3089\u306e\u5fa9\u5143<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3068\u3057\u3066\u30ea\u30b9\u30c8\u30a2\naws rds restore-db-instance-from-db-snapshot \\\n    --db-instance-identifier prod-mysql-restored \\\n    --db-snapshot-identifier prod-mysql-pre-upgrade \\\n    --db-instance-class db.r5.xlarge \\\n    --multi-az \\\n    --no-publicly-accessible\n\n# \u30ea\u30b9\u30c8\u30a2\u9032\u6357\u306e\u78ba\u8a8d\naws rds describe-db-instances \\\n    --db-instance-identifier prod-mysql-restored \\\n    --query 'DBInstances[0].DBInstanceStatus'<\/pre>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>\u7279\u5b9a\u6642\u70b9\u3078\u306e\u30ea\u30b9\u30c8\u30a2\uff08PITR\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u969c\u5bb3\u767a\u751f\u524d\u306e\u6642\u70b9\u3078\u30ea\u30b9\u30c8\u30a2\naws rds restore-db-instance-to-point-in-time \\\n    --source-db-instance-identifier prod-mysql \\\n    --target-db-instance-identifier prod-mysql-recovered \\\n    --restore-time \"2024-01-27T10:00:00Z\" \\\n    --use-latest-restorable-time<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u8a2d\u5b9a\u3068\u5909\u66f4\u30b3\u30de\u30f3\u30c9<\/h3>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u7528\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\naws rds create-db-parameter-group \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --db-parameter-group-family mysql8.0 \\\n    --description \"Custom performance parameters for MySQL 8.0\"\n\n# \u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u4e00\u62ec\u8a2d\u5b9a\naws rds modify-db-parameter-group \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --parameters \\\n    \"ParameterName=max_connections,ParameterValue=1000,ApplyMethod=immediate\" \\\n    \"ParameterName=innodb_buffer_pool_size,ParameterValue=4294967296,ApplyMethod=pending-reboot\"<\/pre>\n\n\n\n<ol start=\"8\" class=\"wp-block-list\">\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u9069\u7528<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u3092\u9069\u7528\naws rds modify-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --apply-immediately<\/pre>\n\n\n\n<ol start=\"9\" class=\"wp-block-list\">\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u73fe\u5728\u306e\u8a2d\u5b9a\u5024\u3092\u78ba\u8a8d\naws rds describe-db-parameters \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --query 'Parameters[?ParameterName==`max_connections`]'<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u30e1\u30c8\u30ea\u30af\u30b9\u53d6\u5f97\u306e\u30b3\u30de\u30f3\u30c9<\/h3>\n\n\n\n<ol start=\"10\" class=\"wp-block-list\">\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u53d6\u5f97<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># CPU\u4f7f\u7528\u7387\u306e\u78ba\u8a8d\naws cloudwatch get-metric-statistics \\\n    --namespace AWS\/RDS \\\n    --metric-name CPUUtilization \\\n    --dimensions Name=DBInstanceIdentifier,Value=prod-mysql \\\n    --start-time \"2024-01-27T00:00:00\" \\\n    --end-time \"2024-01-28T00:00:00\" \\\n    --period 300 \\\n    --statistics Average Maximum\n\n# \u63a5\u7d9a\u6570\u306e\u76e3\u8996\naws cloudwatch get-metric-statistics \\\n    --namespace AWS\/RDS \\\n    --metric-name DatabaseConnections \\\n    --dimensions Name=DBInstanceIdentifier,Value=prod-mysql \\\n    --start-time \"2024-01-27T00:00:00\" \\\n    --end-time \"2024-01-28T00:00:00\" \\\n    --period 300 \\\n    --statistics Average<\/pre>\n\n\n\n<ol start=\"11\" class=\"wp-block-list\">\n<li>\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u53d6\u5f97<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u5229\u7528\u53ef\u80fd\u306a\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u4e00\u89a7\u8868\u793a\naws rds describe-db-log-files \\\n    --db-instance-identifier prod-mysql\n\n# \u7279\u5b9a\u306e\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u53d6\u5f97\naws rds download-db-log-file-portion \\\n    --db-instance-identifier prod-mysql \\\n    --log-file-name error\/mysql-error.log \\\n    --output text<\/pre>\n\n\n\n<ol start=\"12\" class=\"wp-block-list\">\n<li>\u62e1\u5f35\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306e\u6709\u52b9\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u62e1\u5f35\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u5316\uff08\u3088\u308a\u8a73\u7d30\u306a\u30e1\u30c8\u30ea\u30af\u30b9\u53d6\u5f97\uff09\naws rds modify-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --monitoring-interval 60 \\\n    --monitoring-role-arn arn:aws:iam::123456789012:role\/rds-monitoring-role<\/pre>\n\n\n\n<ol start=\"13\" class=\"wp-block-list\">\n<li>\u30b9\u30ed\u30fc\u30af\u30a8\u30ea\u30ed\u30b0\u306e\u8a2d\u5b9a<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b9\u30ed\u30fc\u30af\u30a8\u30ea\u30ed\u30b0\u3092\u6709\u52b9\u5316\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u8a2d\u5b9a\naws rds modify-db-parameter-group \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --parameters \\\n    \"ParameterName=slow_query_log,ParameterValue=1,ApplyMethod=immediate\" \\\n    \"ParameterName=long_query_time,ParameterValue=2,ApplyMethod=immediate\"<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u5b9f\u969b\u306e\u904b\u7528\u30b7\u30fc\u30f3\u3067\u4f7f\u7528\u3055\u308c\u308b\u4ee3\u8868\u7684\u306a\u4f8b\u3067\u3059\u3002\u5404\u30b3\u30de\u30f3\u30c9\u306f\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8abf\u6574\u3057\u3066\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001\u672c\u756a\u74b0\u5883\u3067\u306e\u5b9f\u884c\u6642\u306f\u5341\u5206\u306a\u30c6\u30b9\u30c8\u3068\u5f71\u97ff\u78ba\u8a8d\u3092\u884c\u3046\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">AWS CLI\u3092\u4f7f\u3063\u305fRDS\u306e\u81ea\u52d5\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<p>RDS\u306e\u904b\u7528\u7ba1\u7406\u3092\u52b9\u7387\u5316\u3059\u308b\u305f\u3081\u306e\u81ea\u52d5\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u3001\u5177\u4f53\u7684\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30b9\u30af\u30ea\u30d7\u30c8\u30b7\u30a7\u30eb\u306b\u3088\u308b\u5b9a\u671f\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u81ea\u52d5\u5316<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u72b6\u614b\u30c1\u30a7\u30c3\u30af\u3068\u518d\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u72b6\u614b\u30c1\u30a7\u30c3\u30af\u3068\u5fc5\u8981\u306b\u5fdc\u3058\u305f\u518d\u8d77\u52d5\u3092\u884c\u3046\u30b9\u30af\u30ea\u30d7\u30c8\nINSTANCE_ID=\"prod-mysql\"\nMAX_UPTIME_DAYS=30\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8d77\u52d5\u6642\u9593\u3092\u53d6\u5f97\nuptime=$(aws rds describe-db-instances \\\n    --db-instance-identifier $INSTANCE_ID \\\n    --query 'DBInstances[0].InstanceCreateTime' \\\n    --output text)\n\n# \u73fe\u5728\u6642\u523b\u3068\u306e\u5dee\u5206\u3092\u8a08\u7b97\ncurrent_time=$(date -u +\"%Y-%m-%dT%H:%M:%SZ\")\nuptime_seconds=$(( $(date -d \"$current_time\" +%s) - $(date -d \"$uptime\" +%s) ))\nuptime_days=$(( uptime_seconds \/ 86400 ))\n\n# \u8a2d\u5b9a\u3055\u308c\u305f\u671f\u9593\u3092\u8d85\u3048\u3066\u3044\u308b\u5834\u5408\u306f\u518d\u8d77\u52d5\nif [ $uptime_days -gt $MAX_UPTIME_DAYS ]; then\n    echo \"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u7a3c\u50cd\u6642\u9593\u304c${MAX_UPTIME_DAYS}\u65e5\u3092\u8d85\u3048\u3066\u3044\u307e\u3059\u3002\u518d\u8d77\u52d5\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\"\n\n    # \u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30a6\u30a3\u30f3\u30c9\u30a6\u5185\u304b\u30c1\u30a7\u30c3\u30af\n    current_hour=$(date +%H)\n    if [ $current_hour -ge 2 ] &amp;&amp; [ $current_hour -lt 5 ]; then\n        aws rds reboot-db-instance \\\n            --db-instance-identifier $INSTANCE_ID\n        echo \"\u518d\u8d77\u52d5\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3057\u305f\u3002\"\n    else\n        echo \"\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30a6\u30a3\u30f3\u30c9\u30a6\u5916\u306e\u305f\u3081\u3001\u518d\u8d77\u52d5\u3092\u30b9\u30ad\u30c3\u30d7\u3057\u307e\u3059\u3002\"\n    fi\nelse\n    echo \"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u7a3c\u50cd\u6642\u9593\u306f${uptime_days}\u65e5\u3067\u3059\u3002\u518d\u8d77\u52d5\u306f\u4e0d\u8981\u3067\u3059\u3002\"\nfi<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u5b9a\u671f\u76e3\u67fb\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u8a2d\u5b9a\u5024\u3092\u76e3\u67fb\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\nPARAM_GROUP=\"custom-mysql8-perf\"\nAUDIT_FILE=\"parameter_audit_$(date +%Y%m%d).csv\"\n\n# \u30d8\u30c3\u30c0\u30fc\u884c\u3092\u4f5c\u6210\necho \"Parameter,CurrentValue,AllowedValues,Description,ApplyType\" &gt; $AUDIT_FILE\n\n# \u30d1\u30e9\u30e1\u30fc\u30bf\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066 CSV \u5f62\u5f0f\u3067\u51fa\u529b\naws rds describe-db-parameters \\\n    --db-parameter-group-name $PARAM_GROUP \\\n    --query 'Parameters[].[ParameterName,ParameterValue,AllowedValues,Description,ApplyMethod]' \\\n    --output text | while read -r line; do\n    echo \"$line\" | tr '\\t' ',' &gt;&gt; $AUDIT_FILE\ndone\n\n# \u91cd\u8981\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5024\u3092\u30c1\u30a7\u30c3\u30af\ncritical_params=(\"max_connections\" \"innodb_buffer_pool_size\" \"slow_query_log\")\necho \"\u91cd\u8981\u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30a7\u30c3\u30af\u7d50\u679c\uff1a\"\nfor param in \"${critical_params[@]}\"; do\n    value=$(aws rds describe-db-parameters \\\n        --db-parameter-group-name $PARAM_GROUP \\\n        --query \"Parameters[?ParameterName=='$param'].ParameterValue\" \\\n        --output text)\n    echo \"$param: $value\"\ndone<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u4f5c\u6210\u306e\u81ea\u52d5\u5316\u3068\u4e16\u4ee3\u7ba1\u7406<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u4f5c\u6210\u3068\u53e4\u3044\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u524a\u9664\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u81ea\u52d5\u5316\u3068\u4e16\u4ee3\u7ba1\u7406\u3092\u884c\u3046\u30b9\u30af\u30ea\u30d7\u30c8\nINSTANCE_ID=\"prod-mysql\"\nRETENTION_DAYS=30\nSNAPSHOT_PREFIX=\"automated\"\n\n# \u65b0\u3057\u3044\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210\ntimestamp=$(date +%Y-%m-%d-%H-%M)\nsnapshot_id=\"${SNAPSHOT_PREFIX}-${INSTANCE_ID}-${timestamp}\"\n\necho \"\u65b0\u3057\u3044\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u4e2d: $snapshot_id\"\naws rds create-db-snapshot \\\n    --db-snapshot-identifier $snapshot_id \\\n    --db-instance-identifier $INSTANCE_ID \\\n    --tags Key=AutoBackup,Value=true\n\n# \u53e4\u3044\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u524a\u9664\necho \"\u671f\u9650\u5207\u308c\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u691c\u7d22\u4e2d...\"\naws rds describe-db-snapshots \\\n    --query \"DBSnapshots[?DBInstanceIdentifier=='$INSTANCE_ID']\" \\\n    --output json | jq -r '.[] | select(.Tags[].Key==\"AutoBackup\") | .DBSnapshotIdentifier' | while read -r old_snapshot; do\n\n    creation_date=$(aws rds describe-db-snapshots \\\n        --db-snapshot-identifier $old_snapshot \\\n        --query 'DBSnapshots[0].SnapshotCreateTime' \\\n        --output text)\n\n    # \u4f5c\u6210\u65e5\u304b\u3089\u306e\u7d4c\u904e\u65e5\u6570\u3092\u8a08\u7b97\n    days_old=$(( ( $(date +%s) - $(date -d \"$creation_date\" +%s) ) \/ 86400 ))\n\n    if [ $days_old -gt $RETENTION_DAYS ]; then\n        echo \"\u524a\u9664: $old_snapshot (\u4f5c\u6210\u304b\u3089${days_old}\u65e5\u7d4c\u904e)\"\n        aws rds delete-db-snapshot \\\n            --db-snapshot-identifier $old_snapshot\n    fi\ndone<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u7d50\u679c\u306e\u901a\u77e5\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u7d50\u679c\u3092 SNS \u3067\u901a\u77e5\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\nINSTANCE_ID=\"prod-mysql\"\nSNS_TOPIC_ARN=\"arn:aws:sns:region:account-id:backup-notification\"\n\n# \u6700\u65b0\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u60c5\u5831\u3092\u53d6\u5f97\nlatest_snapshot=$(aws rds describe-db-snapshots \\\n    --db-instance-identifier $INSTANCE_ID \\\n    --query 'DBSnapshots[*].[DBSnapshotIdentifier,SnapshotCreateTime,Status]' \\\n    --output text | sort -k2 -r | head -n 1)\n\n# \u901a\u77e5\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u4f5c\u6210\nsnapshot_id=$(echo $latest_snapshot | cut -f1)\ncreate_time=$(echo $latest_snapshot | cut -f2)\nstatus=$(echo $latest_snapshot | cut -f3)\n\nmessage=\"RDS Backup Status Report\\n\"\nmessage+=\"Instance: $INSTANCE_ID\\n\"\nmessage+=\"Snapshot: $snapshot_id\\n\"\nmessage+=\"Created: $create_time\\n\"\nmessage+=\"Status: $status\"\n\n# SNS \u901a\u77e5\u306e\u9001\u4fe1\naws sns publish \\\n    --topic-arn $SNS_TOPIC_ARN \\\n    --message \"$message\" \\\n    --subject \"RDS Backup Report - $INSTANCE_ID\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">CloudWatch\u3068\u9023\u643a\u3057\u305f\u76e3\u8996\u306e\u81ea\u52d5\u5316<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30c8\u30ea\u30af\u30b9\u30a2\u30e9\u30fc\u30e0\u8a2d\u5b9a\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# CloudWatch \u30a2\u30e9\u30fc\u30e0\u3092\u4e00\u62ec\u8a2d\u5b9a\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\nINSTANCE_ID=\"prod-mysql\"\nSNS_TOPIC_ARN=\"arn:aws:sns:region:account-id:rds-alerts\"\n\n# CPU \u4f7f\u7528\u7387\u30a2\u30e9\u30fc\u30e0\naws cloudwatch put-metric-alarm \\\n    --alarm-name \"${INSTANCE_ID}-high-cpu\" \\\n    --alarm-description \"CPU\u4f7f\u7528\u7387\u304c80%\u3092\u8d85\u904e\" \\\n    --metric-name CPUUtilization \\\n    --namespace AWS\/RDS \\\n    --statistic Average \\\n    --period 300 \\\n    --threshold 80 \\\n    --comparison-operator GreaterThanThreshold \\\n    --evaluation-periods 3 \\\n    --dimensions Name=DBInstanceIdentifier,Value=$INSTANCE_ID \\\n    --alarm-actions $SNS_TOPIC_ARN\n\n# \u7a7a\u304d\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30e9\u30fc\u30e0\naws cloudwatch put-metric-alarm \\\n    --alarm-name \"${INSTANCE_ID}-low-storage\" \\\n    --alarm-description \"\u7a7a\u304d\u30b9\u30c8\u30ec\u30fc\u30b8\u304c20%\u672a\u6e80\" \\\n    --metric-name FreeStorageSpace \\\n    --namespace AWS\/RDS \\\n    --statistic Average \\\n    --period 300 \\\n    --threshold 20 \\\n    --comparison-operator LessThanThreshold \\\n    --evaluation-periods 3 \\\n    --dimensions Name=DBInstanceIdentifier,Value=$INSTANCE_ID \\\n    --alarm-actions $SNS_TOPIC_ARN\n\n# \u63a5\u7d9a\u6570\u30a2\u30e9\u30fc\u30e0\naws cloudwatch put-metric-alarm \\\n    --alarm-name \"${INSTANCE_ID}-high-connections\" \\\n    --alarm-description \"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u6570\u304c\u95be\u5024\u3092\u8d85\u904e\" \\\n    --metric-name DatabaseConnections \\\n    --namespace AWS\/RDS \\\n    --statistic Average \\\n    --period 300 \\\n    --threshold 100 \\\n    --comparison-operator GreaterThanThreshold \\\n    --evaluation-periods 3 \\\n    --dimensions Name=DBInstanceIdentifier,Value=$INSTANCE_ID \\\n    --alarm-actions $SNS_TOPIC_ARN<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30e1\u30c8\u30ea\u30af\u30b9\u53ce\u96c6\u30b9\u30af\u30ea\u30d7\u30c8<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# RDS\u306e\u8a73\u7d30\u30e1\u30c8\u30ea\u30af\u30b9\u3092\u53ce\u96c6\u3057\u3066CloudWatch\u306b\u9001\u4fe1\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\nINSTANCE_ID=\"prod-mysql\"\nNAMESPACE=\"Custom\/RDS\"\n\n# \u30b9\u30ed\u30fc\u30af\u30a8\u30ea\u306e\u6570\u3092\u53d6\u5f97\nslow_queries=$(aws rds download-db-log-file-portion \\\n    --db-instance-identifier $INSTANCE_ID \\\n    --log-file-name slowquery\/mysql-slowquery.log \\\n    --output text | grep -c \"Query_time:\")\n\n# \u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9045\u5ef6\u3092\u53d6\u5f97\uff08\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u306e\u5834\u5408\uff09\nreplication_lag=$(aws rds describe-db-instances \\\n    --db-instance-identifier $INSTANCE_ID \\\n    --query 'DBInstances[0].ReadReplicaSourceDBInstanceIdentifier' \\\n    --output text)\n\nif [ \"$replication_lag\" != \"None\" ]; then\n    lag_seconds=$(aws cloudwatch get-metric-statistics \\\n        --namespace AWS\/RDS \\\n        --metric-name ReplicaLag \\\n        --dimensions Name=DBInstanceIdentifier,Value=$INSTANCE_ID \\\n        --start-time $(date -u +\"%Y-%m-%dT%H:%M:%SZ\" --date \"5 minutes ago\") \\\n        --end-time $(date -u +\"%Y-%m-%dT%H:%M:%SZ\") \\\n        --period 300 \\\n        --statistics Average \\\n        --query 'Datapoints[0].Average' \\\n        --output text)\nfi\n\n# \u30ab\u30b9\u30bf\u30e0\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u9001\u4fe1\naws cloudwatch put-metric-data \\\n    --namespace $NAMESPACE \\\n    --metric-data \\\n    MetricName=SlowQueries,Value=$slow_queries,Unit=Count,Dimensions=[{Name=DBInstanceIdentifier,Value=$INSTANCE_ID}]\n\nif [ \"$replication_lag\" != \"None\" ]; then\n    aws cloudwatch put-metric-data \\\n        --namespace $NAMESPACE \\\n        --metric-data \\\n        MetricName=ReplicationLagSeconds,Value=$lag_seconds,Unit=Seconds,Dimensions=[{Name=DBInstanceIdentifier,Value=$INSTANCE_ID}]\nfi<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001crontab\u3084AWS Systems Manager\u306e\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u4f7f\u7528\u3057\u3066\u5b9a\u671f\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u672c\u756a\u74b0\u5883\u3067\u306e\u4f7f\u7528\u524d\u306b\u3001\u30c6\u30b9\u30c8\u74b0\u5883\u3067\u306e\u5341\u5206\u306a\u691c\u8a3c\u3092\u884c\u3046\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u6a29\u9650\u3084\u5fc5\u8981\u306aIAM\u30ed\u30fc\u30eb\u306e\u8a2d\u5b9a\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3001\u30ed\u30b0\u51fa\u529b\u306e\u5b9f\u88c5\u3082\u5fd8\u308c\u305a\u306b\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-13\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n\n\n\n<p>AWS CLI\u3092\u4f7f\u7528\u3057\u305fRDS\u904b\u7528\u306b\u304a\u3051\u308b\u4e00\u822c\u7684\u306a\u554f\u984c\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5\u3001\u304a\u3088\u3073\u52b9\u7387\u7684\u306a\u904b\u7528\u306e\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8a8d\u8a3c\u95a2\u9023\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ol>\n\n\n\n<p><strong>\u30a8\u30e9\u30fc\u4f8b1: \u8a8d\u8a3c\u60c5\u5831\u304c\u898b\u3064\u304b\u3089\u306a\u3044<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">An error occurred (NoCredentialsError) when calling the DescribeDBInstances operation: Unable to locate credentials<\/pre>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u6cd5:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u8a8d\u8a3c\u60c5\u5831\u306e\u8a2d\u5b9a\u72b6\u614b\u3092\u78ba\u8a8d\naws configure list\n\n# \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8a8d\u8a3c\u60c5\u5831\u3092\u518d\u8a2d\u5b9a\naws configure set aws_access_key_id YOUR_ACCESS_KEY\naws configure set aws_secret_access_key YOUR_SECRET_KEY\naws configure set region ap-northeast-1\n\n# \u307e\u305f\u306f\u3001\u74b0\u5883\u5909\u6570\u3067\u4e00\u6642\u7684\u306b\u8a2d\u5b9a\nexport AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY\nexport AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY\nexport AWS_DEFAULT_REGION=ap-northeast-1<\/pre>\n\n\n\n<p><strong>\u30a8\u30e9\u30fc\u4f8b2: \u6a29\u9650\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">An error occurred (AccessDenied) when calling the CreateDBInstance operation: User: arn:aws:iam::123456789012:user\/username is not authorized to perform: rds:CreateDBInstance<\/pre>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u6cd5:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u73fe\u5728\u306e IAM \u30e6\u30fc\u30b6\u30fc\u306e\u6a29\u9650\u3092\u78ba\u8a8d\naws iam get-user\naws iam list-attached-user-policies --user-name your-username\n\n# \u5fc5\u8981\u306a\u6a29\u9650\u3092\u6301\u3064\u30dd\u30ea\u30b7\u30fc\u3092\u4ed8\u4e0e\naws iam attach-user-policy \\\n    --user-name your-username \\\n    --policy-arn arn:aws:iam::aws:policy\/AmazonRDSFullAccess<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u95a2\u9023\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ol>\n\n\n\n<p><strong>\u30a8\u30e9\u30fc\u4f8b3: \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u64cd\u4f5c\u306e\u5931\u6557<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">An error occurred (InvalidDBInstanceState) when calling the StopDBInstance operation: Cannot stop instance prod-mysql because instance is not in available state.<\/pre>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u6cd5:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u73fe\u5728\u306e\u72b6\u614b\u3092\u78ba\u8a8d\naws rds describe-db-instances \\\n    --db-instance-identifier prod-mysql \\\n    --query 'DBInstances[0].DBInstanceStatus'\n\n# \u4fdd\u7559\u4e2d\u306e\u64cd\u4f5c\u304c\u3042\u308b\u304b\u78ba\u8a8d\naws rds describe-pending-maintenance-actions \\\n    --filters Name=db-instance-id,Values=prod-mysql\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30a4\u30d9\u30f3\u30c8\u5c65\u6b74\u3092\u78ba\u8a8d\naws rds describe-events \\\n    --source-identifier prod-mysql \\\n    --source-type db-instance \\\n    --duration 60<\/pre>\n\n\n\n<p><strong>\u30a8\u30e9\u30fc\u4f8b4: \u30d1\u30e9\u30e1\u30fc\u30bf\u5909\u66f4\u306e\u5931\u6557<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">An error occurred (InvalidParameterValue) when calling the ModifyDBParameterGroup operation: Cannot modify parameter max_connections. Value 5000 is outside of valid range: [1-3000]<\/pre>\n\n\n\n<p>\u89e3\u6c7a\u65b9\u6cd5:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u6709\u52b9\u7bc4\u56f2\u3092\u78ba\u8a8d\naws rds describe-db-parameters \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --query 'Parameters[?ParameterName==`max_connections`]'\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30af\u30e9\u30b9\u306b\u5fdc\u3058\u305f\u9069\u5207\u306a\u5024\u3092\u8a2d\u5b9a\naws rds modify-db-parameter-group \\\n    --db-parameter-group-name custom-mysql8-perf \\\n    --parameters \"ParameterName=max_connections,ParameterValue=3000,ApplyMethod=immediate\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8003\u616e\u3057\u305fIAM\u30dd\u30ea\u30b7\u30fc\u8a2d\u5b9a<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6700\u5c0f\u6a29\u9650\u306e\u539f\u5247\u306b\u57fa\u3065\u304fIAM\u30dd\u30ea\u30b7\u30fc\u4f8b<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"AllowSpecificRDSActions\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"rds:DescribeDBInstances\",\n                \"rds:StartDBInstance\",\n                \"rds:StopDBInstance\",\n                \"rds:RebootDBInstance\"\n            ],\n            \"Resource\": \"arn:aws:rds:region:account-id:db:prod-*\"\n        },\n        {\n            \"Sid\": \"AllowParameterGroupModification\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"rds:DescribeDBParameterGroups\",\n                \"rds:DescribeDBParameters\",\n                \"rds:ModifyDBParameterGroup\"\n            ],\n            \"Resource\": \"arn:aws:rds:region:account-id:pg:custom-*\"\n        },\n        {\n            \"Sid\": \"AllowSnapshotOperations\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"rds:CreateDBSnapshot\",\n                \"rds:DescribeDBSnapshots\",\n                \"rds:DeleteDBSnapshot\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"AllowTagging\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"rds:AddTagsToResource\",\n                \"rds:ListTagsForResource\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u8a2d\u5b9a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\naws ec2 create-security-group \\\n    --group-name rds-secure-access \\\n    --description \"Security group for RDS secure access\"\n\n# \u5fc5\u8981\u6700\u5c0f\u9650\u306e\u30a4\u30f3\u30d0\u30a6\u30f3\u30c9\u30eb\u30fc\u30eb\u8a2d\u5b9a\naws ec2 authorize-security-group-ingress \\\n    --group-name rds-secure-access \\\n    --protocol tcp \\\n    --port 3306 \\\n    --cidr 10.0.0.0\/16\n\n# \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u9069\u7528\naws rds modify-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --vpc-security-group-ids sg-1234567890abcdef0<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u5927\u898f\u6a21\u74b0\u5883\u3067\u306e\u904b\u7528\u7ba1\u7406\u306e\u30b3\u30c4<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u30bf\u30b0\u3092\u6d3b\u7528\u3057\u305f\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30bf\u30b0\u4ed8\u3051\u306e\u4e00\u8cab\u6027\u3092\u4fdd\u3064\naws rds add-tags-to-resource \\\n    --resource-name arn:aws:rds:region:account-id:db:prod-mysql \\\n    --tags \\\n    Key=Environment,Value=Production \\\n    Key=Department,Value=Engineering \\\n    Key=CostCenter,Value=12345\n\n# \u30bf\u30b0\u30d9\u30fc\u30b9\u3067\u306e\u30ea\u30bd\u30fc\u30b9\u691c\u7d22\naws rds describe-db-instances \\\n    --filters Name=tag:Environment,Values=Production \\\n    --query 'DBInstances[*].[DBInstanceIdentifier,TagList]'<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u52b9\u7387\u7684\u306a\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u6226\u7565<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u91cd\u8981\u306a\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u30a2\u30e9\u30fc\u30e0\u8a2d\u5b9a\naws cloudwatch put-metric-alarm \\\n    --alarm-name RDS-HighCPU \\\n    --metric-name CPUUtilization \\\n    --namespace AWS\/RDS \\\n    --statistic Average \\\n    --period 300 \\\n    --threshold 80 \\\n    --comparison-operator GreaterThanThreshold \\\n    --evaluation-periods 2 \\\n    --dimensions Name=DBInstanceIdentifier,Value=prod-mysql \\\n    --alarm-actions arn:aws:sns:region:account-id:alert-topic\n\n# \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30a4\u30f3\u30b5\u30a4\u30c8\u306e\u6709\u52b9\u5316\naws rds modify-db-instance \\\n    --db-instance-identifier prod-mysql \\\n    --enable-performance-insights \\\n    --performance-insights-retention-period 7<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u5927\u898f\u6a21\u74b0\u5883\u3067\u306e\u904b\u7528\u52b9\u7387\u5316\u306e\u305f\u3081\u306eTips<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30c1\u64cd\u4f5c\u306e\u6d3b\u7528:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u8907\u6570\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4e00\u62ec\u64cd\u4f5c\nfor instance in $(aws rds describe-db-instances --query 'DBInstances[?TagList[?Key==`Environment` &amp;&amp; Value==`Production`]].DBInstanceIdentifier' --output text); do\n    echo \"Processing $instance...\"\n    aws rds create-db-snapshot \\\n        --db-snapshot-identifier \"${instance}-$(date +%Y%m%d)\" \\\n        --db-instance-identifier $instance\ndone<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u5236\u9650\u306e\u7ba1\u7406:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30b5\u30fc\u30d3\u30b9\u5236\u9650\u306e\u78ba\u8a8d\naws service-quotas get-service-quota \\\n    --service-code rds \\\n    --quota-code L-7B6409FD\n\n# \u5236\u9650\u7de9\u548c\u30ea\u30af\u30a8\u30b9\u30c8\naws service-quotas request-service-quota-increase \\\n    --service-code rds \\\n    --quota-code L-7B6409FD \\\n    --desired-value 100<\/pre>\n\n\n\n<p>\u904b\u7528\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9a\u671f\u7684\u306a\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u9069\u5207\u306a\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30d1\u30c3\u30c1\u9069\u7528\u306e\u81ea\u52d5\u5316<\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u306e\u5b9a\u671f\u7684\u306a\u898b\u76f4\u3057<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6226\u7565<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u5b9a\u671f\u7684\u306a\u30ea\u30b9\u30c8\u30a2\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u30af\u30ed\u30b9\u30ea\u30fc\u30b8\u30e7\u30f3\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u691c\u8a0e<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u3068\u901a\u77e5<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u91cd\u8981\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30a2\u30e9\u30fc\u30c8\u95be\u5024\u306e\u9069\u5207\u306a\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a4\u30f3\u30b7\u30c7\u30f3\u30c8\u5bfe\u5fdc\u30d7\u30ed\u30bb\u30b9\u306e\u78ba\u7acb<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9a\u671f\u7684\u306a\u8a8d\u8a3c\u60c5\u5831\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30d1\u30c3\u30c1\u306e\u8fc5\u901f\u306a\u9069\u7528<\/li>\n\n\n\n<li>\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u306e\u5b9a\u671f\u7684\u306a\u898b\u76f4\u3057<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u74b0\u5883\u3067\u3082\u52b9\u7387\u7684\u304b\u3064\u5b89\u5168\u306aRDS\u904b\u7528\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-17\">\u767a\u5c55RDS\u904b\u7528\u7ba1\u7406\u624b\u6cd5<\/h2>\n\n\n\n<p>\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u306b\u304a\u3051\u308bRDS\u306e\u52b9\u7387\u7684\u306a\u904b\u7528\u7ba1\u7406\u624b\u6cd5\u3068\u3001CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3068\u306e\u7d71\u5408\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u8907\u6570\u74b0\u5883\u306e\u4e00\u62ec\u7ba1\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u74b0\u5883\u5225\u306e\u8a2d\u5b9a\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n# \u74b0\u5883\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\uff08env-config.json\uff09\n{\n    \"development\": {\n        \"instance_class\": \"db.t3.medium\",\n        \"multi_az\": false,\n        \"backup_retention\": 7,\n        \"parameter_group\": \"dev-mysql8-params\"\n    },\n    \"staging\": {\n        \"instance_class\": \"db.r5.large\",\n        \"multi_az\": true,\n        \"backup_retention\": 14,\n        \"parameter_group\": \"staging-mysql8-params\"\n    },\n    \"production\": {\n        \"instance_class\": \"db.r5.xlarge\",\n        \"multi_az\": true,\n        \"backup_retention\": 30,\n        \"parameter_group\": \"prod-mysql8-params\"\n    }\n}\n\n# \u74b0\u5883\u5225\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\u30b9\u30af\u30ea\u30d7\u30c8\n#!\/bin\/bash\n\nENV=$1\nCONFIG_FILE=\"env-config.json\"\n\n# \u8a2d\u5b9a\u306e\u8aad\u307f\u8fbc\u307f\ninstance_class=$(jq -r \".$ENV.instance_class\" $CONFIG_FILE)\nmulti_az=$(jq -r \".$ENV.multi_az\" $CONFIG_FILE)\nbackup_retention=$(jq -r \".$ENV.backup_retention\" $CONFIG_FILE)\nparameter_group=$(jq -r \".$ENV.parameter_group\" $CONFIG_FILE)\n\n# \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\naws rds create-db-instance \\\n    --db-instance-identifier \"${ENV}-mysql\" \\\n    --db-instance-class $instance_class \\\n    --engine mysql \\\n    --multi-az $multi_az \\\n    --backup-retention-period $backup_retention \\\n    --db-parameter-group-name $parameter_group \\\n    --tags Key=Environment,Value=$ENV<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u74b0\u5883\u9593\u306e\u30c7\u30fc\u30bf\u540c\u671f<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n# \u958b\u767a\u74b0\u5883\u3078\u306e\u672c\u756a\u30c7\u30fc\u30bf\u306e\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u30b9\u30af\u30ea\u30d7\u30c8\n\n# \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u4f5c\u6210\naws rds create-db-snapshot \\\n    --db-instance-identifier prod-mysql \\\n    --db-snapshot-identifier prod-snapshot-$(date +%Y%m%d)\n\n# \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306e\u5b8c\u4e86\u3092\u5f85\u6a5f\naws rds wait db-snapshot-available \\\n    --db-snapshot-identifier prod-snapshot-$(date +%Y%m%d)\n\n# \u958b\u767a\u74b0\u5883\u306e\u505c\u6b62\naws rds stop-db-instance \\\n    --db-instance-identifier dev-mysql\n\n# \u958b\u767a\u74b0\u5883\u306e\u524a\u9664\uff08\u5f85\u6a5f\uff09\naws rds delete-db-instance \\\n    --db-instance-identifier dev-mysql \\\n    --skip-final-snapshot\naws rds wait db-instance-deleted \\\n    --db-instance-identifier dev-mysql\n\n# \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304b\u3089\u958b\u767a\u74b0\u5883\u3092\u5fa9\u5143\naws rds restore-db-instance-from-db-snapshot \\\n    --db-instance-identifier dev-mysql \\\n    --db-snapshot-identifier prod-snapshot-$(date +%Y%m%d) \\\n    --db-instance-class db.t3.medium \\\n    --no-multi-az\n\n# \u30c7\u30fc\u30bf\u30de\u30b9\u30ad\u30f3\u30b0\u306e\u9069\u7528\uff08\u5fc5\u8981\u306b\u5fdc\u3058\u3066\uff09\nmysql -h dev-mysql-endpoint -u admin -p &lt; mask_sensitive_data.sql<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u30ea\u30bd\u30fc\u30b9\u4f7f\u7528\u72b6\u6cc1\u306e\u4e00\u62ec\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n# \u5168\u74b0\u5883\u306e\u30ea\u30bd\u30fc\u30b9\u4f7f\u7528\u72b6\u6cc1\u30ec\u30dd\u30fc\u30c8\u751f\u6210\n\n# \u76e3\u8996\u5bfe\u8c61\u306e\u74b0\u5883\u30ea\u30b9\u30c8\nenvironments=(\"development\" \"staging\" \"production\")\n\nreport_file=\"rds_usage_report_$(date +%Y%m%d).csv\"\necho \"Environment,Instance,CPU Usage,Memory Usage,Storage Usage,Connections\" &gt; $report_file\n\nfor env in \"${environments[@]}\"; do\n    instances=$(aws rds describe-db-instances \\\n        --query \"DBInstances[?Tags[?Key=='Environment' &amp;&amp; Value=='$env']].DBInstanceIdentifier\" \\\n        --output text)\n\n    for instance in $instances; do\n        # CPU\u4f7f\u7528\u7387\n        cpu=$(aws cloudwatch get-metric-statistics \\\n            --namespace AWS\/RDS \\\n            --metric-name CPUUtilization \\\n            --dimensions Name=DBInstanceIdentifier,Value=$instance \\\n            --start-time \"$(date -u -d '1 hour ago' '+%Y-%m-%dT%H:%M:%S')\" \\\n            --end-time \"$(date -u '+%Y-%m-%dT%H:%M:%S')\" \\\n            --period 3600 \\\n            --statistics Average \\\n            --query 'Datapoints[0].Average' \\\n            --output text)\n\n        # \u305d\u306e\u4ed6\u306e\u30e1\u30c8\u30ea\u30af\u30b9\u3082\u540c\u69d8\u306b\u53d6\u5f97\n        echo \"$env,$instance,$cpu,...\" &gt;&gt; $report_file\n    done\ndone<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">CI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3068\u306e\u7d71\u5408\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>GitHubActions\u3067\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u66f4\u65b0\u81ea\u52d5\u5316<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># .github\/workflows\/db-migration.yml\nname: Database Migration\non:\n  push:\n    branches: [ main ]\n    paths:\n      - 'db\/migrations\/**'\n\njobs:\n  migrate:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        environment: [staging, production]\n\n    steps:\n      - uses: actions\/checkout@v2\n\n      - name: Configure AWS credentials\n        uses: aws-actions\/configure-aws-credentials@v1\n        with:\n          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}\n          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n          aws-region: ap-northeast-1\n\n      - name: Execute DB Migration\n        run: |\n          # \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\n          for script in db\/migrations\/*.sql; do\n            aws rds-data execute-statement \\\n              --resource-arn ${{ secrets.DB_CLUSTER_ARN }} \\\n              --secret-arn ${{ secrets.DB_SECRET_ARN }} \\\n              --database myapp \\\n              --sql \"$(cat $script)\"\n          done<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u306e\u30b3\u30fc\u30c9\u5316\uff08Terraform\u4f8b\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># main.tf\nprovider \"aws\" {\n  region = \"ap-northeast-1\"\n}\n\nmodule \"rds\" {\n  source = \".\/modules\/rds\"\n\n  for_each = {\n    development = {\n      instance_class    = \"db.t3.medium\"\n      multi_az         = false\n      backup_retention = 7\n    }\n    staging = {\n      instance_class    = \"db.r5.large\"\n      multi_az         = true\n      backup_retention = 14\n    }\n    production = {\n      instance_class    = \"db.r5.xlarge\"\n      multi_az         = true\n      backup_retention = 30\n    }\n  }\n\n  environment      = each.key\n  instance_class   = each.value.instance_class\n  multi_az         = each.value.multi_az\n  backup_retention = each.value.backup_retention\n\n  tags = {\n    Environment = each.key\n    ManagedBy   = \"Terraform\"\n  }\n}\n\n# modules\/rds\/main.tf\nresource \"aws_db_instance\" \"mysql\" {\n  identifier        = \"${var.environment}-mysql\"\n  instance_class    = var.instance_class\n  engine           = \"mysql\"\n  engine_version   = \"8.0\"\n  multi_az         = var.multi_az\n\n  backup_retention_period = var.backup_retention\n\n  tags = var.tags\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u81ea\u52d5\u5316\u3055\u308c\u305f\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u69cb\u7bc9<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n# \u30c6\u30b9\u30c8\u74b0\u5883\u306e\u81ea\u52d5\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u30b9\u30af\u30ea\u30d7\u30c8\n\n# \u30c6\u30b9\u30c8\u7528\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\naws rds create-db-parameter-group \\\n    --db-parameter-group-name test-mysql8-params \\\n    --db-parameter-group-family mysql8.0 \\\n    --description \"Parameters for automated testing\"\n\n# \u30c6\u30b9\u30c8\u7528\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\naws rds create-db-instance \\\n    --db-instance-identifier test-mysql \\\n    --db-instance-class db.t3.medium \\\n    --engine mysql \\\n    --master-username test_admin \\\n    --master-user-password \"TestPassword123!\" \\\n    --db-parameter-group-name test-mysql8-params \\\n    --tags Key=Purpose,Value=Testing\n\n# \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u30ed\u30fc\u30c9\nmysql -h test-mysql-endpoint -u test_admin -p &lt; test_data.sql\n\n# \u30c6\u30b9\u30c8\u5b9f\u884c\n.\/run_integration_tests.sh\n\n# \u30c6\u30b9\u30c8\u5b8c\u4e86\u5f8c\u306e\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\naws rds delete-db-instance \\\n    --db-instance-identifier test-mysql \\\n    --skip-final-snapshot<\/pre>\n\n\n\n<p>\u5b9f\u88c5\u306e\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u74b0\u5883\u7ba1\u7406<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8a2d\u5b9a\u306e\u5916\u90e8\u5316\u306b\u3088\u308b\u67d4\u8edf\u306a\u74b0\u5883\u7ba1\u7406<\/li>\n\n\n\n<li>\u74b0\u5883\u56fa\u6709\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u4e00\u5143\u7ba1\u7406<\/li>\n\n\n\n<li>\u30bf\u30b0\u30d9\u30fc\u30b9\u306e\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>CI\/CD\u7d71\u5408<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u81ea\u52d5\u5316<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u81ea\u52d5\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/li>\n\n\n\n<li>\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u306e\u81ea\u52d5\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8003\u616e\u4e8b\u9805<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u74b0\u5883\u9593\u306e\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/li>\n\n\n\n<li>\u6a5f\u5bc6\u60c5\u5831\u306e\u9069\u5207\u306a\u7ba1\u7406<\/li>\n\n\n\n<li>\u76e3\u67fb\u30ed\u30b0\u306e\u53d6\u5f97\u3068\u4fdd\u7ba1<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u904b\u7528\u52b9\u7387\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u52d5\u5316\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u518d\u5229\u7528\u6027<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u7dad\u6301<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u767a\u5c55\u7684\u306a\u904b\u7528\u7ba1\u7406\u624b\u6cd5\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u306aRDS\u74b0\u5883\u3067\u3082\u52b9\u7387\u7684\u304b\u3064\u5b89\u5168\u306a\u904b\u7528\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u5c0e\u5165\u306b\u3042\u305f\u3063\u3066\u306f\u5341\u5206\u306a\u30c6\u30b9\u30c8\u3068\u6bb5\u968e\u7684\u306a\u9069\u7528\u3092\u63a8\u5968\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":{"0":"post-2393","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-aws","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2393"}],"version-history":[{"count":1,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2393\/revisions"}],"predecessor-version":[{"id":2394,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2393\/revisions\/2394"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}