

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Amazon MWAA での独自の Amazon VPC エンドポイントの管理
<a name="vpc-endpoint-management"></a>

Amazon MWAA は Amazon VPC エンドポイントを使用して、Apache Airflow 環境のセットアップに必要なさまざまな AWS サービスと統合します。独自のエンドポイントの管理には、主に 2 つのユースケースがあります。

1. つまり、 を使用して複数の [AWS Organizations](https://aws.amazon.com/organizations/)を管理し AWS アカウント 、リソースを共有するときに、共有 Amazon VPC に Apache Airflow 環境を作成できます。

1. アクセス許可をエンドポイントを使用する特定のリソースに絞り込むことで、より制限の厳しいアクセスポリシーを使用できるようになります。

独自の VPC エンドポイントを管理する場合は、環境 RDS for PostgreSQL データベースと環境ウェブサーバー用に独自のエンドポイントを作成する責任があります。

Amazon MWAA がクラウドに Apache Airflow をデプロイする方法の詳細については、 [Amazon MWAA アーキテクチャ図](what-is-mwaa.md#architecture-mwaa) を参照してください。

**重要**  
Amazon MWAA は、カスタマー管理エンドポイントの IP アドレスタイプ (`AddressType`) の選択を検証しないため、正しく `AddressType` を指定するようにしてください (有効なオプションは IPv4 または IPv6 です)。



## 共有 Amazon VPC での環境の作成
<a name="configure-shared-vpc"></a>

[AWS Organizations](https://aws.amazon.com/organizations/) を使用してリソース AWS アカウント を共有する複数の を管理する場合は、Amazon MWAA でカスタマーマネージド VPC エンドポイントを使用して、組織内の別のアカウントと環境リソースを共有できます。

共有 VPC アクセスを設定すると、メインの Amazon VPC を所有するアカウント (*所有者*) は、Amazon MWAA に必要な 2 つのプライベートサブネットを、同じ組織に属する他のアカウント (*参加者*) と共有します。サブネットを共有する参加者アカウントは、共有 Amazon VPC 内の環境を表示、作成、変更、削除できます。

組織内の `Root` アカウントとして機能し、Amazon VPC リソースを所有するアカウント `Owner` と、同じ組織のメンバーである参加者アカウント `Participant` があるとします。`Participant` が `Owner` と共有している Amazon VPC に新しい Amazon MWAA を作成すると、Amazon MWAA はまずサービス VPC リソースを作成し、最大 72 時間 [https://docs.aws.amazon.com/mwaa/latest/API/API_Environment.html#mwaa-Type-Environment-Status](https://docs.aws.amazon.com/mwaa/latest/API/API_Environment.html#mwaa-Type-Environment-Status) の状態になります。

環境ステータスが `CREATING` から `PENDING` に変更されると、`Owner` に代わって動作するプリンシパルが必要なエンドポイントを作成します。これを行うに、Amazon MWAA は、Amazon MWAA コンソールにデータベースとウェブサーバーエンドポイントを一覧表示します。[]() API アクションを呼び出して、サービスエンドポイントを取得することもできます。

**注記**  
リソースの共有に使用する Amazon VPC がプライベート Amazon VPC である場合も、「[Amazon MWAA でのサービス固有の Amazon VPC エンドポイントへのアクセスの管理](vpc-vpe-access.md)」で説明されているステップを完了する必要があります。このトピックでは、Amazon ECR、Amazon ECS、Amazon SQS など、 と AWS 統合する他の AWS サービスに関連する別の Amazon VPC エンドポイントセットの設定について説明します。これらのサービスは、クラウド内の Apache Airflow 環境を運用および管理するために不可欠です。

### 前提条件
<a name="configure-shared-vpc-prerequisites"></a>

共有 VPC に Amazon MWAA 環境を作成する前に、次のリソースが必要です。
+ Amazon VPC を所有するアカウントとして AWS アカウント`Owner`使用される 。
+ [AWS Organizations](https://aws.amazon.com/organizations/) 組織単位、`MyOrganization` は *ルート* として作成されました。
+ 新しい環境を作成する参加者アカウント`MyOrganization`を提供する `Participant`の 2 AWS アカウント番目の 。

さらに、Amazon VPC でリソースを共有するときは、[所有者および参加者の責任とアクセス許可](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-sharing.html#vpc-share-limitations) を理解しておくことをお勧めします。

### Amazon VPC を作成する
<a name="configure-shared-vpc-create-vpc"></a>

まず、所有者アカウントと参加者アカウントが共有する新しい Amazon VPC を作成します。

1. を使用してコンソールにサインインし`Owner`、 CloudFormation コンソールを開きます。次のテンプレートを使用してスタックを作成します。このスタックは、Amazon VPC や、このシナリオで 2 つのアカウントが共有するサブネットなど、多数のネットワークリソースをプロビジョニングします。

   ```
   AWSTemplateFormatVersion: "2010-09-09"                   
   Description: >-
   This template deploys a VPC, with a pair of public and private subnets spread across two Availability Zones. It deploys an internet gateway, with a default route on the public subnets. It deploys a pair of NAT gateways (one in each AZ), and default routes for them in the private subnets.
    Parameters:
      EnvironmentName:
        Description: An environment name that is prefixed to resource names
        Type: String
        Default: mwaa-
      VpcCIDR:
        Description: Please enter the IP range (CIDR notation) for this VPC
        Type: String
        Default: 10.192.0.0/16
      PublicSubnet1CIDR:
        Description: >-
        Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
        Type: String
        Default: 10.192.10.0/24
      PublicSubnet2CIDR:
        Description: >-
        Please enter the IP range (CIDR notation) for the public subnet in the	second Availability Zone
        Type: String
        Default: 10.192.11.0/24
      PrivateSubnet1CIDR:
        Description: >-
        Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
        Type: String
        Default: 10.192.20.0/24
      PrivateSubnet2CIDR:
        Description: >-
        Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
        Type: String
        Default: 10.192.21.0/24
    Resources:
      VPC:
        Type: 'AWS::EC2::VPC'
        Properties:
        CidrBlock: !Ref VpcCIDR
        EnableDnsSupport: true
        EnableDnsHostnames: true
        Tags:
          - Key: Name
          Value: !Ref EnvironmentName
      InternetGateway:
        Type: 'AWS::EC2::InternetGateway'
        Properties:
        Tags:
          - Key: Name
          Value: !Ref EnvironmentName
      InternetGatewayAttachment:
        Type: 'AWS::EC2::VPCGatewayAttachment'
        Properties:
          InternetGatewayId: !Ref InternetGateway
          VpcId: !Ref VPC
      PublicSubnet1:
        Type: 'AWS::EC2::Subnet'
        Properties:
          VpcId: !Ref VPC
          AvailabilityZone: !Select 
            - 0
            - !GetAZs ''
          CidrBlock: !Ref PublicSubnet1CIDR
          MapPublicIpOnLaunch: true
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Public Subnet (AZ1)'
      PublicSubnet2:
        Type: 'AWS::EC2::Subnet'
        Properties:
   						VpcId: !Ref VPC
          AvailabilityZone: !Select 
            - 1
            - !GetAZs ''
          CidrBlock: !Ref PublicSubnet2CIDR
          MapPublicIpOnLaunch: true
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Public Subnet (AZ2)'
      PrivateSubnet1:
        Type: 'AWS::EC2::Subnet'
        Properties:
          VpcId: !Ref VPC
          AvailabilityZone: !Select 
            - 0
            - !GetAZs ''
          CidrBlock: !Ref PrivateSubnet1CIDR
          MapPublicIpOnLaunch: false
            Tags:
            - Key: Name
              Value: !Sub '${EnvironmentName} Private Subnet (AZ1)'
      PrivateSubnet2:
        Type: 'AWS::EC2::Subnet'
        Properties:
          VpcId: !Ref VPC
          AvailabilityZone: !Select 
            - 1
            - !GetAZs ''
          CidrBlock: !Ref PrivateSubnet2CIDR
          MapPublicIpOnLaunch: false
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Private Subnet (AZ2)'
      NatGateway1EIP:
        Type: 'AWS::EC2::EIP'
        DependsOn: InternetGatewayAttachment
        Properties:
          Domain: vpc
      NatGateway2EIP:
        Type: 'AWS::EC2::EIP'
        DependsOn: InternetGatewayAttachment
        Properties:
          Domain: vpc
      NatGateway1:
        Type: 'AWS::EC2::NatGateway'
        Properties:
          AllocationId: !GetAtt NatGateway1EIP.AllocationId
          SubnetId: !Ref PublicSubnet1
      NatGateway2:
        Type: 'AWS::EC2::NatGateway'
        Properties:
          AllocationId: !GetAtt NatGateway2EIP.AllocationId
          SubnetId: !Ref PublicSubnet2
      PublicRouteTable:
        Type: 'AWS::EC2::RouteTable'
        Properties:
          VpcId: !Ref VPC
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Public Routes'
      DefaultPublicRoute:
        Type: 'AWS::EC2::Route'
        DependsOn: InternetGatewayAttachment
        Properties:
          RouteTableId: !Ref PublicRouteTable
          DestinationCidrBlock: 0.0.0.0/0
          GatewayId: !Ref InternetGateway
      PublicSubnet1RouteTableAssociation:
        Type: 'AWS::EC2::SubnetRouteTableAssociation'
        Properties:
          RouteTableId: !Ref PublicRouteTable
          SubnetId: !Ref PublicSubnet1
      PublicSubnet2RouteTableAssociation:
        Type: 'AWS::EC2::SubnetRouteTableAssociation'
        Properties:
          RouteTableId: !Ref PublicRouteTable
          SubnetId: !Ref PublicSubnet2
      PrivateRouteTable1:
        Type: 'AWS::EC2::RouteTable'
        Properties:
          VpcId: !Ref VPC
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Private Routes (AZ1)'
      DefaultPrivateRoute1:
        Type: 'AWS::EC2::Route'
        Properties:
          RouteTableId: !Ref PrivateRouteTable1
          DestinationCidrBlock: 0.0.0.0/0
          NatGatewayId: !Ref NatGateway1
      PrivateSubnet1RouteTableAssociation:
        Type: 'AWS::EC2::SubnetRouteTableAssociation'
        Properties:
          RouteTableId: !Ref PrivateRouteTable1
          SubnetId: !Ref PrivateSubnet1
      PrivateRouteTable2:
        Type: 'AWS::EC2::RouteTable'
        Properties:
          VpcId: !Ref VPC
          Tags:
            - Key: Name
            Value: !Sub '${EnvironmentName} Private Routes (AZ2)'
      DefaultPrivateRoute2:
        Type: 'AWS::EC2::Route'
        Properties:
          RouteTableId: !Ref PrivateRouteTable2
          DestinationCidrBlock: 0.0.0.0/0
          NatGatewayId: !Ref NatGateway2
      PrivateSubnet2RouteTableAssociation:
        Type: 'AWS::EC2::SubnetRouteTableAssociation'
        Properties:
          RouteTableId: !Ref PrivateRouteTable2
          SubnetId: !Ref PrivateSubnet2
      SecurityGroup:
        Type: 'AWS::EC2::SecurityGroup'
        Properties:
          GroupName: mwaa-security-group
          GroupDescription: Security group with a self-referencing inbound rule.
          VpcId: !Ref VPC
      SecurityGroupIngress:
        Type: 'AWS::EC2::SecurityGroupIngress'
        Properties:
          GroupId: !Ref SecurityGroup
          IpProtocol: '-1'
          SourceSecurityGroupId: !Ref SecurityGroup
          Outputs:
            VPC:
              Description: A reference to the created VPC
              Value: !Ref VPC
              PublicSubnets:
              Description: A list of the public subnets
              Value: !Join 
                - ','
                - - !Ref PublicSubnet1
                - !Ref PublicSubnet2
            PrivateSubnets:
              Description: A list of the private subnets
              Value: !Join 
                - ','
                - - !Ref PrivateSubnet1
                - !Ref PrivateSubnet2
            PublicSubnet1:
              Description: A reference to the public subnet in the 1st Availability Zone
              Value: !Ref PublicSubnet1
            PublicSubnet2:
              Description: A reference to the public subnet in the 2nd Availability Zone
              Value: !Ref PublicSubnet2
            PrivateSubnet1:
              Description: A reference to the private subnet in the 1st Availability Zone
              Value: !Ref PrivateSubnet1
            PrivateSubnet2:
              Description: A reference to the private subnet in the 2nd Availability Zone
              Value: !Ref PrivateSubnet2
            SecurityGroupIngress:
              Description: Security group with self-referencing inbound rule
              Value: !Ref SecurityGroupIngress
   ```

1. 新しい Amazon VPC リソースがプロビジョニングされたら、 AWS Resource Access Manager コンソールに移動し、**リソース共有の作成**を選択します。

1. 最初のステップで作成したサブネットを、`Participant` と共有できる使用可能なサブネットのリストから選択します。

### 環境を作成します
<a name="configure-shared-vpc-create-mwaa"></a>

カスタマー管理の Amazon VPC エンドポイントを使用して Amazon MWAA 環境を作成するには、次の手順を実行します。

1. `Participant` を使用してサインインして、Amazon MWAA コンソールを開きます。**[ステップ 1: 詳細を指定する]** を完了して、Amazon S3 バケット、DAG フォルダ、および新しい環境の依存関係を指定します。詳細については、[開始する](create-environment.md#create-environment-start-details) を参照してください。

1. **詳細設定の設定** ページの **ネットワーク** で、共有 Amazon VPC からサブネットを選択します。

1. **[エンドポイント管理]** で、ドロップダウンリストから **[CUSTOMER]** を選択します。

1. ページの残りのオプションのデフォルトのままにし、**[レビューと作成]** ページで **[環境の作成]** を選択します。

環境は `CREATING` 状態で開始され、`PENDING` に変わります。環境が `PENDING` の場合、 コンソールを使用して **データベースエンドポイントサービス名** と **ウェブサーバーエンドポイントサービス名** (プライベートウェブサーバーをセットアップした場合) を書き留めます。

Amazon MWAA コンソールを使用して新しい環境を作成する場合。Amazon MWAA は、必要なインバウンドルールとアウトバウンドルールを持つ新しいセキュリティグループを作成します。セキュリティグループ ID を書き留めます。

次のセクションでは、 `Owner` はサービスエンドポイントとセキュリティグループ ID を使用して、共有 Amazon VPC に新しい Amazon VPC エンドポイントを作成します。

### Amazon VPC エンドポイントを作成する
<a name="configure-shared-vpc-create-endpoints"></a>

環境に必要な Amazon VPC エンドポイントを作成するには、次の手順を実行します。

1.  を開く AWS マネジメントコンソール を使用して にサインイン`Owner`します[https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/)。

1. 左側のナビゲーションパネルから **[セキュリティグループ]** を選択し、次のインバウンドルールとアウトバウンドルールを使用して、共有 Amazon VPC に新しいセキュリティグループを作成します。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/mwaa/latest/userguide/vpc-endpoint-management.html)
**警告**  
`Owner` アカウントは、新しい環境から共有 Amazon VPC へのトラフィックを許可するように、`Owner` アカウントにセキュリティグループを設定する必要があります。`Owner` に新しいセキュリティグループを作成するか、既存のパイプラインを編集することでこれが可能になります。

1. **エンドポイント** を選択、前のステップのエンドポイントサービス名を使用して、環境データベースとウェブサーバー (プライベートモードの場合) の新しいエンドポイントを作成します。共有 Amazon VPC、環境に使用したサブネット、環境のセキュリティグループを選択します。

成功すると、環境は `PENDING` から `CREATING` に戻り、最後に `AVAILABLE` に変わります。`AVAILABLE` の場合は、Apache Airflow コンソールにサインインできます。

### 共有 Amazon VPC のトラブルシューティング
<a name="configure-shared-vpc-troubleshooting"></a>

次のリファレンスを使用して、共有 Amazon VPC で環境を作成するときに発生する問題を解決します。

**`PENDING` ステータス後の `CREATE_FAILED` の環境**  
+ `Owner` が [AWS Resource Access Manager](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html) を使用して `Participant` とサブネットを共有していることを確認します。
+ データベースとウェブサーバーの Amazon VPC エンドポイントが、環境に関連付けられているのと同じサブネットに作成されていることを確認します。
+ エンドポイントで使用されるセキュリティグループが、環境に使用されるセキュリティグループからのトラフィックを許可していることを確認します。`Owner` アカウントは、`Participant` のセキュリティグループを `123456789012/security-group-id` として参照するルールを作成します。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/mwaa/latest/userguide/vpc-endpoint-management.html)

  詳細については、[所有者および参加者の責任とアクセス許可](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-sharing.html#vpc-share-limitations) を参照してください。

**環境が `PENDING` ステータスでスタックしている**  
各 VPC エンドポイントのステータスを検証して、`Available` であることを確認します。プライベートウェブサーバーで環境を設定する場合は、ウェブサーバーのエンドポイントも作成する必要があります。環境が `PENDING` で停止している場合、プライベートウェブサーバーエンドポイントが欠落している可能性があります。

**`The Vpc Endpoint Service 'vpce-service-name' does not exist` エラーを受信した**  
次のエラーが表示された場合は、共有 VPC を所有する アカウントでエンドポイントを作成する `Owner` を確認します。  

```
ClientError: An error occurred (InvalidServiceName) when calling the CreateVpcEndpoint operation: 
							
The Vpc Endpoint Service 'vpce-service-name' does not exist
```