

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# Criar a rede VPC
<a name="vpc-create"></a>

O Amazon Managed Workflows for Apache Airflow requer uma Amazon VPC e componentes da rede específicos para oferecer suporte a um ambiente. Este guia descreve as diferentes opções da criação da rede da Amazon VPC para o ambiente do Amazon Managed Workflows for Apache Airflow.

**nota**  
O Apache Airflow funciona melhor em um ambiente de rede de baixa latência. Se você estiver usando uma Amazon VPC existente que roteia o tráfego para outra região ou para um ambiente on-premises, recomendamos adicionar endpoints do AWS PrivateLink para Amazon SQS, CloudWatch, Amazon S3 e AWS KMS. Para obter mais informações sobre a configuração do AWS PrivateLink para o Amazon MWAA, consulte [Criação de uma rede Amazon VPC sem acesso à internet](#vpc-create-template-private-only).

**Contents**
+ [Pré-requisitos](#vpc-create-prereqs)
+ [Antes de começar](#vpc-create-how-networking)
+ [Opções para criar a rede Amazon VPC](#vpc-create-options)
  + [Opção um: criar a rede VPC no console Amazon MWAA](#vpc-create-mwaa-console)
  + [Opção dois: criar uma rede Amazon VPC *com* acesso à internet](#vpc-create-template-private-or-public)
  + [Opção três: criar uma rede Amazon VPC *sem* acesso à internet](#vpc-create-template-private-only)
+ [Próximas etapas](#create-vpc-next-up)

## Pré-requisitos
<a name="vpc-create-prereqs"></a>

A AWS Command Line Interface (AWS CLI) é uma ferramenta de código aberto que pode ser usada para interagir com os serviços da AWS por meio de comandos no shell da linha de comando. Para concluir as etapas nesta página, é necessário o seguinte:
+ [AWS CLI – instalar a versão 2](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html).
+ [AWS CLI: configuração rápida com `aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).

## Antes de começar
<a name="vpc-create-how-networking"></a>
+ A [rede VPC](#vpc-create) que você especifica para seu ambiente não pode ser alterada após a criação do ambiente.
+ É possível usar roteamento privado ou público para seu servidor Web da Amazon VPC e do Apache Airflow. Para acessar uma lista de opções, consulte [Exemplos de casos de uso para um modo de acesso Amazon VPC e Apache Airflow](networking-about.md#networking-about-network-usecase).

## Opções para criar a rede Amazon VPC
<a name="vpc-create-options"></a>

A seção a seguir descreve as opções disponíveis para criar a rede Amazon VPC para um ambiente.

**nota**  
O Amazon MWAA não é compatível com o uso da zona de disponibilidade (AZ) `use1-az3` da região Leste dos EUA (Norte da Virgínia). Ao criar a VPC para o Amazon MWAA na região Leste dos EUA (Norte da Virgínia), atribua explicitamente a `AvailabilityZone` no modelo do CloudFormation (CFN). O nome da zona de disponibilidade atribuída não deve ser mapeado para `use1-az3`. É possível recuperar o mapeamento detalhado de nomes de AZ para os IDs de AZ correspondentes executando o seguinte comando:  

```
aws ec2 describe-availability-zones --region us-east-1
```

### Opção um: criar a rede VPC no console Amazon MWAA
<a name="vpc-create-mwaa-console"></a>

A seção a seguir explica como criar uma rede da Amazon VPC no console do Amazon MWAA. Esta opção usa [Roteamento público pela internet](networking-about.md#networking-about-overview-public). Ela pode ser usada para um servidor Web do Apache Airflow com os modos de acesso à **rede privada** ou à **rede pública**.

A imagem a seguir mostra onde você pode encontrar o botão **Criar MWAA VPC** no console do Amazon MWAA.

![\[Esta imagem mostra onde você pode encontrar Criar MWAA VPC no console do Amazon MWAA.\]](http://docs.aws.amazon.com/pt_br/mwaa/latest/userguide/images/mwaa-console-create-vpc.png)


### Opção dois: criar uma rede Amazon VPC *com* acesso à internet
<a name="vpc-create-template-private-or-public"></a>

O modelo CloudFormation a seguir cria uma rede Amazon VPC com acesso à internet em sua Região da AWS padrão. Esta opção usa [Roteamento público pela internet](networking-about.md#networking-about-overview-public). Este modelo pode ser usado para um servidor Web do Apache Airflow com os modos de acesso à **rede privada** ou à **rede pública**.

1. Copie o conteúdo do modelo a seguir e salve localmente como `cfn-vpc-public-private.yaml`. Também é possível [baixar o modelo](./samples/cfn-vpc-public-private.zip).

   ```
   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. No prompt de comando, navegue até o diretório em que `cfn-vpc-public-private.yaml` está armazenado. Por exemplo:

   ```
   cd mwaaproject
   ```

1. Use o comando [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) para criar a pilha usando o AWS CLI.

   ```
   aws cloudformation create-stack --stack-name mwaa-environment --template-body file://cfn-vpc-public-private.yaml
   ```
**nota**  
A criação da infraestrutura da Amazon VPC requer cerca de 30 minutos.

### Opção três: criar uma rede Amazon VPC *sem* acesso à internet
<a name="vpc-create-template-private-only"></a>

O modelo CloudFormation a seguir cria uma rede Amazon VPC *sem acesso à internet* em sua região padrão Região da AWS.

Esta opção usa [Roteamento privado sem acesso à internet](networking-about.md#networking-about-overview-private). Este modelo pode ser usado para um servidor Web Apache Airflow somente com o modo de acesso à **rede privada**. Ele cria os [endpoints da VPC necessários para os serviços da AWS usados por um ambiente](vpc-vpe-create-access.md#vpc-vpe-create-view-endpoints-attach-services).

1. Copie o conteúdo do modelo a seguir e salve localmente como `cfn-vpc-private.yaml`. Também é possível [baixar o modelo](./samples/cfn-vpc-private-no-ops.zip).

   ```
   AWSTemplateFormatVersion: "2010-09-09"
        
   Parameters:
      VpcCIDR:
        Description: The IP range (CIDR notation) for this VPC
        Type: String
        Default: 10.192.0.0/16
        
      PrivateSubnet1CIDR:
        Description: The IP range (CIDR notation) for the private subnet in the first Availability Zone
        Type: String
        Default: 10.192.10.0/24
        
      PrivateSubnet2CIDR:
        Description: The IP range (CIDR notation) for the private subnet in the second Availability Zone
        Type: String
        Default: 10.192.11.0/24
        
   Resources:
      VPC:
        Type: AWS::EC2::VPC
        Properties:
          CidrBlock: !Ref VpcCIDR
          EnableDnsSupport: true
          EnableDnsHostnames: true
          Tags:
           - Key: Name
             Value: !Ref AWS::StackName
        
      RouteTable:
        Type: AWS::EC2::RouteTable
        Properties:
          VpcId: !Ref VPC
          Tags:
           - Key: Name
             Value: !Sub "${AWS::StackName}-route-table"
        
      PrivateSubnet1:
        Type: AWS::EC2::Subnet
        Properties:
          VpcId: !Ref VPC
          AvailabilityZone: !Select [ 0, !GetAZs  '' ]
          CidrBlock: !Ref PrivateSubnet1CIDR
          MapPublicIpOnLaunch: false
          Tags:
           - Key: Name
             Value: !Sub "${AWS::StackName} 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 "${AWS::StackName} Private Subnet (AZ2)"
        
      PrivateSubnet1RouteTableAssociation:
        Type: AWS::EC2::SubnetRouteTableAssociation
        Properties:
          RouteTableId: !Ref RouteTable
          SubnetId: !Ref PrivateSubnet1
        
      PrivateSubnet2RouteTableAssociation:
        Type: AWS::EC2::SubnetRouteTableAssociation
        Properties:
          RouteTableId: !Ref RouteTable
          SubnetId: !Ref PrivateSubnet2
        
      S3VpcEndoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Sub "com.amazonaws.${AWS::Region}.s3"
          VpcEndpointType: Gateway
          VpcId: !Ref VPC
          RouteTableIds:
           - !Ref RouteTable
        
      SecurityGroup:
        Type: AWS::EC2::SecurityGroup
        Properties:
          VpcId: !Ref VPC
          GroupDescription: Security Group for Amazon MWAA Environments to access VPC endpoints
          GroupName: !Sub "${AWS::StackName}-mwaa-vpc-endpoints"
      
      SecurityGroupIngress:
        Type: AWS::EC2::SecurityGroupIngress
        Properties:
          GroupId: !Ref SecurityGroup
          IpProtocol: "-1"
          SourceSecurityGroupId: !Ref SecurityGroup
      
      SqsVpcEndoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Sub "com.amazonaws.${AWS::Region}.sqs"
          VpcEndpointType: Interface
          VpcId: !Ref VPC
          PrivateDnsEnabled: true
          SubnetIds:
           - !Ref PrivateSubnet1
           - !Ref PrivateSubnet2
          SecurityGroupIds:
           - !Ref SecurityGroup
        
      CloudWatchLogsVpcEndoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Sub "com.amazonaws.${AWS::Region}.logs"
          VpcEndpointType: Interface
          VpcId: !Ref VPC
          PrivateDnsEnabled: true
          SubnetIds:
           - !Ref PrivateSubnet1
           - !Ref PrivateSubnet2
          SecurityGroupIds:
           - !Ref SecurityGroup
        
      CloudWatchMonitoringVpcEndoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Sub "com.amazonaws.${AWS::Region}.monitoring"
          VpcEndpointType: Interface
          VpcId: !Ref VPC
          PrivateDnsEnabled: true
          SubnetIds:
           - !Ref PrivateSubnet1
           - !Ref PrivateSubnet2
          SecurityGroupIds:
           - !Ref SecurityGroup
        
      KmsVpcEndoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Sub "com.amazonaws.${AWS::Region}.kms"
          VpcEndpointType: Interface
          VpcId: !Ref VPC
          PrivateDnsEnabled: true
          SubnetIds:
           - !Ref PrivateSubnet1
           - !Ref PrivateSubnet2
          SecurityGroupIds:
           - !Ref SecurityGroup
   
   
   Outputs:
      VPC:
        Description: A reference to the created VPC
        Value: !Ref VPC
        
      MwaaSecurityGroupId:
        Description: Associates the Security Group to the environment to allow access to the VPC endpoints 
        Value: !Ref SecurityGroup
        
      PrivateSubnets:
        Description: A list of the private subnets
        Value: !Join [ ",", [ !Ref PrivateSubnet1, !Ref PrivateSubnet2 ]]
        
      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
   ```

1. No prompt de comando, navegue até o diretório em que `cfn-vpc-private.yml` está armazenado. Por exemplo:

   ```
   cd mwaaproject
   ```

1. Use o comando [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html) para criar a pilha usando o AWS CLI.

   ```
   aws cloudformation create-stack --stack-name mwaa-private-environment --template-body file://cfn-vpc-private.yml
   ```
**nota**  
A criação da infraestrutura da Amazon VPC requer cerca de 30 minutos.

1. Você precisará criar um mecanismo para acessar esses endpoints da VPC a partir do seu computador. Consulte [Como gerenciar o acesso a endpoints da Amazon VPC específicos do serviço no Amazon MWAA](vpc-vpe-access.md) para saber mais.

**nota**  
É possível restringir ainda mais o acesso de saída no CIDR do seu grupo de segurança do Amazon MWAA. Por exemplo, você pode se restringir adicionando uma regra de saída de autorreferência, a [prefix list](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-gateway.html) (lista de prefixos) do Amazon S3 e o CIDR da sua Amazon VPC.

## Próximas etapas
<a name="create-vpc-next-up"></a>
+ Saiba como criar um ambiente do Amazon MWAA em [Criar um ambiente do Amazon MWAA](create-environment.md).
+ Aprenda a criar um túnel VPN do seu computador para a Amazon VPC com roteamento privado em [Tutorial: Como configurar o acesso à rede privada usando um AWS Client VPN](tutorials-private-network-vpn-client.md).