続き!
そう!続!VPCとサブネットです!
(‘ω’)ノそして第4回!デデン!
なんで終わらなかったか!って言うと!
deployしてみたら、思ったようにできなかったからです!この辺がトライandエラーですね。
(´・ω・)いや、先に試してからブログに書けよ・・・
まぁあまりに意外だったので・・・そのままに続けちゃおうかなっと!
では前回の課題から
・Nameはつけられないのか?
・ネットワークACLや、ルートテーブルのカスタマイズできるの?
で、まずはNameから・・・これはタグにNameってつければ行くんじゃない?って思っています。
ネットワークACLや、ルートテーブルは少しお勉強が必要になるでしょうか・・・
ではACLから行きますかね!
ネットワークACLとは?
ネットワークACLと似たものとして、セキュリティグループがあります。良く比較しているサイトがありますね。
と言う訳でここでもやりますかね(´_ゝ`)ホーホッホ
って思ったけど・・・AWS公式ページに結構ちゃんと書いてあるので・・・いいかな・・・っと
と言う訳で以下がリンクですね。
セキュリティグループとネットワーク ACL を比較する
さて↑このページ見るとあれ?って思いますね

つまりはVPCでは?動作しない?って思いますね。
ネットワークアクセスコントロールリストを使用して、サブネットのトラフィックを制御する
更に、↑このページ・・・上記サイトクリックしてみちゃった人は特に以下の部分注目です!

そう無料(タダ)!ACLはタダなんです!で
↓このページも参照
ネットワーク ACL の基本

あーつまりVPCにはディフォルトACLが自動的に作られる。カスタムACLはサブネットにつける!
VPCのディフォルトACLはすべてのトラヒック(※1)を許可しますってことですね。
※1 トラヒックってのは、信号のことですね。良くトラヒックってAWSの公式では書いてあるけど私は信号って書いてくれた方が馴染み深い感じがしますね。
(´・ω・`)あれ?これイラナクネ?
あー…確かに、と言う訳で・・・VPCにつくACLは自動でいいし、作る必要ないね!って思いました。
(´_ゝ`)カスタムACLはサブネットにつけようね!
(´・ω・`)っていうか第4回の存在意義がナクね?
いやまだ、ルートテーブルがありますよ!
最後に、ディフォルトネットワークACLの説明は以下のリンクでお願いします!
デフォルトのネットワーク ACL
ルートテーブル
何のための回だったのか?そうルートテーブルのための回と言ってもいいでしょう!
(´・ω・)まぁALCがぽしゃっちゃったからね・・・
でルートテーブルですけど・・・名前の通りです。信号の通り道を作るためのものです。
ルートテーブルを作るには。。。
・CfnRouteTable
・CfnRoute
を使えばよさそう・・・
名前みたら大体想像できると思いますが、CfnRouteTableがルートテーブル本体を作るCunstructです。
CfnRouteはルートテーブルと、ネットワークインタフェースを関連付ける(ルートを作る)Cunstructです。
今回作成を予定しているネットワークインタフェースは、インターネットゲートウェイとVPC内はすべてルートが通る(vpc-local)の2つです。
調べてみたらvpc-localについては、ディフォルトで作られるようですので、作成不要。
自分で作らないといけないのは、インターネットゲートウェイになります。
インターネットゲートウェイのConstructは、CfnInternetGatewayになります。
手順としては、
①ルートテーブルを作る。
②インターネットゲートウェイを作る。
③ルートを作る。(CfnRouteで①と②を関連付ける。)
になります。図にしてみると以下のイメージですね。

CDKにしてみる
調べも済んだので、CDKに落とし込んでいきましょう。
ラッパー関数は以下の3つ追加。
・MyRouteTable
・MyRoute
・MyInternetGateway
IFデータ構成も以下3つを追加しました。
・MyRouteTableIF
・MyRouteIF
・MyInternetGatewayIF
パラメータリストは以下の感じになります。
01:---
02:common:
03: region: ap-northeast-1
04: account : "123456789088"
05: tags :
06: commontag1: "commontags-value1"
07: commontag2: "commontags-value2"
08:firstvpc:
09: vpcs:
10: first-vpc:
11: construct_id: "firstvpc"
12: cidr_block: "10.0.0.0/16"
13: enable_dns_hostnames: True
14: enable_dns_support: True
15: instance_tenancy: "default"
16: tags:
17: Name: "first-vpc"
18: vpctag1: "vpctag-value1"
19: vpctag2: "vpctag-value2"
20: route_tables:
21: first-public-routetbl:
22: construct_id: "first-public-routetbl"
23: #vpc_id: ""
24: tags:
25: Name: "first-vpc-pub-routetbl"
26: routetbl-pub-tag1: "routetbl-pub-value1"
27: routetbl-pub-tag2: "routetbl-pub-value2"
28: first-private-routetbl:
29: construct_id: "first-private-routetbl"
30: #vpc_id: ""
31: tags:
32: Name: "first-vpc-pri-routetbl"
33: routetbl-pri-tag1: "routetbl-pri-value1"
34: routetbl-pri-tag2: "routetbl-pri-value2"
35: igws:
36: first-igw:
37: construct_id: "first-igw"
38: tags:
39: Name: "first-vpc-igw"
40: igwtag1: "igwtag-value1"
41: igwtag2: "igwtag-value2"
42: routes:
43: first-igw-rute:
44: construct_id: "first-igw-rute"
45: #route_table_id: ""
46: gateway_id: "first-igw"
赤字の部分(23、30、45行目)は、これから作るので設定できないので・・・コメントアウトしてあります。この部分はあとで作ってから設定します。
青字の部分(17、25、32、39行目)は、タグに”Name”を指定したらどうなるかを確認するために追加してます。
デプロイが上手くいったらAWSコンソール画面で確認してみましょう~
でパート①からの引き続きで、「first_vpc_stack.py」を修正します。
01:from aws_cdk import Stack
02:from constructs import Construct
03:
04:from core.myconstructs.ec2.myInternetgateway import MyInternetGateway
05:from core.myconstructs.ec2.myroute import MyRoute
06:from core.myconstructs.ec2.myroutetable import MyRouteTable
07:from core.myconstructs.ec2.myvpc import MyVpc
08:from core.servicetypes.first_vpc_types import FirstVpcTypes
09:
10:
11:class FirstVpcStack(Stack):
12: def __init__(
13: self, scope: Construct, construct_id: str,myif: FirstVpcTypes, **kwargs
14: ) -> None:
15: super().__init__(scope, construct_id, **kwargs)
16: #VPC
17: vpfif=myif.firstvpc.vpcs['first-vpc']
18: firstvpc=MyVpc(self,vpfif.construct_id,myif=vpfif)
19: #route-table public
20: pub_routetblif=myif.firstvpc.route_tables['first-public-routetbl']
21: pub_routetblif.vpc_id=firstvpc.rsc.attr_vpc_id
22: firstpubroutetbl=MyRouteTable(self,pub_routetblif.construct_id,myif=pub_routetblif)
23: #route-table private
24: pri_routetblif=myif.firstvpc.route_tables['first-private-routetbl']
25: pri_routetblif.vpc_id=firstvpc.rsc.attr_vpc_id
26: firstpriroutetbl=MyRouteTable(self,pri_routetblif.construct_id,myif=pri_routetblif)
27: #igw
28: igwif=myif.firstvpc.igws['first-igw']
29: firstigw=MyInternetGateway(self,igwif.construct_id,myif=igwif)
30: #route-igw
31: routeigwif=myif.firstvpc.routes['first-igw-rute']
32: routeigwif.route_table_id=firstpubroutetbl.rsc.attr_route_table_id
33: routeigwif.gateway_id=firstigw.rsc.attr_internet_gateway_id
34: routeigw = MyRoute(self, myif=routeigwif)
赤字は追加部分です。
青字(21、25、33行目)は先に書いたようにまだなくて設定できなかったパラメータを設定している部分です。
で最後は、メインのapp.pyは・・・は変更なしです。でも以下に記載しておきます。
#!/usr/bin/env python3
import os
from aws_cdk import App,Environment
from core.utils.configread import configread
from core.servicetypes.first_vpc_types import FirstVpcTypes
from core.first_vpc_stack import FirstVpcStack
app = App()
tmpif=FirstVpcTypes(**configread("core/parameters/first_vpc_params.yaml"))
env=Environment(region=tmpif.common.region,account=tmpif.common.account)
FirstVpcStack(app,"FirstVpcStack",myif=tmpif,env=env)
app.synth()
で、できたコードをcdk synthしてcdk deployの流れです。
cdk synthは省略します。
でcdk deployの前に、cdk diffしてみます。
> cdk diff
Stack FirstVpcStack
Parameters
[+] Parameter BootstrapVersion BootstrapVersion: {"Type":"AWS::SSM::Parameter::Value<String>","Default":"/cdk-bootstrap/hnb659fds/version","Description":"Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"}
Resources
[+] AWS::EC2::VPC firstvpc/firstvpc firstvpc4F2EE15C
[+] AWS::EC2::RouteTable first-public-routetbl/first-public-routetbl firstpublicroutetbl5BE2A638
[+] AWS::EC2::RouteTable first-private-routetbl/first-private-routetbl firstprivateroutetblE7B32141
[+] AWS::EC2::InternetGateway first-igw/first-igw firstigw2B5EC158
[+] AWS::EC2::Route first-igw-rute/first-igw-rute firstigwrute842311B0
✨ Number of stacks with differences: 1
でcdk deploy・・・
cdk deploy
✨ Synthesis time: 7.59s
FirstVpcStack: deploying... [1/1]
FirstVpcStack: creating CloudFormation changeset...
FirstVpcStack | 0/7 | 21:26:16 | REVIEW_IN_PROGRESS | AWS::CloudFormation::Stack | FirstVpcStack User Initiated
FirstVpcStack | 0/7 | 21:26:22 | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | FirstVpcStack User Initiated
FirstVpcStack | 0/7 | 21:26:24 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw/first-igw (firstigw2B5EC158)
FirstVpcStack | 0/7 | 21:26:24 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
FirstVpcStack | 0/7 | 21:26:24 | CREATE_IN_PROGRESS | AWS::EC2::VPC | firstvpc/firstvpc (firstvpc4F2EE15C)
FirstVpcStack | 0/7 | 21:26:25 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) Resource creation Initiated
FirstVpcStack | 0/7 | 21:26:25 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw/first-igw (firstigw2B5EC158) Resource creation Initiated
FirstVpcStack | 1/7 | 21:26:25 | CREATE_COMPLETE | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
FirstVpcStack | 1/7 | 21:26:26 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw/first-igw (firstigw2B5EC158) Eventual consistency check initiated
FirstVpcStack | 1/7 | 21:26:26 | CREATE_IN_PROGRESS | AWS::EC2::VPC | firstvpc/firstvpc (firstvpc4F2EE15C) Resource creation Initiated
FirstVpcStack | 2/7 | 21:26:37 | CREATE_COMPLETE | AWS::EC2::VPC | firstvpc/firstvpc (firstvpc4F2EE15C)
FirstVpcStack | 2/7 | 21:26:38 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl/first-public-routetbl (firstpublicroutetbl5BE2A638)
FirstVpcStack | 2/7 | 21:26:38 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl/first-private-routetbl (firstprivateroutetblE7B32141)
FirstVpcStack | 2/7 | 21:26:40 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl/first-private-routetbl (firstprivateroutetblE7B32141) Resource creation Initiated
FirstVpcStack | 2/7 | 21:26:40 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl/first-public-routetbl (firstpublicroutetbl5BE2A638) Resource creation Initiated
FirstVpcStack | 2/7 | 21:26:40 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl/first-public-routetbl (firstpublicroutetbl5BE2A638) Eventual consistency check initiated
FirstVpcStack | 2/7 | 21:26:40 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl/first-private-routetbl (firstprivateroutetblE7B32141) Eventual consistency check initiated
FirstVpcStack | 3/7 | 21:26:41 | CREATE_COMPLETE | AWS::EC2::InternetGateway | first-igw/first-igw (firstigw2B5EC158)
FirstVpcStack | 4/7 | 21:26:50 | CREATE_COMPLETE | AWS::EC2::RouteTable | first-public-routetbl/first-public-routetbl (firstpublicroutetbl5BE2A638)
FirstVpcStack | 5/7 | 21:26:50 | CREATE_COMPLETE | AWS::EC2::RouteTable | first-private-routetbl/first-private-routetbl (firstprivateroutetblE7B32141)
FirstVpcStack | 5/7 | 21:26:51 | CREATE_IN_PROGRESS | AWS::EC2::Route | first-igw-rute/first-igw-rute (firstigwrute842311B0)
FirstVpcStack | 5/7 | 21:26:52 | CREATE_FAILED | AWS::EC2::Route | first-igw-rute/first-igw-rute (firstigwrute842311B0) Resource handler returned message: "You must provide one of destinationCidrBlock or destinationIpv6CidrBlock or destinationPrefixList and a valid routeTableId" (RequestToken: c30622ff-0b1b-ca9b-e14a-92e1c6ccb1d0, HandlerErrorCode: InvalidRequest)
FirstVpcStack | 5/7 | 21:26:52 | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | FirstVpcStack The following resource(s) failed to create: [firstigwrute842311B0]. Rollback requested by user.
(。-`ω-)アララ。。。エラーが・・・
・・・っとこのように失敗するとエラーがでます。
(´・ω・`)当たり前やろそれ・・・
最終的に何が悪かったのかでます。
The stack named FirstVpcStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "You must provide one of destinationCidrBlock or destinationIpv6CidrBlock or destinationPrefixList and a valid routeTableId" (RequestToken: c30622ff-0b1b-ca9b-e14a-92e1c6ccb1d0, HandlerErrorCode: InvalidRequest)
↑returned message:の後のメッセージをみて、何で怒っているのか確認します。
returned message: “You must provide one of destinationCidrBlock or destinationIpv6CidrBlock or destinationPrefixList and a valid routeTableId”
「destinationCidrBlockまたはdestinationIpv6CidrBlockまたはdestinationPrefixList のいずれかと有効なrouteTableIdを指定する必要があります」
と・・・(-_-)う~ん。
有効なルートテーブルのIDと、IPv4 CIDRブロック、IPv6 CIDRブロック、Prefixリストのどれかを指定しないとだめですよ!ってことなんかな?確かにパラメータリストでは以下の感じで指定はしてないですね・・・
42: routes:
43: first-igw-rute:
44: construct_id: "first-igw-rute"
45: #route_table_id: ""
46: gateway_id: "first-igw"
じゃ指定すっか?ってことでIPv4 CIDRブロックの指定を追加しました。
42: routes:
43: first-igw-rute:
44: construct_id: "first-igw-rute"
45: #route_table_id: ""
46: gateway_id: "first-igw"
47: destination_cidr_block: "10.0.0.0/16"
で再度deployしたら以下のエラーが・・・
(#゚Д゚)ムウウ・・・
今度は以下でした・・・
The stack named FirstVpcStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "route table rtb-0cf44e5d992a83215 and network gateway igw-0b48bbdf57d2adb66 belong to different networks (Service: Ec2, Status Code: 400, Request ID: 4f30b297-a3b5-49cc-8ff1-40a543f3d376)" (RequestToken: c1fe6e22-7530-b24d-f5e0-dd8d2c18ded7, HandlerErrorCode: GeneralServiceException)
何を怒っているんでしょう・・・
route table rtb-0cf44e5d992a83215 and network gateway igw-0b48bbdf57d2adb66 belong to different networks
「ルートテーブル rtb-0cf44e5d992a83215 とネットワークゲートウェイ igw-0b48bbdf57d2adb66 は異なるネットワークに属しています」
「異なるネットワーク」?とな?
(´・ω・)なんじゃろのぉ~
色々調べてみますと!インタネットゲートウェイは作っただけではダメ!VPCに関連付けないといけないみたいです。関連してないので、「異なるネットワーク」みたいな事みたいですね。
で、関連付けるのに以下のConstructを使います。
・CfnVPCGatewayAttachment
なんともそれっぽい名前ですね。でこいつのラッパー関数、IF構造体、パラメータを追加しました。
ラッパー関数と、IF構造体は省略してパラメータの変更部分だけ書いておきます。
48: vpcgatewayattachs:
49: first-vpcgatewayattach:
50: construct_id: "first-vpcgatewayattach"
51: #vpc_id: ""
52: #internet_gateway_id: ""
53: #vpn_gateway_id: ""
パラメータとして設定しているのは、construct_idだけですね。後はパラメータの段階では決まってないので、コメントアウトした状態で書いておきます。
first_vpc_stack.pyは以下の部分を追加です。
01:from aws_cdk import Stack
02:from constructs import Construct
03:
04:from core.myconstructs.ec2.myInternetgateway import MyInternetGateway
05:from core.myconstructs.ec2.myroute import MyRoute
06:from core.myconstructs.ec2.myroutetable import MyRouteTable
07:from core.myconstructs.ec2.myvpc import MyVpc
08:from core.myconstructs.ec2.myvpc_gateway_attachment import MyVPCGatewayAttachment
09:from core.servicetypes.first_vpc_types import FirstVpcTypes
~ 省略 ~
36: #vpcgatewayattach
37: vpcgatewayattachif=myif.firstvpc.vpcgatewayattachs['first-vpcgatewayattach']
38: vpcgatewayattachif.vpc_id=firstvpc.rsc.attr_vpc_id
39: vpcgatewayattachif.internet_gateway_id=routeigw.rsc.gateway_id
40: vpcgatewayattach=MyVPCGatewayAttachment(self,vpcgatewayattachif.construct_id,myif=vpcgatewayattachif)
38、39行目でvpc_idと、インターネットゲートウェイIDを設定してます。
で40行目で生成する流れです。
で再度deployです。
( `ー´)ノよっし今度こそ!(;´Д`)
・・・がまた以下のエラー・・・これがトライあんどエラー(;´Д`)
( ;∀;)ガーン!
The stack named FirstVpcStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "The destination CIDR block 10.0.0.0/16 is equal to or more specific than one of this VPC's CIDR blocks. This route can target only an interface or an instance. (Service: Ec2, Status Code: 400, Request ID: 8b249508-2010-4301-b230-0bd675ac1947)" (RequestToken: 64bbade9-b0f7-6912-74c6-24d4e9ad9b67, HandlerErrorCode: GeneralServiceException)
今度はなんだ・・・
The destination CIDR block 10.0.0.0/16 is equal to or more specific than one of this VPC’s CIDR blocks.This route can target only an interface or an instance.
「宛先 CIDR ブロック 10.0.0.0/16 は、この VPC の CIDR ブロックの 1 つと等しいか、より具体的です。このルートはインターフェースまたはインスタンスのみをターゲットにできます。」
とのこと・・・適当にVPCのIPv4 CIDRブロック(10.0.0.0/16)を指定したのがまずかったか?
(´・ω・)いや、たぶんソレやろ!適当に指定すんなや~
インタネットゲートウェイが存在するVPCを宛先に指定してもダメってこと?って思いました。
インタネットゲートウェイは基本外部のインターネットと接続するためのものなので、外部(0.0.0.0/0)を指定してあげないとダメっぽいです。
と言う訳で以下のパラメータを変更して・・・deployの流れですが・・・これで最後になると思うので、synth->diff->deployの流れで行きます。
42: routes:
43: first-igw-rute:
44: construct_id: "first-igw-rute"
45: #route_table_id: ""
46: gateway_id: "first-igw"
47: destination_cidr_block: "0.0.0.0/0"
synth~
> cdk synth
Resources:
firstvpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
InstanceTenancy: default
Tags:
- Key: Name
Value: first-vpc
- Key: vpctag1
Value: vpctag-value1
- Key: vpctag2
Value: vpctag-value2
Metadata:
aws:cdk:path: FirstVpcStack/firstvpc
firstpublicroutetbl:
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: first-vpc-pub-routetbl
- Key: routetbl-pub-tag1
Value: routetbl-pub-value1
- Key: routetbl-pub-tag2
Value: routetbl-pub-value2
VpcId:
Fn::GetAtt:
- firstvpc
- VpcId
Metadata:
aws:cdk:path: FirstVpcStack/first-public-routetbl
firstprivateroutetbl:
Type: AWS::EC2::RouteTable
Properties:
Tags:
- Key: Name
Value: first-vpc-pri-routetbl
- Key: routetbl-pri-tag1
Value: routetbl-pri-value1
- Key: routetbl-pri-tag2
Value: routetbl-pri-value2
VpcId:
Fn::GetAtt:
- firstvpc
- VpcId
Metadata:
aws:cdk:path: FirstVpcStack/first-private-routetbl
firstigw:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: igwtag1
Value: igwtag-value1
- Key: igwtag2
Value: igwtag-value2
- Key: Name
Value: first-vpc-igw
Metadata:
aws:cdk:path: FirstVpcStack/first-igw
firstigwrute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Fn::GetAtt:
- firstigw
- InternetGatewayId
RouteTableId:
Fn::GetAtt:
- firstpublicroutetbl
- RouteTableId
Metadata:
aws:cdk:path: FirstVpcStack/first-igw-rute
firstvpcgatewayattach:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId:
Fn::GetAtt:
- firstigw
- InternetGatewayId
VpcId:
Fn::GetAtt:
- firstvpc
- VpcId
Metadata:
aws:cdk:path: FirstVpcStack/first-vpcgatewayattach
CDKMetadata:
Type: AWS::CDK::Metadata
Properties:
Analytics: v2:deflate64:H4sIAAAAAAAA/z2LQQqDMBBFz+I+mdYUD1CyKN2Jlm7LmI6YqhNIRkTEu5fW0tXnPd43kBcFHDOck3bPXg++gbUWdL3COT3IGVhty/fSKttyFSahGzYDfejKQpFJLig04/IP1H746bMIum4klu1bUApTdLSpcpEu8OEEuYEieyXvdZxY/EhQ7fsGEPU9yZ0AAAA=
Metadata:
aws:cdk:path: FirstVpcStack/CDKMetadata/Default
Parameters:
BootstrapVersion:
Type: AWS::SSM::Parameter::Value<String>
Default: /cdk-bootstrap/hnb659fds/version
Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]
diff~
> cdk diff
Stack FirstVpcStack
Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)
Could not create a change set, will base the diff on template differences (run again with -v to see the reason)
Resources
[-] AWS::EC2::VPC firstvpc/firstvpc firstvpc4F2EE15C destroy
[-] AWS::EC2::RouteTable first-public-routetbl/first-public-routetbl firstpublicroutetbl5BE2A638 destroy
[-] AWS::EC2::RouteTable first-private-routetbl/first-private-routetbl firstprivateroutetblE7B32141 destroy
[-] AWS::EC2::InternetGateway first-igw/first-igw firstigw2B5EC158 destroy
[-] AWS::EC2::Route first-igw-rute/first-igw-rute firstigwrute842311B0 destroy
[+] AWS::EC2::VPC firstvpc firstvpc
[+] AWS::EC2::RouteTable first-public-routetbl firstpublicroutetbl
[+] AWS::EC2::RouteTable first-private-routetbl firstprivateroutetbl
[+] AWS::EC2::InternetGateway first-igw firstigw
[+] AWS::EC2::Route first-igw-rute firstigwrute
[+] AWS::EC2::VPCGatewayAttachment first-vpcgatewayattach firstvpcgatewayattach
✨ Number of stacks with differences: 1
deploy~
> cdk deploy
✨ Synthesis time: 6.22s
FirstVpcStack: start: Building 2239dc7b32b718a697667de2b0d54d6311861c3ea3ed3ad8d9ddcd1e58da7960:123456789099-ap-northeast-1
FirstVpcStack: success: Built 2239dc7b32b718a697667de2b0d54d6311861c3ea3ed3ad8d9ddcd1e58da7960:123456789099-ap-northeast-1
FirstVpcStack: start: Publishing 2239dc7b32b718a697667de2b0d54d6311861c3ea3ed3ad8d9ddcd1e58da7960:123456789099-ap-northeast-1
FirstVpcStack: success: Published 2239dc7b32b718a697667de2b0d54d6311861c3ea3ed3ad8d9ddcd1e58da7960:123456789099-ap-northeast-1
FirstVpcStack: deploying... [1/1]
FirstVpcStack: creating CloudFormation changeset...
FirstVpcStack | 0/8 | 18:43:48 | REVIEW_IN_PROGRESS | AWS::CloudFormation::Stack | FirstVpcStack User Initiated
FirstVpcStack | 0/8 | 18:43:54 | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | FirstVpcStack User Initiated
FirstVpcStack | 0/8 | 18:43:56 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
FirstVpcStack | 0/8 | 18:43:56 | CREATE_IN_PROGRESS | AWS::EC2::VPC | firstvpc
FirstVpcStack | 0/8 | 18:43:56 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw (firstigw)
FirstVpcStack | 0/8 | 18:43:58 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw (firstigw) Resource creation Initiated
FirstVpcStack | 0/8 | 18:43:58 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) Resource creation Initiated
FirstVpcStack | 1/8 | 18:43:58 | CREATE_COMPLETE | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
FirstVpcStack | 1/8 | 18:43:58 | CREATE_IN_PROGRESS | AWS::EC2::VPC | firstvpc Resource creation Initiated
FirstVpcStack | 1/8 | 18:43:58 | CREATE_IN_PROGRESS | AWS::EC2::InternetGateway | first-igw (firstigw) Eventual consistency check initiated
FirstVpcStack | 2/8 | 18:44:10 | CREATE_COMPLETE | AWS::EC2::VPC | firstvpc
FirstVpcStack | 2/8 | 18:44:11 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl (firstprivateroutetbl)
FirstVpcStack | 2/8 | 18:44:11 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl (firstpublicroutetbl)
FirstVpcStack | 2/8 | 18:44:12 | CREATE_IN_PROGRESS | AWS::EC2::VPCGatewayAttachment | first-vpcgatewayattach (firstvpcgatewayattach)
FirstVpcStack | 2/8 | 18:44:12 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl (firstprivateroutetbl) Resource creation Initiated
FirstVpcStack | 2/8 | 18:44:12 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl (firstpublicroutetbl) Resource creation Initiated
FirstVpcStack | 2/8 | 18:44:13 | CREATE_IN_PROGRESS | AWS::EC2::VPCGatewayAttachment | first-vpcgatewayattach (firstvpcgatewayattach) Resource creation Initiated
FirstVpcStack | 2/8 | 18:44:13 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-private-routetbl (firstprivateroutetbl) Eventual consistency check initiated
FirstVpcStack | 2/8 | 18:44:13 | CREATE_IN_PROGRESS | AWS::EC2::RouteTable | first-public-routetbl (firstpublicroutetbl) Eventual consistency check initiated
FirstVpcStack | 3/8 | 18:44:14 | CREATE_COMPLETE | AWS::EC2::InternetGateway | first-igw (firstigw)
FirstVpcStack | 4/8 | 18:44:15 | CREATE_COMPLETE | AWS::EC2::VPCGatewayAttachment | first-vpcgatewayattach (firstvpcgatewayattach)
FirstVpcStack | 5/8 | 18:44:23 | CREATE_COMPLETE | AWS::EC2::RouteTable | first-public-routetbl (firstpublicroutetbl)
FirstVpcStack | 6/8 | 18:44:23 | CREATE_COMPLETE | AWS::EC2::RouteTable | first-private-routetbl (firstprivateroutetbl)
FirstVpcStack | 6/8 | 18:44:24 | CREATE_IN_PROGRESS | AWS::EC2::Route | first-igw-rute (firstigwrute)
FirstVpcStack | 6/8 | 18:44:25 | CREATE_IN_PROGRESS | AWS::EC2::Route | first-igw-rute (firstigwrute) Resource creation Initiated
FirstVpcStack | 7/8 | 18:44:26 | CREATE_COMPLETE | AWS::EC2::Route | first-igw-rute (firstigwrute)
FirstVpcStack | 8/8 | 18:44:27 | CREATE_COMPLETE | AWS::CloudFormation::Stack | FirstVpcStack
✅ FirstVpcStack
✨ Deployment time: 47.06s
Stack ARN:
arn:aws:cloudformation:ap-northeast-1:123456789099:stack/FirstVpcStack/5cc01850-e6ca-11ef-beab-0a76a85c01d7
✨ Total time: 53.28s
ついに出ました!SUCCESSです!
(´▽`)ワーパチパチ!
っとVPC作るだけでもサッとできないよ!っていう事例でしたね!
できたものをAWSコンソールで確認しよう
これ!大切!やっておかないと後で何ができたかよく分からんチンになるのでやりましょう!
まずVPC、Nameがちゃんと入っていますね~

VPC詳細です~

ルートテーブル

パブリックルートテーブル詳細

プライベートルートテーブル詳細

インターネットゲートウェイ

インターネットゲートウェイ詳細

( ゚Д゚)?!あれ?!これで終わり?サブネットはぁ!?
うん。覚えてる覚えてる・・・でも次はこれまでの反省会と改善についてになるかな・・・
でも、いづれはやるので・・・
今回のGITはこちらです!
次回は、「いちはじCDK第5回 見直しと改善」です。良かったら寄って下さい。
コメント