About networking on Amazon MWAAのドキュメントを少し読む

MWAAの環境を構築するにあたり、まだMWAAのネットワーキングについて理解が曖昧だったので公式ドキュメントを読んでみます。

docs.aws.amazon.com

MWAAについて解消したい不明点

MWAAはパブリックサブネットに置くべきかプライベートサブネットに置くべきか

プライベートサブネットに置く方がMWAA自体はセキュアになると思うので、たぶんプライベートサブネットに配置しつつインターネットに通信する必要がある場合はNATゲートウェイで外部にアクセスする形になりそう。

ドキュメント読む

Terms

Public routingはインターネットにアクセス可能なVPCで、Private routingはインターネットにアクセスは発生しないVPCとのこと。

What's supported

The following table describes the types of Amazon VPCs Amazon MWAA supports.

Amazon VPC types Supported An Amazon VPC owned by the account that is attempting to create the environment. Yes

A shared Amazon VPC where multiple AWS accounts create their AWS resources. No

AWSアカウントが保有しているVPCにMWAAを構築予定なら問題なさそう。複数のAWSアカウントでシェアしているVPCにはMWAA環境は作成できない。

VPC infrastructure overview

When you create an Amazon MWAA environment, Amazon MWAA creates between one to two VPC endpoints for your environment based on the Apache Airflow access mode you chose for your environment. These endpoints appear as Elastic Network Interfaces (ENIs) with private IPs in your Amazon VPC. After these endpoints are created, any traffic destined to these IPs is privately or publicly routed to the corresponding AWS services used by your environment.

Airflowのaccess modeの設定によってMWAAの環境には一つか二つのVPCエンドポイントが作られる。
このエンドポイントはVPC内でプライベートIPを持つENIになる。
このエンドポイントが作成されたら、これらのIPへのトラフィックは対応するMWAAが使用しているAWSサービスにルーティングされる。

The following section describes the Amazon VPC infrastructure required to route traffic publicly over the Internet, or privately within your Amazon VPC.

VPCの外にルーティングする必要がある場合と、VPC内でルーティングする場合についての解説は以下。

今回はVPCの外にルーティングする必要があるのでその部分を読みます。

Public routing over the Internet

This section describes the Amazon VPC infrastructure of an environment with public routing. You'll need the following VPC infrastructure:

パブリックにルーティングする必要がある場合は以下のVPC infrastructureが必要になる。

  • One VPC security group.
    • A VPC security group acts as a virtual firewall to control ingress (inbound) and egress (outbound) network traffic on an instance.
    • Up to 5 security groups can be specified.

    • The security group must specify a self-referencing inbound rule to itself.

    • The security group must specify an outbound rule for all traffic (0.0.0.0/0).

    • The security group must allow all traffic in the self-referencing rule. For example, (Recommended) Example all access self-referencing security group .

    • The security group can optionally restrict traffic further by specifying the port range for HTTPS port range 443 and a TCP port range 5432. For example, (Optional) Example security group that restricts inbound access to port 5432 and (Optional) Example security group that restricts inbound access to port 443.

  • セキュリティグループが一つ必要。
  • セキュリティグループは最大5つまで指定できる。
  • セキュリティグループは自分を参照するインバウンドルールが必要。
  • セキュリティグループは0.0.0.0/0を許可するアウトバウンドルールが必要。
  • セキュリティグループは自分を参照しているルールではすべてのトラフィックを許可する必要がある。
  • セキュリティグループは任意でトラフィックHTTPSのポート443とTCPのポート5432に制限できる。
  • Two public subnets.
    A public subnet is a subnet that's associated with a route table that has a route to an Internet gateway.

    • Two public subnets are required. This allows Amazon MWAA to build a new container image for your environment in your other availability zone, if one container fails.

    • The subnets must be in different Availability Zones. For example, us-east-1a, us-east-1b.

    • The subnets must route to a NAT gateway (or NAT instance) with an Elastic IP Address (EIP).

    • The subnets must have a route table that directs internet-bound traffic to an Internet gateway.

  • パブリックサブネットが二つ必要。パブリックサブネットとはインターネットゲートウェイへのルートテーブルが関連づけられているサブネット。
  • サブネットは二つ必要。これにより、MWAAのコンテナが一つ落ちてももう一つのコンテナを別のAZでビルドできる。
  • サブネットは別のAZにする必要がある。(ap-northeast-1とap-northeast-3とか)
  • サブネットはEIPでNATゲートウェイにルーティングする必要がある。
  • サブネットはインターネット向けのトラフィックはIGWに向かわせるルートテーブルを持つ必要がある。
  • Two private subnets.
    A private subnet is a subnet that's not associated with a route table that has a route to an Internet gateway.

    • Two private subnets are required. This allows Amazon MWAA to build a new container image for your environment in your other availability zone, if one container fails.

    • The subnets must be in different Availability Zones. For example, us-east-1a, us-east-1b.

The subnets must have a route table to a NAT device (gateway or instance).

The subnets must not route to an Internet gateway.

  • プライベートサブネットはIGWへのルーティングを持つルートテーブルが関連づけられていないサブネットのこと。
  • 二つのプライベートサブネットが必要。これによりMWAAがコンテナが一つ落ちても別のAZで新しいコンテナをビルドできる。
  • サブネットは別のAZにする必要がある。
  • サブネットはNATへのルートテーブルを持ってはいけない。
  • サブネットはIGWへのルートを持ってはいけない。
  • A network access control list (ACL).
    An NACL manages (by allow or deny rules) inbound and outbound traffic at the subnet level.

    • The NACL must have an inbound rule that allows all traffic (0.0.0.0/0).

    • The NACL must have an outbound rule that denies all traffic (0.0.0.0/0).

    • For example, (Recommended) Example ACLs.

  • 一つのACLが必要。
  • ACLは全てのトラフィックを許可するインバウンドルールを持つ必要がある。
  • ACLは全てのトラフィックを許可するアウトバウンドルールを持つ必要がある。
  • Two NAT gateways (or NAT instances).
    A NAT device forwards traffic from the instances in the private subnet to the Internet or other AWS services, and then routes the response back to the instances.

    • The NAT device must be attached to a public subnet. (One NAT device per public subnet.)

    • The NAT device must have an Elastic IPv4 Address (EIP) attached to each public subnet.

  • 二つのNATゲートウェイ。NATデバイスはプライベートサブネットからのトラフィックをインターネットや他のAWSサービスに送り、レスポンスをインスタンスに返す。
  • NATデバイスはパブリックサブネットにアタッチされる必要がある。(それぞれのパブリックサブネットに一つのNATデバイス)
  • NATデバイスはパブリックサブネットにアタッチされているEIPを持つ必要がある。
  • 一つのインターネットゲートウェイ(IGW)。IGWはVPCをインターネットや他のAWSサービスに繋げる。
  • IGWはVPCにアタッチされている必要がある。

Example use cases for an Amazon VPC and Apache Airflow access mode

This section descibes the different use cases for network access in your Amazon VPC and the Apache Airflow Web server access mode you should choose on the Amazon MWAA console.

VPCのネットワークアクセスのユースケースごとにMWAAコンソールでどうAirflowのアクセスモードを選択するべきかを以下に記載。

今回は自分は新規VPCかつインターネットアクセスが許可されている場合のみ読む。

Internet access is allowed - new Amazon VPC network

If Internet access in your VPC is allowed by your organization, and you would like users to access your Apache Airflow Web server over the Internet:

  1. Create an Amazon VPC network with Internet access.

  2. Create an environment with the Public network access mode for your Apache Airflow Web server.

  3. What we recommend: We recommend using the AWS CloudFormation quick-start template that creates the Amazon VPC infrastructure, an Amazon S3 bucket, and an Amazon MWAA environment at the same time. To learn more, see Quick start tutorial for Amazon Managed Workflows for Apache Airflow.

VPCのインターネットアクセスが許可されていて、ユーザーにAirflow Webサーバーへのインターネットからのアクセスを許可したい場合:

  1. VPCネットワークをインターネットアクセスありで作成する
  2. MWAAの環境をApache Airflow Web serverのPublic networkアクセスモードで作成する
  3. 推奨事項: 便利なCfnテンプレートの紹介