この記事は約6分で読めます。
この記事は1年以上前に書かれたものです。
内容が古い可能性がありますのでご注意ください。
エンタープライズクラウド部の松田です。こんにちは。
今回は業務で行った技術検証の記録になります。
少々雑多な記事になりますがお付き合い頂けますと幸いです。
やりたいこと
- EC2インスタンスをSSMマネージドノードにしたい
- EC2インスタンスのOSログをCloudWatch Logsに出力したい
です。
一見簡単ですが、以下の前提があります。
- EC2インスタンスはRocky Linux 9を採用
- インターネット向けの通信は明示的に許可したドメイン以外は通信不可(Network FirewallによりBlock)
- EC2へのログインにはSession Managerを使用すること
言い換えると、要求を実現するために次のような課題があります。
- SSMエージェントとCloudWatchエージェントをどうやってインストールするか?
- SSMおよびCloudWatchのエンドポイントへの通信経路をどう準備するか?
各課題に対し、どのようにアプローチするかを考えます。
1. 各エージェントをどうやってインストールするか
今回採用したRocky LinuxのAMIにはSSMエージェントがプリインストールされていないため、ユーザー側でインストールする必要があります。インストールのためにログインしようにも、今回EC2インスタンスはプライベートサブネットに配置するため、直接SSHで接続することはできません。また、エージェントをインストールするためだけに踏み台を起動するのも面倒です。
ということで今回は、ユーザーデータでSSMエージェントとCloudWatchエージェントをインストールすることにします。
2. SSMおよびCloudWatchのエンドポイントへの通信経路をどう準備するか
Network Firewallで通信を許可するか、VPCエンドポイントを使用するかの2択があり得そうです。
明確に優劣はありませんが、今回はVPCエンドポイントを使うことにします。
やったこと
環境準備
検証用に、以下の環境を準備します。
VPCエンドポイントを配置することで、インターネットを介さず(言い換えればNetwork Firewallで検査されることなく)必要なAWSエンドポイントに到達できます。 配置したVPCエンドポイントと、用途は以下の通りです。
VPCエンドポイント (サービス名) |
用途 |
---|---|
SSM Messeges (com.amazonaws.ap-northeast-1.ssmmessages) |
セッションマネージャー用 |
EC2 Messages (com.amazonaws.ap-northeast-1.ec2messages) |
セッションマネージャー用 |
SSM (com.amazonaws.ap-northeast-1.ssm) |
セッションマネージャー用 パラメータストアからCloudWatchエージェントのコンフィグを取得する用 |
CloudWatch Logs (com.amazonaws.ap-northeast-1.logs) |
CloudWatch LogsにOSログを出力する用 |
S3 (com.amazonaws.ap-northeast-1.s3) |
SSMエージェントおよびCloudWatchエージェントのインストーラをダウンロードする用 ※これだけGateway型 |
なお環境構築に使用したCloudFormationテンプレートは本記事末に記載しています。
ネットワークの確認
まずはルーティングが意図した通りに設定されているかを確認するため、サブネット「protected-a」にAmazon Linux 2023のインスタンスを起動し、セッションマネージャーで接続できるか確認したところ、問題なく接続できました。
このことから、以下のことが言えます。
- EC2に付与するIAMロール(の権限)が正しいこと。
- 「protected-a」から以下のAWSのエンドポイントに到達できること。
- ssm
- ssmmessages
- ec2messages
なおこの時点では、インターネット向けの通信は全てNetwork FirewallによりBlockされる設定としていたため、インターネットを介してAWSのエンドポイントに到達できない状態でした。
AWSのエンドポイントへのアクセスが全てVPCエンドポイントを経由することを確認するため、念のため名前解決を行いましたが、プライベートIPアドレスが返ってきたので問題なさそうです。
[ssm-user@ip-10-156-64-80 ~]$ nslookup ssm.ap-northeast-1.amazonaws.com Server: 10.156.64.2 Address: 10.156.64.2#53 Non-authoritative answer: Name: ssm.ap-northeast-1.amazonaws.com Address: 10.156.64.73 Name: ssm.ap-northeast-1.amazonaws.com Address: 10.156.64.206 [ssm-user@ip-10-156-64-80 ~]$ nslookup ssmmessages.ap-northeast-1.amazonaws.com Server: 10.156.64.2 Address: 10.156.64.2#53 Non-authoritative answer: Name: ssmmessages.ap-northeast-1.amazonaws.com Address: 10.156.64.214 Name: ssmmessages.ap-northeast-1.amazonaws.com Address: 10.156.64.78 [ssm-user@ip-10-156-64-80 ~]$ nslookup ec2messages.ap-northeast-1.amazonaws.com Server: 10.156.64.2 Address: 10.156.64.2#53 Non-authoritative answer: Name: ec2messages.ap-northeast-1.amazonaws.com Address: 10.156.64.85 Name: ec2messages.ap-northeast-1.amazonaws.com Address: 10.156.64.200
Rocky Linuxで確認
上記のAmazon Linuxから、Rocky LinuxにSSH接続して色々確認します。
まず、SSMエージェントのインストーラがダウンロードできるか確認しておきます。SSMエージェントのインストーラがあるディレクトリにはS3エンドポイントからアクセスできるため、VPCエンドポイントがあればダウンロードできるはずです。
[ssm-user@ip-10-156-64-80 ~]$ curl -OL https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:23 --:--:-- 0 curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to s3.amazonaws.com:443
できない。。。
ということで色々調べてみたところ、S3のGateway型エンドポイントのサービス名がそもそも com.amazonaws.ap-northeast-1.s3
だということに気付きました。上記では s3.amazonaws.com
に対して curl
を実行していたため、VPCエンドポイントでなくインターネットに通信が向いてしまい、Network FirewallによってBlockされていたようです。
ドキュメントをよく読むと、S3のサービスエンドポイントは、リージョンを明示的に指定する形式に置き換えが可能でしたので、URLを書き換えて改めてダウンロードしてみます。
curl -OL https://s3.ap-northeast-1.amazonaws.com/amazon-ssm-ap-northeast-1/latest/linux_arm64/amazon-ssm-agent.rpm
うまくいきました。
続いて、CloudWatchエージェントのインストーラも以下でダウンロードできました。こちらもS3からのダウンロードなので、明示的にリージョンを指定します。(参考)。
curl -OL https://amazoncloudwatch-agent-ap-northeast-1.s3.ap-northeast-1.amazonaws.com/redhat/arm64/latest/amazon-cloudwatch-agent.rpm
ついでに確認したこと
Rocky Linuxで yum update
できるようにしたいので、Network Firewallで必要なドメインを許可する必要があります。とはいえどのドメインを許可すればよいか分からなかったので調べてみました。
色々調べた結果、/etc/yum.repos.d/
ディレクトリ内のファイルに書いてあった次のドメインをとりあえず許可してみることにしました。
mirrors.rockylinux.org
dl.rockylinux.org
この状態で一度 yum update
してみます。
[rocky@ip-10-156-64-71 ~]$ sudo yum update ^CRocky Linux 9 - BaseOS [ === ] --- B/s | 0 B --:-- ETRocky Linux 9 - BaseOS 0.0 B/s | 0 B 05:34 Errors during downloading metadata for repository 'baseos': - Curl error (28): Timeout was reached for http://mirror.nishi.network/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for http://mirror-nrt.yuki.net.uk/rockylinux/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for http://repo.jing.rocks/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for http://ftp.ubuntu-tw.net/mirror/rockylinux/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for https://ftp.jaist.ac.jp/pub/Linux/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation timed out after 30000 milliseconds with 0 out of 0 bytes received] - Curl error (35): SSL connect error for https://rocky-linux-asia-northeast2.production.gcp.mirrors.ctrliq.cloud/pub/rocky//9.3/BaseOS/aarch64/os/repodata/repomd.xml [error:0A000126:SSL routines::unexpected eof while reading] - Curl error (28): Timeout was reached for http://mirrors.asnet.am/rockylinux/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for https://ftp.iij.ad.jp/pub/linux/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation timed out after 30000 milliseconds with 0 out of 0 bytes received] - Curl error (28): Timeout was reached for http://mirror.ossplanet.net/mirror/rockylinux/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (35): SSL connect error for https://rocky-linux-asia-northeast1.production.gcp.mirrors.ctrliq.cloud/pub/rocky//9.3/BaseOS/aarch64/os/repodata/repomd.xml [error:0A000126:SSL routines::unexpected eof while reading] - Curl error (28): Timeout was reached for http://mirrors.ipserverone.com/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] - Curl error (28): Timeout was reached for http://ftp.udx.icscoe.jp/Linux/rocky/9.3/BaseOS/aarch64/os/repodata/repomd.xml [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds] Error: Failed to download metadata for repo 'baseos': Librepo was interrupted by a signal
残念ながらエラーになってしまいましたが、アクセスがBlockされたドメインを出力してくれたので、追加で以下のドメインを許可してリトライしてたところ、上手くいきました。
mirror.nishi.network
mirror-nrt.yuki.net.uk
repo.jing.rocks
ftp.ubuntu-tw.net
ftp.jaist.ac.jp
rocky-linux-asia-northeast2.production.gcp.mirrors.ctrliq.cloud
mirrors.asnet.am
ftp.iij.ad.jp
mirror.ossplanet.net
rocky-linux-asia-northeast1.production.gcp.mirrors.ctrliq.cloud
mirrors.ipserverone.com
ftp.udx.icscoe.jp
ユーザーデータでインストール
ここまでの確認で、少なくとも手動ではSSMエージェントとCloudWatchエージェントをインストールできる状況だということが分かりました。最後にユーザーデータを使って、EC2起動時に初めから各エージェントがインストールされた状態に持って行けるか確認します。
ユーザーデータは以下としました。
#!/bin/bash sudo yum update -y sudo dnf install -y https://s3.ap-northeast-1.amazonaws.com/amazon-ssm-ap-northeast-1/latest/linux_arm64/amazon-ssm-agent.rpm curl -OL https://amazoncloudwatch-agent-ap-northeast-1.s3.ap-northeast-1.amazonaws.com/redhat/arm64/latest/amazon-cloudwatch-agent.rpm sudo rpm -U ./amazon-cloudwatch-agent.rpm sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:cw-agent-config-rocky9
なお事前にSSMパラメータストアで cw-agent-config-rocky9
という名前で以下のパラメータを作成しています。ここではCloudWatch LogsにOSログを出力する設定だけ入れています。
{"logs": {"logs_collected": {"files": {"collect_list": [{"file_path": "/var/log/**.log","log_group_name": "rocky9","log_stream_name": "{instance_id}","retention_in_days": 731}]}}}}
EC2を起動後、何も設定せずともセッションマネージャーで接続できました。
CloudWatch Logsロググループへのログ出力も正常に行われていました。
ということで、ユーザーデータで各エージェントを無事インストールできました。
まとめ
検証の記録は以上です。
S3のVPCエンドポイントを利用する際はリージョンを明示的に指定する必要がある、というのは地味ながら要注意かもですね。
ここまでお付き合い頂き、ありがとうございました。
おまけ
検証環境の構築に使ったCloudFormationテンプレートを載せておきます。
ルートを設定するテンプレート(route.yaml)とそれ以外(network.yaml)とで、2つのテンプレートに分けています。ルートの記述でNetwork FirewallのエンドポイントIDを指定する必要があるのですが、カスタムリソースを使わないとIDが取得できなかったため、もうめんどくさくなって手動でIDを拾ってパラメータとして渡すやり方にしています。結果テンプレートが2つになりました。
ちなみにEC2インスタンスは含まれませんのでご了承ください。
- network.yaml
AWSTemplateFormatVersion: '2010-09-09'Resources:########################### Network Settings########################### VPCsVpc:Type: 'AWS::EC2::VPC'DeletionPolicy: DeleteProperties:CidrBlock: 10.156.64.0/24EnableDnsHostnames: 'true'EnableDnsSupport: 'true'Tags:- Key: NameValue: vpc# SubnetsSubnetPublicA:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1aCidrBlock: 10.156.64.32/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-public-aSubnetPublicC:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1cCidrBlock: 10.156.64.160/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-public-cSubnetInspectionA:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1aCidrBlock: 10.156.64.0/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-inspection-aSubnetInspectionC:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1cCidrBlock: 10.156.64.128/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-inspection-cSubnetProtectedA:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1aCidrBlock: 10.156.64.64/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-protected-aSubnetProtectedC:Type: 'AWS::EC2::Subnet'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcAvailabilityZone: ap-northeast-1cCidrBlock: 10.156.64.192/27MapPublicIpOnLaunch: 'false'Tags:- Key: NameValue: subnet-protected-c# GatewaysIgw:Type: 'AWS::EC2::InternetGateway'DeletionPolicy: DeleteProperties:Tags:- Key: NameValue: igwIgwAttach:Type: 'AWS::EC2::VPCGatewayAttachment'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcInternetGatewayId: !Ref IgwNgwA:Type: 'AWS::EC2::NatGateway'DeletionPolicy: DeleteProperties:AllocationId: !GetAtt- EipNgwA- AllocationIdSubnetId: !Ref SubnetPublicATags:- Key: NameValue: nat-aEipNgwA:Type: 'AWS::EC2::EIP'DeletionPolicy: DeleteProperties:Domain: vpcNgwC:Type: 'AWS::EC2::NatGateway'DeletionPolicy: DeleteProperties:AllocationId: !GetAtt- EipNgwC- AllocationIdSubnetId: !Ref SubnetPublicCTags:- Key: NameValue: nat-cEipNgwC:Type: 'AWS::EC2::EIP'DeletionPolicy: DeleteProperties:Domain: vpc# Route tables## For public subnetsRtbPublicA:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-public-aAssociationRtbPublicA:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetPublicARouteTableId: !Ref RtbPublicARtbPublicC:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-public-cAssociationRtbPublicC:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetPublicCRouteTableId: !Ref RtbPublicC## For inspection subnetsRtbInspectionA:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-inspection-aAssociationRtbInspectionA:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetInspectionARouteTableId: !Ref RtbInspectionARtbInspectionC:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-inspection-cAssociationRtbInspectionC:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetInspectionCRouteTableId: !Ref RtbInspectionC## For protected subnetsRtbProtectedA:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-protected-aAssociationRtbProtectedA:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetProtectedARouteTableId: !Ref RtbProtectedARtbProtectedC:Type: 'AWS::EC2::RouteTable'DeletionPolicy: DeleteProperties:VpcId: !Ref VpcTags:- Key: NameValue: rtb-protected-cAssociationRtbProtectedC:Type: 'AWS::EC2::SubnetRouteTableAssociation'DeletionPolicy: DeleteProperties:SubnetId: !Ref SubnetProtectedCRouteTableId: !Ref RtbProtectedC########################### VPC Endpoints########################### s3 endpointVpceS3:Type: AWS::EC2::VPCEndpointProperties:RouteTableIds:- !Ref RtbProtectedA- !Ref RtbProtectedCServiceName: com.amazonaws.ap-northeast-1.s3VpcEndpointType: GatewayVpcId: !Ref Vpc# ssm endpointVpceSSM:Type: AWS::EC2::VPCEndpointProperties:PrivateDnsEnabled: trueSecurityGroupIds:- !Ref ScgForEndpointServiceName: com.amazonaws.ap-northeast-1.ssmSubnetIds:- !Ref SubnetProtectedA- !Ref SubnetProtectedCVpcEndpointType: InterfaceVpcId: !Ref Vpc# ec2 messages endpointVpceEC2messages:Type: AWS::EC2::VPCEndpointProperties:PrivateDnsEnabled: trueSecurityGroupIds:- !Ref ScgForEndpointServiceName: com.amazonaws.ap-northeast-1.ec2messagesSubnetIds:- !Ref SubnetProtectedA- !Ref SubnetProtectedCVpcEndpointType: InterfaceVpcId: !Ref Vpc# ssm messages endpointVpceSSMessages:Type: AWS::EC2::VPCEndpointProperties:PrivateDnsEnabled: trueSecurityGroupIds:- !Ref ScgForEndpointServiceName: com.amazonaws.ap-northeast-1.ssmmessagesSubnetIds:- !Ref SubnetProtectedA- !Ref SubnetProtectedCVpcEndpointType: InterfaceVpcId: !Ref Vpc# cloudwatch logs endpointVpceLogs:Type: AWS::EC2::VPCEndpointProperties:PrivateDnsEnabled: trueSecurityGroupIds:- !Ref ScgForEndpointServiceName: com.amazonaws.ap-northeast-1.logsSubnetIds:- !Ref SubnetProtectedA- !Ref SubnetProtectedCVpcEndpointType: InterfaceVpcId: !Ref Vpc# Security Group for VPC EndpointScgForEndpoint:Type: AWS::EC2::SecurityGroupProperties:GroupDescription: for VPC EndpointGroupName: scg-vpc-endpointSecurityGroupIngress:- CidrIp: 10.156.0.0/16FromPort: 443ToPort: 443IpProtocol: tcpSecurityGroupEgress:- CidrIp: 0.0.0.0/0IpProtocol: -1Tags:- Key: NameValue: scg-vpc-endpointVpcId: !Ref Vpc########################### Firewall settings########################### Network firewallNetworkFirewall:Type: AWS::NetworkFirewall::FirewallProperties:DeleteProtection: TrueDescription: 'Shared Network Firewall'FirewallName: nfwFirewallPolicyArn: !Ref FirewallPolicy01FirewallPolicyChangeProtection: FalseSubnetChangeProtection: TrueSubnetMappings:- SubnetId: !Ref SubnetInspectionAIPAddressType: IPV4- SubnetId: !Ref SubnetInspectionCIPAddressType: IPV4Tags:- Key: NameValue: nfw-cbsi-prd-inspectionVpcId: !Ref Vpc# Firewall PolicyFirewallPolicy01:Type: AWS::NetworkFirewall::FirewallPolicyProperties:Description: 'for nfw-cbsi-prd-inspection'FirewallPolicy:StatefulDefaultActions:- aws:drop_established- aws:alert_establishedStatefulEngineOptions:RuleOrder: STRICT_ORDERStatefulRuleGroupReferences:- Priority: 1ResourceArn: !Ref FullopenStatelessDefaultActions:- aws:forward_to_sfeStatelessFragmentDefaultActions:- aws:forward_to_sfeFirewallPolicyName: nfw-policy01Tags:- Key: NameValue: nfw-policy01# Network Firewall LoggingNetworkFirewallLog:Type: AWS::NetworkFirewall::LoggingConfigurationProperties:FirewallArn: !Ref NetworkFirewallLoggingConfiguration:LogDestinationConfigs:- LogType: ALERTLogDestinationType: CloudWatchLogsLogDestination:logGroup: !Ref CloudWatchLogGroupAlert- LogType: FLOWLogDestinationType: CloudWatchLogsLogDestination:logGroup: !Ref CloudWatchLogGroupFlowCloudWatchLogGroupAlert:Type: 'AWS::Logs::LogGroup'DeletionPolicy: DeleteProperties:LogGroupName: nfw-alertRetentionInDays: 90Tags:- Key: NameValue: nfw-alertCloudWatchLogGroupFlow:Type: 'AWS::Logs::LogGroup'DeletionPolicy: DeleteProperties:LogGroupName: nfw-flowRetentionInDays: 90Tags:- Key: NameValue: nfw-flow## Rule Group#1Fullopen:Type: AWS::NetworkFirewall::RuleGroupProperties:RuleGroupName: rgp-fullopenDescription: 'for test'Type: STATEFULCapacity: 100RuleGroup:RulesSource:RulesSourceList:GeneratedRulesType: ALLOWLISTTargets:- .rockylinux.org- mirror.nishi.network- mirror-nrt.yuki.net.uk- repo.jing.rocks- ftp.ubuntu-tw.net- ftp.jaist.ac.jp- mirrors.asnet.am- ftp.iij.ad.jp- mirror.ossplanet.net- rocky-linux-asia-northeast2.production.gcp.mirrors.ctrliq.cloud- rocky-linux-asia-northeast1.production.gcp.mirrors.ctrliq.cloud- mirrors.ipserverone.com- ftp.udx.icscoe.jpTargetTypes:- TLS_SNI- HTTP_HOSTRuleVariables:IPSets:HOME_NET:Definition:- 10.156.0.0/16StatefulRuleOptions:RuleOrder: STRICT_ORDEROutputs:RtbPublicA:Value: !Ref RtbPublicAExport:Name: RtbPublicARtbPublicC:Value: !Ref RtbPublicCExport:Name: RtbPublicCRtbInspectionA:Value: !Ref RtbInspectionAExport:Name: RtbInspectionARtbInspectionC:Value: !Ref RtbInspectionCExport:Name: RtbInspectionCRtbProtectedA:Value: !Ref RtbProtectedAExport:Name: RtbProtectedARtbProtectedC:Value: !Ref RtbProtectedCExport:Name: RtbProtectedCIgw:Value: !Ref IgwExport:Name: IgwNgwA:Value: !Ref NgwAExport:Name: NgwANgwC:Value: !Ref NgwCExport:Name: NgwC
- routes.yaml
AWSTemplateFormatVersion: '2010-09-09'Parameters:FirewallEndpointA:Type: StringDescription: (Required) Enter NFW endpoint ID AZ-a!"FirewallEndpointC:Type: StringDescription: (Required) Enter NFW endpoint ID AZ-c!"Resources:# routes for public subnetsPublicRouteA0:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicADestinationCidrBlock: 0.0.0.0/0GatewayId: !ImportValue IgwPublicRouteA1:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicADestinationCidrBlock: 10.156.64.64/27VpcEndpointId: !Ref FirewallEndpointAPublicRouteA2:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicADestinationCidrBlock: 10.156.64.192/27VpcEndpointId: !Ref FirewallEndpointCPublicRouteC0:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicCDestinationCidrBlock: 0.0.0.0/0GatewayId: !ImportValue IgwPublicRouteC1:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicCDestinationCidrBlock: 10.156.64.192/27VpcEndpointId: !Ref FirewallEndpointCPublicRouteC2:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbPublicCDestinationCidrBlock: 10.156.64.64/27VpcEndpointId: !Ref FirewallEndpointA# routes for inspection subnetsInspectionRouteA0:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbInspectionADestinationCidrBlock: 0.0.0.0/0NatGatewayId: !ImportValue NgwAInspectionRouteC0:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbInspectionCDestinationCidrBlock: 0.0.0.0/0NatGatewayId: !ImportValue NgwC# routes for protected subnetsProtectedRouteA1:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbProtectedADestinationCidrBlock: 0.0.0.0/0VpcEndpointId: !Ref FirewallEndpointAProtectedRouteC1:Type: 'AWS::EC2::Route'DeletionPolicy: DeleteProperties:RouteTableId: !ImportValue RtbProtectedCDestinationCidrBlock: 0.0.0.0/0VpcEndpointId: !Ref FirewallEndpointC
松田 渓(記事一覧)
2021年10月入社。散歩が得意です。