

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

# Creación de la red de VPC
<a name="vpc-create"></a>

Los flujos de trabajo de Amazon para Apache Airflow requieren una VPC de Amazon y componentes de red específicos para dar soporte a un entorno. En esta guía se describen las diferentes opciones para crear la red de Amazon VPC para un entorno de Amazon Managed Workflows para Apache Airflow.

**nota**  
Apache Airflow funciona mejor en un entorno de red de baja latencia. Si utiliza una Amazon VPC existente que enruta el tráfico a otra región o a un entorno local, le recomendamos que agregue puntos de conexión de AWS PrivateLink para Amazon SQS, CloudWatch, Amazon S3 y AWS KMS. Para más información sobre la configuración de AWS PrivateLink para Amazon MWAA, consulte [Creación de una red VPC de Amazon sin acceso a Internet](#vpc-create-template-private-only).

**Contents**
+ [Requisitos previos](#vpc-create-prereqs)
+ [Antes de empezar](#vpc-create-how-networking)
+ [Opciones para crear la red de Amazon VPC](#vpc-create-options)
  + [Opción 1: crear la red de VPC en la consola de Amazon MWAA](#vpc-create-mwaa-console)
  + [Opción 2: Creación de una red Amazon VPC *con* acceso a Internet](#vpc-create-template-private-or-public)
  + [Opción 3: Creación de una red de Amazon VPC *sin* acceso a Internet](#vpc-create-template-private-only)
+ [Siguientes pasos](#create-vpc-next-up)

## Requisitos previos
<a name="vpc-create-prereqs"></a>

La AWS Command Line Interface (AWS CLI) es una herramienta de código abierto que le permite interactuar con los servicios de AWS mediante el uso de comandos en el shell de la línea de comandos. Para completar los pasos de esta página, necesita lo siguiente:
+ [AWS CLI: instalar la versión 2](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html).
+ [AWS CLI: configuración rápida con `aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).

## Antes de empezar
<a name="vpc-create-how-networking"></a>
+ La [red de VPC](#vpc-create) que especifique para su entorno no se puede cambiar después crearlo.
+ Puede usar el enrutamiento público o privado para su servidor web de Amazon VPC y Apache Airflow. Para acceder a una lista de opciones, consulte [Ejemplos de casos de uso para un modo de acceso a Amazon VPC y Apache Airflow](networking-about.md#networking-about-network-usecase).

## Opciones para crear la red de Amazon VPC
<a name="vpc-create-options"></a>

En la sección siguiente se describen las opciones disponibles para crear la red de Amazon VPC para un entorno.

**nota**  
Amazon MWAA no admite el uso de la zona de disponibilidad (AZ) `use1-az3` en la región Este de EE. UU. (Norte de Virginia). Cuando crea la VPC para Amazon MWAA en la región Este de EE. UU. (Norte de Virginia), debe asignar la `AvailabilityZone` de forma explícita en la plantilla CloudFormation (CFN). No se debe asignar a `use1-az3` el nombre de la zona de disponibilidad asignada. Puede obtener la asignación detallada de los nombres de las zonas de disponibilidad (AZ) a sus correspondientes ID de zona de disponibilidad mediante la ejecución del siguiente comando:  

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

### Opción 1: crear la red de VPC en la consola de Amazon MWAA
<a name="vpc-create-mwaa-console"></a>

En la siguiente sección, se muestra cómo crear una red de Amazon VPC en la consola de Amazon MWAA. Esta opción usa [Enrutamiento público a través de Internet](networking-about.md#networking-about-overview-public). Se puede usar para un servidor web de Apache Airflow con el modo de acceso de **Red privada** o **Red pública**.

En la siguiente imagen, se muestra dónde puede encontrar el botón **Create MWAA VPC** (Crear VPC de MWAA) en la consola de Amazon MWAA.

![\[En esta imagen, se muestra dónde puede encontrar el botón Creare MWAA VPC (Crear VPC de MWAA) en la consola de Amazon MWAA.\]](http://docs.aws.amazon.com/es_es/mwaa/latest/userguide/images/mwaa-console-create-vpc.png)


### Opción 2: Creación de una red Amazon VPC *con* acceso a Internet
<a name="vpc-create-template-private-or-public"></a>

La siguiente plantilla de CloudFormation crea una red de Amazon VPC con acceso a Internet en su región predeterminada de Región de AWS. Esta opción usa [Enrutamiento público a través de Internet](networking-about.md#networking-about-overview-public). Esta plantilla se puede usar para un servidor web de Apache Airflow con el modo de acceso de **Red privada** o **Red pública**.

1. Copie el contenido de la siguiente plantilla y guárdelo localmente como `cfn-vpc-public-private.yaml`. También puede [descargar la plantilla](./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. En el símbolo del sistema, vaya hasta el directorio en el que está almacenado `cfn-vpc-public-private.yaml`. Por ejemplo:

   ```
   cd mwaaproject
   ```

1. Utilice el 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 crear la pila con la AWS CLI.

   ```
   aws cloudformation create-stack --stack-name mwaa-environment --template-body file://cfn-vpc-public-private.yaml
   ```
**nota**  
Se tardan unos 30 minutos en crear la infraestructura de Amazon VPC.

### Opción 3: Creación de una red de Amazon VPC *sin* acceso a Internet
<a name="vpc-create-template-private-only"></a>

La siguiente plantilla de CloudFormation crea una red de Amazon VPC *sin acceso a Internet* en su Región de AWS predeterminada.

Esta opción usa [Enrutamiento privado sin acceso a Internet](networking-about.md#networking-about-overview-private). Esta plantilla se puede usar solo para un servidor web de Apache Airflow con el modo de acceso a la **red privada**. Crea los [puntos de conexión de VPC necesarios para los servicios de AWS que utiliza un entorno](vpc-vpe-create-access.md#vpc-vpe-create-view-endpoints-attach-services).

1. Copie el contenido de la siguiente plantilla y guárdelo localmente como `cfn-vpc-private.yaml`. También puede [descargar la plantilla](./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. En el símbolo del sistema, vaya hasta el directorio en el que está almacenado `cfn-vpc-private.yml`. Por ejemplo:

   ```
   cd mwaaproject
   ```

1. Utilice el 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 crear la pila con la AWS CLI.

   ```
   aws cloudformation create-stack --stack-name mwaa-private-environment --template-body file://cfn-vpc-private.yml
   ```
**nota**  
Se tardan unos 30 minutos en crear la infraestructura de Amazon VPC.

1. Deberá crear un mecanismo para acceder a estos puntos de conexión de VPC desde su ordenador. Consulte [Administración del acceso a los puntos de conexión de Amazon VPC específicos del servicio en Amazon MWAA](vpc-vpe-access.md) para obtener más información.

**nota**  
Puede restringir aún más el acceso saliente en el CIDR de su grupo de seguridad de Amazon MWAA. Por ejemplo, puede restringirse a sí mismo añadiendo una regla de salida autorreferenciada, la [lista de prefijos](https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-gateway.html) de Amazon S3 y el CIDR de su Amazon VPC.

## Siguientes pasos
<a name="create-vpc-next-up"></a>
+ Obtenga información sobre cómo crear un entorno Amazon MWAA en [Creación de entornos de Amazon MWAA](create-environment.md).
+ Aprenda a crear un túnel VPN desde su ordenador a su Amazon VPC con enrutamiento privado en [Tutorial: Configuración del acceso a la red privada mediante una AWS Client VPN](tutorials-private-network-vpn-client.md).