{"id":16727,"date":"2019-07-17T13:00:20","date_gmt":"2019-07-17T04:00:20","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=16727"},"modified":"2019-08-22T12:35:49","modified_gmt":"2019-08-22T03:35:49","slug":"aws-cloud-development-kitcdk%e3%81%a7python%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/aws-cloud-development-kitcdk%e3%81%a7python%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"AWS Cloud Development Kit(CDK)\u3067Python\u3092\u4f7f\u3063\u3066\u307f\u305f"},"content":{"rendered":"<h1>AWS Cloud Development Kit(CDK)\u3067Python\u4f7f\u3063\u3066\u307f\u305f<\/h1>\n<h2>\u521d\u3081\u306b<\/h2>\n<p>\u307f\u306a\u3055\u3093\u521d\u3081\u307e\u3057\u3066!!!<br \/>\n\u30b9\u30ab\u30a4\u30a2\u30fc\u30c1\u306e\u77f3\u9ed2\u3068\u7533\u3057\u307e\u3059!!<\/p>\n<p>\u6700\u8fd1\u3053\u3093\u306a\u8a18\u4e8b\u3092\u898b\u304b\u3051\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/aws.amazon.com\/jp\/blogs\/aws\/aws-cloud-development-kit-cdk-typescript-and-python-are-now-generally-available\/\">AWS Cloud Development Kit(CDK)\u3067Python\u3068TypeScript\u304c\u4f7f\u7528\u53ef\u80fd\u306b!!!<\/a><\/p>\n<p>AWS CDK\u3092\u89e6\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u306e\u3067\u3059\u304c<br \/>\n\u4f55\u3084\u3089Python\u3067\u307e\u305f\u4fbf\u5229\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u69d8\u5b50...<br \/>\n\u3053\u308c\u306f\u8a66\u3057\u3066\u307f\u306d\u3070!!!\u306e\u7cbe\u795e\u3067\u4eca\u56de\u53d6\u308a\u7d44\u3093\u3067\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>AWS Cloud Development Kit (CDK)\u3068\u306f?<\/h2>\n<p>\u305d\u3082\u305d\u3082<a href=\"https:\/\/aws.amazon.com\/jp\/blogs\/news\/aws-cdk-developer-preview\/\">AWS CDK<\/a>\u3068\u306f\u4f55\u306a\u306e\u304b\u3068\u3044\u3046\u3068\u3053\u308d\u304b\u3089\u8abf\u3079\u307e\u3057\u305f\u3002<\/p>\n<blockquote><p>\n  \u73fe\u5728\u306e\u5bfe\u5fdc\u8a00\u8a9e\u306f TypeScript\u3001 JavaScript \u305d\u3057\u3066 Java \u3067\u3001.NET \u3068 Python \u3092\u8fd1\u3005\u3054\u6848\u5185\u4e88\u5b9a\u3067\u3059\u3002<br \/>\n  AWS CDK \u306f\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u958b\u767a\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3042\u308a\u3001\u30af\u30e9\u30a6\u30c9\u306e\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u3092\u30b3\u30fc\u30c9\u3067\u5b9a\u7fa9\u3057\u3066<br \/>\n  CloudFormation \u3067\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u3067\u304d\u307e\u3059\u3002CDK \u306f AWS \u306e\u30b5\u30fc\u30d3\u30b9\u3068\u7d71\u5408\u3055\u308c\u3001<br \/>\n  \u9ad8\u30ec\u30d9\u30eb\u304b\u3064\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u62bd\u8c61\u6982\u5ff5\u3092\u4f7f\u3063\u3066AWS \u30ea\u30bd\u30fc\u30b9\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<br \/>\n  CDK \u306b\u3088\u3063\u3066\u30e2\u30c0\u30f3\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3092\u4f7f\u3063\u3066AWS \u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u3092\u898b\u901a\u3057\u3088\u304f\u52b9\u7387\u3088\u304f\u5b9a\u7fa9\u3067\u304d\u308b\u305f\u3081\u3001<br \/>\n  \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u307e\u3067\u4e00\u8cab\u3057\u305f\u958b\u767a\u4f53\u9a13 (development experience) \u304c\u5f97\u3089\u308c\u307e\u3059\u3002\n<\/p><\/blockquote>\n<p>AWS CDK\u3092\u4f7f\u3048\u3070Python\u306e\u30b3\u30fc\u30c9\u3067AWS\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u884c\u3048\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<blockquote><p>\n  CDK \u306f\u30af\u30e9\u30a6\u30c9\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u306e\u300c\u30b3\u30f3\u30d1\u30a4\u30e9\u300d\u3067\u3042\u308b\u3068\u8003\u3048\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n  CDK\u306f Constructs \u3068\u3044\u3046\u30cf\u30a4\u30ec\u30d9\u30eb\u306a\u30af\u30e9\u30b9\u30e9\u30a4\u30d6\u30e9\u30ea\u7fa4\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<br \/>\n  Constructs\u306f\u62bd\u8c61\u5316\u3055\u308c\u305fAWS\u30ea\u30bd\u30fc\u30b9\u3067\u3001AWS\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u5f93\u3063\u305f\u8a2d\u5b9a\u3092\u5185\u5305\u3057\u307e\u3059\u3002<br \/>\n  Constructs\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e CDK application \u306b\u5272\u308a\u5f53\u3066\u53ef\u80fd\u3067\u3059\u3002<br \/>\n  CDK application \u306f\u500b\u5225\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u3092\u5b9a\u7fa9\u3057\u3001\u7e70\u308a\u8fd4\u3057\u4f7f\u308f\u308c\u308b\u8907\u96d1\u306a\u51e6\u7406\u3092\u7ba1\u7406\u3057\u307e\u3059<br \/>\n  CDK application \u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066 AWS \u306e \u201c\u30a2\u30bb\u30f3\u30d6\u30ea\u8a00\u8a9e\u201d \u3067\u3042\u308b\u3001CloudFormation \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<br \/>\n  \u3053\u308c\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092 CloudFormation \u306e\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u30a8\u30f3\u30b8\u30f3\u3067\u51e6\u7406\u3059\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3059\u3002<br \/>\n  CDK tools \u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30a4\u30f3\u30d5\u30e9\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u306e\u30b9\u30bf\u30c3\u30af\u5b9a\u7fa9\u3092\u5bb9\u6613\u306b\u3057\u3001<br \/>\n  CloudFormation \u30b5\u30fc\u30d3\u30b9\u304c\u30b9\u30bf\u30c3\u30af\u306e\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u3092\u5b89\u5168\u6027\u304a\u3088\u3073\u4fe1\u983c\u6027\u9ad8\u304f\u5b9f\u65bd\u3057\u307e\u3059\u3002\n<\/p><\/blockquote>\n<p>\u305f\u3060\u3057\u3001CDK\u306f\u3042\u304f\u307e\u3067\u30b3\u30f3\u30d1\u30a4\u30e9\u3068\u3044\u3046\u4f4d\u7f6e\u4ed8\u3051\u3067\u3001CDK\u305d\u306e\u3082\u306e\u304cAWS\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u3057\u3066\u304f\u308c\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u306a\u3044\u3088\u3046\u3067\u3059\u3002<br \/>\nAWS CDK\u3092\u7528\u3044\u308b\u3053\u3068\u3067CloudFormation\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u7528\u610f\u3068\u30c7\u30d7\u30ed\u30a4\u304c\u3067\u304d\u3001\u9593\u63a5\u7684\u306bAWS\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u884c\u3048\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<h2>\u8a66\u3057\u3066\u307f\u3088\u3046<\/h2>\n<p><a href=\"https:\/\/cdkworkshop.com\/30-python.html\">Python\u30ef\u30fc\u30af\u30b7\u30e7\u30c3\u30d7<\/a>\u3092\u53c2\u8003\u306bMac\u3067\u4f5c\u696d\u3092\u9032\u3081\u307e\u3059\u3002<\/p>\n<p>\u307e\u305aAWS CDK\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\uff08CLI\uff09 \u3092\u5165\u308c\u307e\u3059\u3002<br \/>\nnpm\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f<a href=\"https:\/\/public-constructor.com\/install-node-and-npm-on-mac\/\">\u3053\u3061\u3089<\/a>\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><code>$ npm install -g aws-cdk<\/code><\/p>\n<p>CDK\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u5165\u308c\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n<code>$ mkdir cdk-workshop &amp;amp;&amp;amp; cd cdk-workshop<\/code><\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u306eCDK\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ cdk init app --language=python\n$ tree\n.\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 app.py\n\u251c\u2500\u2500 cdk.json\n\u251c\u2500\u2500 hello\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 hello.egg-info\n\u2502 \u2502 \u251c\u2500\u2500 PKG-INFO\n\u2502 \u2502 \u251c\u2500\u2500 SOURCES.txt\n\u2502 \u2502 \u251c\u2500\u2500 dependency_links.txt\n\u2502 \u2502 \u251c\u2500\u2500 requires.txt\n\u2502 \u2502 \u2514\u2500\u2500 top_level.txt\n\u2502 \u251c\u2500\u2500 hello_construct.py\n\u2502 \u2514\u2500\u2500 hello_stack.py\n\u251c\u2500\u2500 requirements.txt\n\u251c\u2500\u2500 setup.py\n\u2514\u2500\u2500 tests\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 unit\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 test_hello_construct.py\n<\/pre>\n<p>virtualenv\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3057\u3001\u5fc5\u8981\u306a\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre>\n$ source .env\/bin\/activate\n(.env)$ pip install -r requirements.txt\n<\/pre>\n<p>\u30b5\u30f3\u30d7\u30eb\u3067\u30ea\u30fc\u30b8\u30e7\u30f3\u5225\u306b\u3001\u30a2\u30d7\u30ea\u304c2\u3064\u6e96\u5099\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\nMyStack\u30af\u30e9\u30b9\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3057\u3066\u7528\u610f\u3059\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre>\n(.env)$ cat app.py\n#!\/usr\/bin\/env python3\n\nfrom aws_cdk import core\n\nfrom hello.hello_stack import MyStack\n\napp = core.App()\nMyStack(app, \"hello-cdk-1\", env={'region': 'us-east-2'})\nMyStack(app, \"hello-cdk-2\", env={'region': 'us-west-2'})\n\napp.synth()\n<\/pre>\n<p>\u6b21\u306b\u30b9\u30bf\u30c3\u30af(CloudFormation\u3067\u4f5c\u6210\u3055\u308c\u308b\u74b0\u5883\u7fa4)\u306e\u5185\u5bb9\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>hello\/hello_stack.py<\/li>\n<li>\u30a2\u30d7\u30ea\u306e\u4e2d\u6838\u3068\u306a\u308b\u30e1\u30a4\u30f3\u30b9\u30bf\u30c3\u30af<\/li>\n<li>4\u3064\u306e\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/li>\n<li>SQS\u30ad\u30e5\u30fc\u30921\u3064\u4f5c\u6210\u3059\u308b<\/li>\n<li>SNS\u30c8\u30d4\u30c3\u30af\u30921\u3064\u4f5c\u6210\u3059\u308b<\/li>\n<\/ul>\n<pre>\n(.env)$ cat hello\/hello_stack.py\nfrom aws_cdk import (\n\u3000aws_iam as iam,\n\u3000aws_sqs as sqs,\n\u3000aws_sns as sns,\n\u3000aws_sns_subscriptions as subs,\n\u3000core\n)\n\nfrom hello_construct import HelloConstruct\n\nclass MyStack(core.Stack):\n\ndef __init__(self, scope: core.Construct, id: str, **kwargs) -&gt; None:\nsuper().__init__(scope, id, **kwargs)\n\nqueue = sqs.Queue(\n\u3000self, \"MyFirstQueue\",\n\u3000visibility_timeout=core.Duration.seconds(300),\n)\n\ntopic = sns.Topic(\n\u3000self, \"MyFirstTopic\",\n\u3000display_name=\"My First Topic\"\n)\n\ntopic.add_subscription(subs.SqsSubscription(queue))\n\nhello = HelloConstruct(self, \"MyHelloConstruct\", num_buckets=4)\nuser = iam.User(self, \"MyUser\")\nhello.grant_read(user)\n<\/pre>\n<ul>\n<li>hello\/hello_construct.py<\/li>\n<li>\u53ef\u5909\u6570\u306eS3\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/li>\n<\/ul>\n<pre>\n(.env)$ cat hello\/hello_construct.py\nfrom aws_cdk import (\n\u3000aws_iam as iam,\n\u3000aws_s3 as s3,\n\u3000core,\n)\n\nclass HelloConstruct(core.Construct):\n\n@property\ndef buckets(self):\nreturn tuple(self._buckets)\n\ndef __init__(self, scope: core.Construct, id: str, num_buckets: int) -&gt; None:\nsuper().__init__(scope, id)\nself._buckets = []\nfor i in range(0, num_buckets):\n\u3000self._buckets.append(s3.Bucket(self, f\"Bucket-{i}\"))\n\ndef grant_read(self, principal: iam.IPrincipal):\n\u3000for b in self.buckets:\n\u3000\u3000b.grant_read(principal, \"*\")\n<\/pre>\n<p><code>cdk ls<\/code>\u3067\u5229\u7528\u53ef\u80fd\u306a\u30a2\u30d7\u30ea\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\n$ cdk ls\nhello-cdk-1\nhello-cdk-2\n<\/pre>\n<p><code>cdk synth<\/code>\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u969b\u306b\u5229\u7528\u3059\u308b\u30a2\u30d7\u30ea\u3092CloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u6a19\u6e96\u51fa\u529b\u3055\u305b\u3001\u78ba\u8a8d\u3057\u307e\u3059\u3002<br \/>\n\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u3068yaml\u5f62\u5f0f\u306e\u305f\u3081\u3001json\u5f62\u5f0f\u3067\u51fa\u529b\u3057\u305f\u3044\u5834\u5408\u306b\u306f-j\u307e\u305f\u306f--json\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre>\ncdk synth hello-cdk-1\nResources:\nMyFirstQueueFF09316A:\nType: AWS::SQS::Queue\nProperties:\nVisibilityTimeout: 300\nMetadata:\naws:cdk:path: hello-cdk-1\/MyFirstQueue\/Resource\n...\n<\/pre>\n<p>\u3055\u3042\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\nAWS CDK\u30a2\u30d7\u30ea\u3092\u521d\u3081\u3066\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u5834\u5408\u306f\u300cbootstrap\u300d\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\nbootstrap\u306f\u30c4\u30fc\u30eb\u30ad\u30c3\u30c8\u306e\u64cd\u4f5c\u306b\u5fc5\u8981\u306a\u3082\u306e\u3060\u305d\u3046\u306a\u306e\u3067\u5fc5\u305a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>\n$ cdk bootstrap\n\u23f3 Bootstrapping environment aws:\/\/000000000000\/us-east-2...\n\u23f3 Bootstrapping environment aws:\/\/000000000000\/\/us-west-2...\n<\/pre>\n<p>\u4eca\u56de\u306f\u7c73\u56fd\u897f\u90e8(\u30aa\u30ec\u30b4\u30f3)\u306e\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre>\n$ cdk deploy hello-cdk-2\nThis deployment will make potentially sensitive changes according to your current security approval level (--require-approval broadening).\nPlease confirm you intend to make the following modifications:\n\nIAM Statement Changes\n\u250c\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 \u2502 Resource \u2502 Effect \u2502 Action \u2502 Principal \u2502 Condition \u2502\n\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 + \u2502 ${MyFirstQueu \u2502 Allow \u2502 sqs:SendMessa \u2502 Service:sns.a \u2502 \"ArnEquals\": { \u2502\n\u2502 \u2502 e.Arn} \u2502 \u2502 ge \u2502 mazonaws.com \u2502 \"aws:SourceA \u2502\n\u2502 \u2502 \u2502 \u2502 \u2502 \u2502 rn\": \"${MyFirs \u2502\n\u2502 \u2502 \u2502 \u2502 \u2502 \u2502 tTopic}\" \u2502\n\u2502 \u2502 \u2502 \u2502 \u2502 \u2502 } \u2502\n\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 + \u2502 ${MyHelloCons \u2502 Allow \u2502 s3:GetBucket* \u2502 AWS:${MyUser} \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 s3:GetObject* \u2502 \u2502 \u2502\n\u2502 \u2502 0.Arn} \u2502 \u2502 s3:List* \u2502 \u2502 \u2502\n\u2502 \u2502 ${MyHelloCons \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 0.Arn}\/* \u2502 \u2502 \u2502 \u2502 \u2502\n\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 + \u2502 ${MyHelloCons \u2502 Allow \u2502 s3:GetBucket* \u2502 AWS:${MyUser} \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 s3:GetObject* \u2502 \u2502 \u2502\n\u2502 \u2502 1.Arn} \u2502 \u2502 s3:List* \u2502 \u2502 \u2502\n\u2502 \u2502 ${MyHelloCons \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 1.Arn}\/* \u2502 \u2502 \u2502 \u2502 \u2502\n\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 + \u2502 ${MyHelloCons \u2502 Allow \u2502 s3:GetBucket* \u2502 AWS:${MyUser} \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 s3:GetObject* \u2502 \u2502 \u2502\n\u2502 \u2502 2.Arn} \u2502 \u2502 s3:List* \u2502 \u2502 \u2502\n\u2502 \u2502 ${MyHelloCons \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 2.Arn}\/* \u2502 \u2502 \u2502 \u2502 \u2502\n\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 + \u2502 ${MyHelloCons \u2502 Allow \u2502 s3:GetBucket* \u2502 AWS:${MyUser} \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 s3:GetObject* \u2502 \u2502 \u2502\n\u2502 \u2502 3.Arn} \u2502 \u2502 s3:List* \u2502 \u2502 \u2502\n\u2502 \u2502 ${MyHelloCons \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 truct\/Bucket- \u2502 \u2502 \u2502 \u2502 \u2502\n\u2502 \u2502 3.Arn}\/* \u2502 \u2502 \u2502 \u2502 \u2502\n\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\nDo you wish to deploy these changes (y\/n)? y\nhello-cdk-2: deploying...\nhello-cdk-2: creating CloudFormation changeset...\n0\/12 | 9:21:13 | CREATE_IN_PROGRESS | AWS::S3::Bucket | MyHelloConstruct\/Bucket-2 (MyHelloConstructBucket2C1DA3656)\n0\/12 | 9:21:13 | CREATE_IN_PROGRESS | AWS::S3::Bucket | MyHelloConstruct\/Bucket-0 (MyHelloConstructBucket0DAEC57E1)\n...\n\u2705 hello-cdk-2\nStack ARN:\narn:aws:cloudformation:us-west-2:000000000000:stack\/hello-cdk-2\/00000-00000\n<\/pre>\n<p>\u3053\u308c\u3067S3\u30d0\u30b1\u30c3\u30c8\u304c4\u3064\u3001SNS\u30c8\u30d4\u30c3\u30af\u304c1\u3064\u3001SQS\u30ad\u30e5\u30fc\u304c1\u3064\u3001\u4f5c\u6210\u3055\u308c\u308b\u306f\u305a\u3067\u3059<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f<\/p>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16740\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d.png\" alt=\"\" width=\"984\" height=\"397\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d.png 984w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d-300x121.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d-768x310.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/9e7fd4db12d49b049abd9e0908ce7d9d-728x294.png 728w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><\/a>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sqs-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16741\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sqs-1.png\" alt=\"\" width=\"748\" height=\"241\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sqs-1.png 748w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sqs-1-300x97.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sqs-1-728x235.png 728w\" sizes=\"auto, (max-width: 748px) 100vw, 748px\" \/><\/a>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sns-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16742\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sns-1.png\" alt=\"\" width=\"594\" height=\"308\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sns-1.png 594w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2019\/07\/sns-1-300x156.png 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/a>\n<h2>\u7591\u554f<\/h2>\n<p><code>cdk synth<\/code>\u306e\u30b3\u30de\u30f3\u30c9\u306e\u7528\u9014\u306b\u3064\u3044\u3066\u7591\u554f\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\nsynth\u306fsynthesize(\u5408\u6210)\u3068\u3044\u3046\u8a00\u8449\u306e\u610f\u5473\u304b\u3089\u63a8\u5bdf\u3057\u3066<br \/>\n\u6700\u521d\u306f\u30b9\u30bf\u30c3\u30af\u3092\u30cd\u30b9\u30c8\u3059\u308b\u7528\u9014\u3060\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001<br \/>\n\u3069\u3046\u3084\u3089\u305d\u3046\u3067\u306f\u306a\u304f\u3001<br \/>\n<code>cdk synth help<\/code>\u306b\u306f<br \/>\n<code>Synthesizes and prints the CloudFormation template for this stack<\/code><br \/>\n(\u3053\u306e\u30b9\u30bf\u30c3\u30af\u306eCloudFormation\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u5408\u6210\u3057\u3066\u51fa\u529b\u3057\u307e\u3059)\u3068\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u79c1\u306f\u3001\u5358\u7d14\u306b1\u3064\u306e\u30a2\u30d7\u30ea\u304b\u30891\u3064\u306eCloudFormation\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u308b\u3068\u3044\u3046\u7528\u9014\u304b\u3068\u601d\u3044\u3001<br \/>\n\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3001\u5b9f\u969b\u306b\u306f\u5168\u3066\u306e\u30a2\u30d7\u30ea\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u53c2\u8003\u306b\u3057\u305f\u30ef\u30fc\u30af\u30b7\u30e7\u30c3\u30d7\u306e\u4f8b\u306b\u3042\u308b<code>cdk synth hello-cdk-1<\/code>\u3068\u3044\u3046\u66f8\u304d\u65b9\u3060\u3068<br \/>\n\u307e\u308b\u3067hello-cdk-1\u3060\u3051\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u4f5c\u6210\u3055\u308c\u308b\u3088\u3046\u306b\u601d\u3044\u307e\u3059\u304c<br \/>\n\u5b9f\u306fhello-cdk-2\u3082\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5f15\u6570\u306a\u3057\u3067<code>cdk synth<\/code>\u3068\u5b9f\u884c\u3057\u3066\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b<code>cdk synth<\/code>\u4ee5\u5916\u306e<code>cdk ls<\/code>\u3001<code>cdk deploy<\/code>\u306e\u5404\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u6642\u306b\u3082<br \/>\ncdk.out\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u5168\u3066\u306e\u30b9\u30bf\u30c3\u30af\u306eCloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u4f5c\u6210\u3055\u308c\u308b(\u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u5168\u3066\u4e0a\u66f8\u304d)\u305f\u3081\u3001<\/p>\n<p><code>cdk synth<\/code>\u306fCloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u4f5c\u6210\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u8003\u3048\u308b\u3068\u3001\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306e\u5fc5\u8981\u6027\u304c\u8584\u304f\u3001<br \/>\n\u3042\u304f\u307e\u3067\u30c7\u30d7\u30ed\u30a4\u524d\u306b\u3001CloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6a19\u6e96\u51fa\u529b\u3055\u305b\u3066\u78ba\u8a8d\u3059\u308b\u7528\u9014\u304c\u30e1\u30a4\u30f3\u306a\u306e\u304b\u3068\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u306b\u95a2\u3057\u3066\u306f\u3069\u3053\u304b\u3067\u601d\u3044\u9055\u3044\u3092\u3057\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u3001\u5f15\u304d\u7d9a\u304d\u8abf\u67fb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS Cloud Development Kit(CDK)\u3067Python\u4f7f\u3063\u3066\u307f\u305f \u521d\u3081\u306b \u307f\u306a\u3055\u3093\u521d\u3081\u307e\u3057\u3066!!! \u30b9\u30ab\u30a4\u30a2\u30fc\u30c1\u306e\u77f3\u9ed2\u3068\u7533\u3057\u307e\u3059!! \u6700\u8fd1\u3053\u3093\u306a\u8a18\u4e8b\u3092\u898b\u304b\u3051\u307e\u3057\u305f\u3002 AWS Cloud Develop&#8230;<\/p>\n","protected":false},"author":1,"featured_media":16755,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"16727","footnotes":""},"categories":[20],"tags":[706,65],"class_list":{"0":"post-16727","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"tag-aws-cdk","9":"tag-python","10":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/16727","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=16727"}],"version-history":[{"count":17,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/16727\/revisions"}],"predecessor-version":[{"id":16749,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/16727\/revisions\/16749"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/16755"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=16727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=16727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=16727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}