{"id":21806,"date":"2022-04-05T10:54:56","date_gmt":"2022-04-05T01:54:56","guid":{"rendered":"https:\/\/www.skyarch.net\/blog\/?p=21806"},"modified":"2022-04-05T11:23:08","modified_gmt":"2022-04-05T02:23:08","slug":"aws-secrets-manager%e3%81%a7rds%e8%aa%8d%e8%a8%bc%e6%83%85%e5%a0%b1%e3%82%92%e6%99%82%e9%96%93%e6%8c%87%e5%ae%9a%e3%83%ad%e3%83%bc%e3%83%86%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/aws-secrets-manager%e3%81%a7rds%e8%aa%8d%e8%a8%bc%e6%83%85%e5%a0%b1%e3%82%92%e6%99%82%e9%96%93%e6%8c%87%e5%ae%9a%e3%83%ad%e3%83%bc%e3%83%86%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3\/","title":{"rendered":"AWS Secrets Manager\u3067RDS\u8a8d\u8a3c\u60c5\u5831\u3092\u6642\u9593\u6307\u5b9a\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3"},"content":{"rendered":"<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#hajime\">\u306f\u3058\u3081\u306b<\/a><\/li>\n<li><a href=\"#osarai\">Secrets Manager\u306b\u3064\u3044\u3066\u304a\u3055\u3089\u3044<\/a><\/li>\n<li><a href=\"#gaiyo\">Secrets Manager\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u6982\u8981<\/a><\/li>\n<li><a href=\"#sikumi\">\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u4ed5\u7d44\u307f<\/a><\/li>\n<li><a href=\"#jissen\">\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u8df5<\/a><\/li>\n<li><a href=\"#owari\">\u304a\u308f\u308a\u306b<\/a><\/li>\n<li><a href=\"#sanko\">\u53c2\u8003\u4e00\u89a7<\/a><\/li>\n<\/ul>\n<h2 id=\"hajime\">\u306f\u3058\u3081\u306b<\/h2>\n<p>\u30b7\u30b9\u30c6\u30e0\u3067\u4f7f\u7528\u3059\u308b\u30e6\u30fc\u30b6\u540d\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u60c5\u5831\u306b\u3064\u3044\u3066\u3001Systems Manager\u306e<strong>ParameterStore<\/strong>\u3084<strong>Secrets Manager<\/strong>\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u65b9\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001\u305d\u3093\u306aSecrets Manager\u3067\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e<strong>\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd<\/strong>\u304c\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3055\u308c\u3001\u6642\u9593\u6307\u5b9a\u3067\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u53ef\u80fd\u3068\u306a\u3063\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2 id=\"osarai\">Secrets Manager\u306b\u3064\u3044\u3066\u304a\u3055\u3089\u3044<\/h2>\n<p>Secrets Manager\u306b\u3064\u3044\u3066\u306f\u3001\u904e\u53bb\u306b\u5f53\u30d6\u30ed\u30b0\u3067\u3042\u307e\u308a\u6271\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u6539\u3081\u3066\u304a\u3055\u3089\u3044\u3057\u307e\u3059\u3002<\/p>\n<h3>Secrets Manager\u3068\u306f<\/h3>\n<p>\u30e6\u30fc\u30b6\u540d\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u60c5\u5831(\u79d8\u5bc6\u60c5\u5831)\u3092<strong>\u5b89\u5168\u306b\u683c\u7d0d<\/strong>\u3067\u304d\u308bAWS\u30b5\u30fc\u30d3\u30b9\u306e\u3072\u3068\u3064\u3067\u3059\u3002<\/p>\n<p>\u5f93\u6765\u578b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u60c5\u5831\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b3\u30fc\u30c9\u5185\u3001\u307e\u305f\u306f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u5185\u306b\u8a18\u8f09\u3057\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\u3057\u304b\u3057Secrets Manager\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30b3\u30f3\u30c6\u30ca\u3084\u30b5\u30fc\u30d0\u306b\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u5b89\u5168\u306b\u52d5\u7684\u633f\u5165\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p><em>The Twelve-Factor App<\/em>\u3067\u3082\u63a8\u5968\u3055\u308c\u3066\u304a\u308a\u3001\u5b9f\u8df5\u3057\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u3082\u591a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<h3>PrameterStore\u3068\u306e\u9055\u3044<\/h3>\n<p>\u540c\u69d8\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u3001Systems Manager\u306e<strong>ParameterStore<\/strong>\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nParameterStore\u306b\u3064\u3044\u3066\u306f\u3001\u5229\u7528\u53ef\u80fd\u306aAWS\u30b5\u30fc\u30d3\u30b9\u304c\u591a\u5c90\u306b\u6e21\u3063\u3066\u304a\u308a\u3001Secrets Manager\u306f<strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u7279\u5316<\/strong>\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3069\u3061\u3089\u3092\u4f7f\u3046\u304b\u306f\u4e88\u7b97\u3084\u30b7\u30b9\u30c6\u30e0\u8981\u4ef6\u6b21\u7b2c\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306b\u3064\u3044\u3066\u306fSecrets Manager\u306e\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u304c<strong>\u63a8\u5968<\/strong>\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u5bfe\u8c61\u306e\u30b5\u30fc\u30d3\u30b9<\/h3>\n<p>Amazon RDS\u3001Amazon DocumentDB\u3001Amazon Redshift<\/p>\n<h2 id=\"gaiyo\">\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u6982\u8981<\/h2>\n<p>Secrets Manager\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306e\u6982\u8981\u306f\u4e0b\u8a18\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u307e\u3067\u306f\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u671f\u9593(\u65e5\u6570)\u306e\u6307\u5b9a\u306e\u307f\u3067\u3001\u5b9f\u969b\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u308b\u6642\u9593\u3092\u6307\u5b9a\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306b\u3088\u308a\u3001\u65b0\u305f\u306b<strong>\u5e0c\u671b\u3059\u308b\u6642\u9593\u306b\u30ed\u30fc\u30c6\u30fc\u30c8<\/strong>\u3092\u5b9f\u65bd\u3067\u304d\u307e\u3059\u3002<\/p>\n<blockquote><p>\n  AWS Secrets Manager \u306f\u7279\u5b9a\u306e\u6642\u9593\u30a6\u30a3\u30f3\u30c9\u30a6\u5185\u3067\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30b9\u30b1\u30b8\u30e5\u30fc\u30ea\u30f3\u30b0\u3059\u308b\u6a5f\u80fd\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\u3053\u306e\u6a5f\u80fd\u306b\u3088\u308a\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u7279\u5b9a\u65e5\u306e\u7279\u5b9a\u6642\u9593\u306b\u9650\u5b9a\u3067\u304d\u307e\u3059\u3002\u4ee5\u524d\u306f\u3001Secrets Manager \u306f\u6307\u5b9a\u3055\u308c\u305f\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30a4\u30f3\u30bf\u30fc\u30d0\u30eb\u306e\u6700\u5f8c\u306e24\u6642\u9593\u5185\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3057\u305f\u3002\u672c\u65e5\u306e\u65b0\u6a5f\u80fd\u306e\u63d0\u4f9b\u958b\u59cb\u306b\u3088\u308a\u3001\u30de\u30cd\u30fc\u30b8\u30c9\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5229\u4fbf\u6027\u304b\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u5b89\u5168\u6027\u306e\u3069\u3061\u3089\u304b\u3092\u9078\u629e\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002\n<\/p><\/blockquote>\n<p><a href=\"https:\/\/aws.amazon.com\/jp\/about-aws\/whats-new\/2022\/02\/aws-secrets-manager-windows\/\">AWS Secrets Manager \u304c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u30b5\u30dd\u30fc\u30c8<\/a><\/p>\n<h2 id=\"sikumi\">\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u4ed5\u7d44\u307f<\/h2>\n<p>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3059\u308b\u3068<strong>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u7528lambda\u95a2\u6570<\/strong>\u304c\u81ea\u52d5\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>lambda\u95a2\u6570\u304c\u6307\u5b9a\u6642\u9593\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u3053\u3068\u306b\u3088\u308a\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u5b9f\u73fe\u3055\u308c\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-19-48.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-19-48.png\" alt=\"\" width=\"561\" height=\"281\" class=\"alignnone size-full wp-image-21815\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-19-48.png 561w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-19-48-300x150.png 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/a>\n<h2 id=\"jissen\">\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u8df5<\/h2>\n<p>\u65b0\u305f\u306bSecrets Manager\u306bRDS\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4fdd\u5b58\u3057\u3001\u6307\u5b9a\u6642\u523b\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u308b\u304b\u8a66\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n<h3>\u624b\u9806<\/h3>\n<ol>\n<li><a href=\"#secret\">Secrets Manager\u306b\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4fdd\u5b58<\/a><\/li>\n<li><a href=\"#enable\">\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b<\/a><\/li>\n<li><a href=\"#verify\">\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u306e\u78ba\u8a8d<\/a><\/li>\n<li><a href=\"#app\">\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u63a5\u7d9a\u78ba\u8a8d<\/a><\/li>\n<\/ol>\n\n<h3 id=\"secret\">Secrets Manager\u306b\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4fdd\u5b58<\/h3>\n<p>\u30de\u30cd\u30fc\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3088\u308a\u65b0\u898f\u306b\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u5bfe\u8c61\u306eRDS\u3092\u6307\u5b9a\u3057\u3001\u300c\u30e6\u30fc\u30b6\u540d\u300d\u3068\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u300d\u3092\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11.png\" alt=\"\" width=\"1379\" height=\"331\" class=\"alignnone size-full wp-image-21816\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11.png 1379w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11-300x72.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11-1024x246.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11-768x184.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-24-11-728x175.png 728w\" sizes=\"auto, (max-width: 1379px) 100vw, 1379px\" \/><\/a>\n<p>RDS\u306e\u300c\u30e6\u30fc\u30b6\u540d\u300d\u3068\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u300d\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1.png\" alt=\"\" width=\"913\" height=\"549\" class=\"alignnone size-full wp-image-21843\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1.png 913w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1-300x180.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1-768x462.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-25-10-1-728x438.png 728w\" sizes=\"auto, (max-width: 913px) 100vw, 913px\" \/><\/a>\n<p>\u5bfe\u8c61\u306eRDS\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23.png\" alt=\"\" width=\"817\" height=\"224\" class=\"alignnone size-full wp-image-21818\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23.png 817w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23-300x82.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23-768x211.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-26-23-728x200.png 728w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/a>\n<p>\u4eca\u56de\u306f\u3001\u308f\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u3001\u307e\u305a\u300c\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u7121\u52b9\u300d\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-28-14.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-28-14.png\" alt=\"\" width=\"586\" height=\"139\" class=\"alignnone size-full wp-image-21819\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-28-14.png 586w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-28-14-300x71.png 300w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/a>\n\n<h3 id=\"enable\">\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b<\/h3>\n<p>\u4f5c\u6210\u3057\u305f\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u300c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u7de8\u96c6\u300d\u304b\u3089\u3001\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u6709\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<h4>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u306e\u8a2d\u5b9a<\/h4>\n<p>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30a6\u30a3\u30f3\u30c9\u30a6\u3067\u306e\u6307\u5b9a\u306b\u306f\u3001cron\u304a\u3088\u3073rate\u5f0f\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u4e0b\u8a18\u306e\u5185\u5bb9\u3067\u8a2d\u5b9a\u3057\u3001\u300c\u6bce\u65e57:00:00 UTC\u300d\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u9805\u76ee<\/th>\n<th>\u8a2d\u5b9a\u5024<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u5f0f<\/td>\n<td>cron(0 7 * * ? *)<\/td>\n<\/tr>\n<tr>\n<td>\u30a6\u30a3\u30f3\u30c9\u30a6\u671f\u9593<\/td>\n<td>1h<\/td>\n<\/tr>\n<tr>\n<td>\u3059\u3050\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/td>\n<td>OFF<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e0a\u8a18\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04.png\" alt=\"\" width=\"774\" height=\"555\" class=\"alignnone size-full wp-image-21820\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04.png 774w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04-300x215.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04-768x551.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-38-04-728x522.png 728w\" sizes=\"auto, (max-width: 774px) 100vw, 774px\" \/><\/a><\/p>\n<h4>\uff1c\u6ce8\u610f\u70b9\uff1e<\/h4>\n<ul>\n<li>Secrets Manager\u306e\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u306f<strong>UTC<\/strong>\u3067\u3059\u3002<\/li>\n<li>cron\u5f0f\u306e<strong>minute<\/strong>\u3001\u304a\u3088\u3073<strong>year<\/strong>\u306f0\u3057\u304b\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002<\/li>\n<li>\u3053\u308c\u306f\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u6b63\u6642\u306b\u958b\u59cb\u3055\u308c\u308b\u305f\u3081\u3001\u304a\u3088\u30731\u5e74\u3092\u8d85\u3048\u308b\u8a2d\u5b9a\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3067\u3059\u3002<\/li>\n<li><strong>\u3059\u3050\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/strong>\u306f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u6b21\u7b2c\u3067\u5931\u6557\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067[OFF]\u306b\u3057\u3066\u304a\u304f\u306e\u304c\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/li>\n<\/ul>\n<h4>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u306e\u8a2d\u5b9a<\/h4>\n<p>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u306f\u3001\u3042\u3089\u304b\u3058\u3081\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u57fa\u3065\u3044\u305f\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u3092<strong>\u81ea\u52d5\u4f5c\u6210<\/strong>\u3059\u308b\u304b\u3001<strong>\u4f5c\u6210\u6e08\u307f\u306e\u81ea\u4f5c\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/strong>\u95a2\u6570\u304c\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u9805\u76ee<\/th>\n<th>\u5185\u5bb9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u3092\u4f5c\u6210<\/td>\n<td>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u3092\u81ea\u52d5\u4f5c\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u3092\u4f7f\u7528<\/td>\n<td>\u4f5c\u6210\u6e08\u307f\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u3092\u5229\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49.png\" alt=\"\" width=\"777\" height=\"400\" class=\"alignnone size-full wp-image-21821\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49.png 777w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49-300x154.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49-768x395.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-39-49-728x376.png 728w\" sizes=\"auto, (max-width: 777px) 100vw, 777px\" \/><\/a>\n<p>\u300c\u500b\u5225\u306e\u8a8d\u8a3c\u60c5\u5831\u3092\u4f7f\u7528\u3057\u3066\u3053\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u306f\u300c\u3044\u3044\u3048\u300d\u3092\u9078\u629e\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3061\u3089\u306f\u5f8c\u8ff0\u306e\u300c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u300d\u306e\u6307\u5b9a\u3067\u3059\u3002\u4eca\u56de\u306f\u4e00\u822c\u7684\u306a\u300c\u30b7\u30f3\u30b0\u30eb\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565\u300d\u3092\u3068\u308a\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u9805\u76ee<\/th>\n<th>\u5185\u5bb9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u3044\u3044\u3048<\/td>\n<td>\u30b7\u30f3\u30b0\u30eb\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/td>\n<\/tr>\n<tr>\n<td>\u306f\u3044<\/td>\n<td>\u4ea4\u4ee3\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3042\u3089\u304b\u3058\u3081\u7528\u610f\u3055\u308c\u3066\u3044\u308bCloudFormation\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304b\u3089Lambda\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u95a2\u6570\u304c<strong>\u81ea\u52d5\u751f\u6210<\/strong>\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-40-59.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-40-59.png\" alt=\"\" width=\"480\" height=\"42\" class=\"alignnone size-full wp-image-21822\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-40-59.png 480w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-40-59-300x26.png 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53.png\" alt=\"\" width=\"1500\" height=\"253\" class=\"alignnone size-full wp-image-21845\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53.png 1500w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53-300x51.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53-1024x173.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53-768x130.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-05-53-728x123.png 728w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/a><br \/>\n\u3053\u3053\u3067\u4f5c\u6210\u3055\u308c\u308blambda\u95a2\u6570\u306f\u3001<strong>\u300cVPC\u3001\u30b5\u30d6\u30cd\u30c3\u30c8\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d<\/strong>\u304c\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u4f5c\u6210\u6642\u306b\u6307\u5b9a\u3057\u305fRDS\u304b\u3089<strong>\u5f15\u304d\u7d99\u304c\u308c\u307e\u3059<\/strong>\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34.png\" alt=\"\" width=\"1314\" height=\"217\" class=\"alignnone size-full wp-image-21844\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34.png 1314w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34-300x50.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34-1024x169.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34-768x127.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-03-34-728x120.png 728w\" sizes=\"auto, (max-width: 1314px) 100vw, 1314px\" \/><\/a>\n<h4>\uff1c\u6ce8\u610f\u70b9\uff1e<\/h4>\n<ul>\n<li>lambda\u95a2\u6570\u306eSG\u304b\u3089RDS\u306eSG\u306b<strong>\u30a2\u30af\u30bb\u30b9\u8a31\u53ef<\/strong>\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002  <\/li>\n<li><strong>\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b5\u30d6\u30cd\u30c3\u30c8<\/strong>\u3067\u3042\u308c\u3070PrivateLink\u3084NAT\u3092\u7d4c\u7531\u3057\u3066Secrets Manager\u306b\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3002<\/li>\n<li>RDS\u3068\u540c\u3058\u5834\u6240\u306b\u4f5c\u6210\u3055\u308c\u308b\u3053\u3068\u306b\u62b5\u6297\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u4f5c\u6210\u5f8c\u306b\u79fb\u52d5\u3057\u307e\u3057\u3087\u3046\u3002  <\/li>\n<li>NAT\u304c\u306a\u3044\u74b0\u5883\u3067\u306f\u3001\u610f\u5916\u3068\u30cf\u30de\u308a\u30dd\u30a4\u30f3\u30c8\u306a\u306e\u3067\u3054\u6ce8\u610f\u3067\u3059\u3002  <\/li>\n<\/ul>\n<p>\u3053\u308c\u3067\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n\n<h3 id=\"verify\">\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u306e\u78ba\u8a8d<\/h3>\n<p>\u8a2d\u5b9a\u3057\u305f\u6642\u9593\u306b\u81ea\u52d5\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u524d<\/li>\n<\/ul>\n<pre>\n[ssm-user@ip-10-0-xxx-xx ~]$ <b>aws secretsmanager get-secret-value --secret-id rotation\/mysql | jq .SecretString | jq fromjson<\/b>\n{\nusername: \"sm_rotation\",\npassword: \".3V~QGPp1bzi?c5u:}xp.Y)Mc?kvx&amp;h]\",\nengine: \"mysql\",\nhost: \"sm-rotation.xxxxxx.ap-northeast-1.rds.amazonaws.com\",\nport: 3306,\ndbInstanceIdentifier: \"rotation\"\n}\n<\/pre>\n<ul>\n<li>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u5f8c<\/li>\n<\/ul>\n<pre>\n[ssm-user@ip-10-0-xxx-xx ~]$ aws secretsmanager get-secret-value --secret-id rotation\/mysql | jq .SecretString | jq fromjson\n{\nusername: \"sm_rotation\",\npassword: \"YG`3$&lt;2wf6gw&amp;OJy$g8M|nz%V)Uie;2E&quot;,\nengine: &quot;mysql&quot;,\nhost: &quot;sm-rotation.xxxxxx.ap-northeast-1.rds.amazonaws.com&quot;,\nport: 3306,\ndbInstanceIdentifier: &quot;rotation&quot;\n}\n<\/pre>\n<p><strong>\u7121\u4e8b\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/strong><br \/>\nRDS\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u307f\u308b\u3068\u554f\u984c\u306a\u304f\u63a5\u7d9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\n[ssm-user@ip-10-0-xxx-xx ~]$ password='YG`3$&lt;2wf6gw&amp;OJy$g8M|nz%V)Uie;2E&#039;\n[ssm-user@ip-10-0-xxx-xx ~]$ mysql -usm_rotation -p${password} -h sm-rotation.cltlmqvebtjp.ap-northeast-1.rds.amazonaws.com\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 170\nServer version: 8.0.27 Source distribution\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType &#039;help;&#039; or &#039;\\h&#039; for help. Type &#039;\\c&#039; to clear the current input statement.\n<\/pre>\n<p>\u6b21\u306b\u3069\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30ed\u30fc\u30c6\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>10\u79d2\u5358\u4f4d\u3067\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u72b6\u614b\u3092\u30c0\u30f3\u30d7\u3057\u7d9a\u3051\u3066\u307f\u308b\u3068\u3001\u6307\u5b9a\u6642\u523b\u3067\u3042\u308b\u300c03:08:00 UTC\u300d\u306b\u5909\u66f4\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\n[ssm-user@ip-10-0-101-57 ~]$ while true; do date;aws secretsmanager get-secret-value --secret-id rotation\/mysql |jq .SecretString |jq fromjson; sleep 10; done\n:(\u7701\u7565)\nThu Mar 30 03:08:03 UTC 2022\n{\nusername: \"sm_rotation\",\npassword: \".3V~QGPp1bzi?c5u:}xp.Y)Mc?kvx&amp;h]\",\nengine: \"mysql\",\nhost: \"sm-rotation.xxxxxx.ap-northeast-1.rds.amazonaws.com\",\nport: 3306,\ndbInstanceIdentifier: \"rotation\"\n}\nThu Mar 30 03:08:13 UTC 2022\n{\nusername: \"sm_rotation\",\npassword: \"YG`3$&lt;2wf6gw&amp;OJy$g8M|nz%V)Uie;2E&quot;,\u3000\u3000\u3000\u2190\u5909\u66f4\u3055\u308c\u305f\nengine: &quot;mysql&quot;,\nhost: &quot;sm-rotation.xxxxxx.ap-northeast-1.rds.amazonaws.com&quot;,\nport: 3306,\ndbInstanceIdentifier: &quot;rotation&quot;\n}\n:(\u7701\u7565)\n<\/pre>\n<p>Secrets Manager\u306eLastRotatedDate\u3092\u6570\u65e5\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001\u6307\u5b9a\u6642\u523b\u306e<strong>0\u5206\u301c10\u5206<\/strong>\u3067\u30ed\u30fc\u30c6\u30fc\u30c8\u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre>\n[ssm-user@ip-10-0-xxx-xx ~]$ aws secretsmanager describe-secret --secret-id rotation\/mysql | jq .LastRotatedDate | awk '{print strftime(\"%c\",$1)}'\nThu 30 Mar 2022 03:08:13 AM UTC\nssm-user@ip-10-0-xxx-xx ~]$ aws secretsmanager describe-secret --secret-id rotation\/mysql | jq .LastRotatedDate | awk '{print strftime(\"%c\",$1)}'\nThu 31 Mar 2022 03:10:02 AM UTC\n<\/pre>\n\n<h3 id=\"app\">\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u63a5\u7d9a\u78ba\u8a8d<\/h3>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u5f8c\u306b<strong>\u6b63\u3057\u3044\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u5024\u3092\u53d6\u5f97\u3067\u304d\u308b\u306e\u304b<\/strong>\u3068\u3044\u3046\u70b9\u3082\u6c17\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067\u3001<br \/>\n\u305d\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u30d9\u30fc\u30b9\u306b\u3001\u53d6\u5f97\u3057\u305f\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3067RDS\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308blambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre>\n# Use this code snippet in your app.\n# If you need more information about configurations or implementing the sample code, visit the AWS docs:   \n# https:\/\/aws.amazon.com\/developers\/getting-started\/python\/\n\nimport boto3\nimport base64\nimport ast\nimport pymysql\nimport logging\nfrom botocore.exceptions import ClientError\n\n\ndef get_secret(event, context):\n\n    logger = logging.getLogger()\n    logger.setLevel(logging.INFO)\n\n    secret_name = \"arn:aws:secretsmanager:ap-northeast-1:[\u30a2\u30ab\u30a6\u30f3\u30c8ID]:secret:[\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u540d]\"\n    region_name = \"ap-northeast-1\"\n\n    # Create a Secrets Manager client\n    session = boto3.session.Session()\n    client = session.client(\n        service_name='secretsmanager',\n        region_name=region_name\n    )\n    try:\n        get_secret_value_response = client.get_secret_value(\n            SecretId=secret_name\n        )\n    except ClientError as e:\n        if e.response['Error']['Code'] == 'DecryptionFailureException':\n            raise e\n        elif e.response['Error']['Code'] == 'InternalServiceErrorException':\n            raise e\n        elif e.response['Error']['Code'] == 'InvalidParameterException':\n            raise e\n        elif e.response['Error']['Code'] == 'InvalidRequestException':\n            raise e\n        elif e.response['Error']['Code'] == 'ResourceNotFoundException':\n            raise e\n    else:\n        if 'SecretString' in get_secret_value_response:\n            secret = get_secret_value_response['SecretString']\n\n            params = ast.literal_eval(secret)\n            host = params[\"host\"]\n            username = params[\"username\"]\n            password = params[\"password\"]\n            dbname = params[\"dbInstanceIdentifier\"]\n            \n            try:\n                conn = pymysql.connect(host=host, user=username, passwd=password, db=dbname, connect_timeout=5)\n            except pymysql.MySQLError as e:\n                print(\"ERROR: Unexpected error: Could not connect to MySQL instance.\")\n            \n            logger.info(\"SUCCESS: Connection to RDS MySQL instance succeeded\")\n<\/pre>\n<p>\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u3053\u3061\u3089\u3082\u554f\u984c\u306a\u304f<strong>\u63a5\u7d9a\u53ef\u80fd<\/strong>\u3067\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16.png\" alt=\"\" width=\"1332\" height=\"238\" class=\"alignnone size-full wp-image-21847\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16.png 1332w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16-300x54.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16-1024x183.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16-768x137.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-16-14-16-728x130.png 728w\" sizes=\"auto, (max-width: 1332px) 100vw, 1332px\" \/><\/a><\/p>\n<p>\u304a\u307e\u3051\u3068\u3057\u3066\u3001\u3053\u306e\u95a2\u6570\u3092<strong>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u671f\u9593\u4e2d<\/strong>\u306b<strong>1mim\u6bce<\/strong>\u306b\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u305f\u6642\u523b\u3092\u631f\u3093\u3067\u3082<strong>RDS\u63a5\u7d9a\u306b\u5931\u6557\u3057\u307e\u305b\u3093\u3067\u3057\u305f<\/strong>\u3002<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-55-36.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-55-36.png\" alt=\"\" width=\"666\" height=\"532\" class=\"alignnone size-full wp-image-21826\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-55-36.png 666w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2022\/04\/2022-04-01-11-55-36-300x240.png 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a>\n<p>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6642\u523b<\/p>\n<pre>\nssm-user@ip-10-0-xxx-xx ~]$ aws secretsmanager describe-secret --secret-id rotation\/mysql | jq .LastRotatedDate | awk '{print strftime(\"%c\",$1)}'\nThu 31 Mar 2022 08:10:02 AM UTC\n<\/pre>\n<p>\u305f\u3060\u3057\u3001<strong><span style=\"color: red\">\u5b9f\u969b\u306b\u306f\u5fae\u5c0f\u306a\u6642\u9593\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u30c0\u30a6\u30f3\u30bf\u30a4\u30e0\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059<\/span><\/strong>\u3002<br \/>\n\u3053\u308c\u306b\u3064\u3044\u3066\u306f<strong>\u9069\u5207\u306a\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/strong>\u3092\u53d6\u308b\u3053\u3068\u3088\u308a\u3001\u3042\u308b\u7a0b\u5ea6\u56de\u907f\u53ef\u80fd\u3067\u3059\u3002<br \/>\n(\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u305f\u3081\u3001\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u3089\u6b21\u306e\u30d6\u30ed\u30b0\u3067)<\/p>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/secretsmanager\/latest\/userguide\/rotating-secrets_strategies.html\">\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6226\u7565<\/a><\/p>\n<h2 id=\"owari\">\u304a\u308f\u308a\u306b<\/h2>\n<p>\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u6642\u9593\u6307\u5b9a\u304c\u53ef\u80fd\u306b\u306a\u3063\u305f\u3053\u3068\u3067\u3001\u3088\u308a<strong>\u53b3\u3057\u3044\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8981\u4ef6<\/strong>\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u6642\u9593\u307e\u3067\u6307\u5b9a\u3059\u308b\u8981\u4ef6\u306f\u5c11\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<strong>\u3044\u3064\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u308b\u306e\u304b<\/strong>\u3092\u628a\u63e1\u3057\u3001\u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u628a\u63e1\u3067\u304d\u308b\u7bc4\u56f2\u3092\u5e83\u3052\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2 id=\"sanko\">\u53c2\u8003\u4e00\u89a7<\/h2>\n<p><a href=\"https:\/\/aws.amazon.com\/jp\/about-aws\/whats-new\/2022\/02\/aws-secrets-manager-windows\/\">AWS Secrets Manager \u304c\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u30b5\u30dd\u30fc\u30c8<\/a><\/p>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/secretsmanager\/latest\/userguide\/rotating-secrets.html\">AWS Secrets Manager\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3<\/a><\/p>\n<p><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/secretsmanager\/latest\/userguide\/rotate-secrets_schedule.html\">Secrets Manager \u306e\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u5f0f<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 \u306f\u3058\u3081\u306b Secrets Manager\u306b\u3064\u3044\u3066\u304a\u3055\u3089\u3044 Secrets Manager\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u6982\u8981 \u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u4ed5\u7d44\u307f \u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u8df5 \u304a\u308f\u308a\u306b \u53c2\u8003\u4e00\u89a7 \u306f\u3058\u3081\u306b \u30b7\u30b9\u30c6\u30e0\u3067\u4f7f\u7528\u3059\u308b\u30e6\u30fc\u30b6\u540d\u3084\u30d1\u30b9&#8230;<\/p>\n","protected":false},"author":199,"featured_media":21814,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/www.skyarch.net\/blog\/?p=21806","footnotes":""},"categories":[20,24,109,276,7],"tags":[397,500,616,352],"class_list":{"0":"post-21806","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-mysql","9":"category-rds","10":"category-serverless","11":"category-security","12":"tag-amazon-rds","13":"tag-aws-secrets-manager","14":"tag-616","15":"tag-352","16":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/21806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/199"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=21806"}],"version-history":[{"count":39,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/21806\/revisions"}],"predecessor-version":[{"id":21857,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/21806\/revisions\/21857"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/21814"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=21806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=21806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=21806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}