// Module included in the following assemblies:
//
// * installing/installing-aws-wavelength-zone.adoc (Installing a cluster on AWS with compute nodes on AWS Wavelength Zones) 

:_mod-docs-content-type: PROCEDURE
[id="installation-creating-aws-vpc-subnets-wz_{context}"]
= Creating subnets in Wavelength Zones

Before you configure a machine set for edge compute nodes in your {product-title} cluster, you must create the subnets in {zone-type}. Complete the following procedure for each Wavelength Zone that you want to deploy compute nodes to.

You can use the provided CloudFormation template and create a CloudFormation stack. You can then use this stack to custom provision a subnet.

[NOTE]
====
If you do not use the provided CloudFormation template to create your AWS infrastructure, you must review the provided information and manually create the infrastructure. If your cluster does not initialize correctly, you might have to contact Red Hat support with your installation logs.
====

.Prerequisites

* You configured an AWS account.
* You added your AWS keys and region to your local AWS profile by running `aws configure`.
* You opted in to the {zone-type} group.

.Procedure

. Go to the section of the documentation named "CloudFormation template for the VPC subnet", and copy the syntax from the template. Save the copied template syntax as a YAML file on your local system. This template describes the VPC that your cluster requires.

. Run the following command to deploy the CloudFormation template, which creates a stack of AWS resources that represent the VPC:
+
[source,terminal]
----
$ aws cloudformation create-stack --stack-name <stack_name> \ <1>
  --region ${CLUSTER_REGION} \
  --template-body file://<template>.yaml \ <2>
  --parameters \
    ParameterKey=VpcId,ParameterValue="${VPC_ID}" \ <3>
    ParameterKey=ClusterName,ParameterValue="${CLUSTER_NAME}" \ <4>
    ParameterKey=ZoneName,ParameterValue="${ZONE_NAME}" \ <5>
    ParameterKey=PublicRouteTableId,ParameterValue="${ROUTE_TABLE_PUB}" \ <6>
    ParameterKey=PublicSubnetCidr,ParameterValue="${SUBNET_CIDR_PUB}" \ <7>
    ParameterKey=PrivateRouteTableId,ParameterValue="${ROUTE_TABLE_PVT}" \ <8>
    ParameterKey=PrivateSubnetCidr,ParameterValue="${SUBNET_CIDR_PVT}" <9>
----
<1> `<stack_name>` is the name for the CloudFormation stack, such as `cluster-wl-<wavelength_zone_shortname>`. You need the name of this stack if you remove the cluster.
<2> `<template>` is the relative path and the name of the CloudFormation template YAML file that you saved.
<3> `${VPC_ID}` is the VPC ID, which is the value `VpcID` in the output of the CloudFormation template for the VPC.
<4> `${ZONE_NAME}` is the value of {zone-type} name to create the subnets.
<5> `${CLUSTER_NAME}` is the value of *ClusterName* to be used as a prefix of the new AWS resource names.
<6> `${ROUTE_TABLE_PUB}` is the *PublicRouteTableId* extracted from the output of the VPC's carrier gateway CloudFormation stack.
<7> `${SUBNET_CIDR_PUB}` is a valid CIDR block that is used to create the public subnet. This block must be part of the VPC CIDR block `VpcCidr`.
<8> `${ROUTE_TABLE_PVT}` is the *PrivateRouteTableId* extracted from the output of the VPC's CloudFormation stack.
<9> `${SUBNET_CIDR_PVT}` is a valid CIDR block that is used to create the private subnet. This block must be part of the VPC CIDR block `VpcCidr`.

.Example output
[source,terminal]
----
arn:aws:cloudformation:us-east-1:123456789012:stack/<stack_name>/dbedae40-820e-11eb-2fd3-12a48460849f
----

.Verification

* Confirm that the template components exist by running the following command:
+
[source,terminal]
----
$ aws cloudformation describe-stacks --stack-name <stack_name>
----
+
After the `StackStatus` displays `CREATE_COMPLETE`, the output displays values for the following parameters. Ensure that you provide these parameter values to the other CloudFormation templates that you run to create for your cluster.
+
[horizontal]
`PublicSubnetId`:: The IDs of the public subnet created by the CloudFormation stack.
`PrivateSubnetId`:: The IDs of the private subnet created by the CloudFormation stack.
