// Module included in the following assemblies:
//
// * cloud_experts_tutorials/cloud-experts-using-alb-and-waf.adoc

:_mod-docs-content-type: PROCEDURE
[id="cloud-experts-using-alb-and-waf-aws-vpc-and-subnets_{context}"]
= Tag your AWS VPC and subnets

[role="_abstract"]
You need to tag your subnets and Virtual Private Cloud (VPC) before using these resources.

[NOTE]
====
These steps only apply to clusters that were deployed into existing VPCs. If you did not deploy your cluster into an existing VPC, proceed to the installation steps.
====

.Procedure
. Set the following variables to the proper values for your {product-title} deployment:
+
[source,terminal]
----
$ export VPC_ID=<vpc-id>
$ export PUBLIC_SUBNET_IDS=(<space-separated-list-of-ids>)
$ export PRIVATE_SUBNET_IDS=(<space-separated-list-of-ids>)
----
+
--
where:

`VPC_ID=<vpc-id>`:: Replace with the VPC ID of the cluster, for example: `export VPC_ID=vpc-04c429b7dbc4680ba`.
`PUBLIC_SUBNET_IDS=(<space-separated-list-of-ids>)`:: Replace with a space-separated list of the public subnet IDs of the cluster, making sure to preserve the `()`. For example: `export PUBLIC_SUBNET_IDS=(subnet-056fd6861ad332ba2 subnet-08ce3b4ec753fe74c subnet-071aa28228664972f)`.
`PRIVATE_SUBNET_IDS=(<space-separated-list-of-ids>)`:: Replace with a space-separated list of the private subnet IDs of the cluster, making sure to preserve the `()`. For example: `export PRIVATE_SUBNET_IDS=(subnet-0b933d72a8d72c36a subnet-0817eb72070f1d3c2 subnet-0806e64159b66665a)`.
--

. Add a tag to your cluster's VPC with the cluster identifier:
+
[source,terminal]
----
$ aws ec2 create-tags --resources ${VPC_ID} \
  --tags Key=kubernetes.io/cluster/${CLUSTER},Value=shared --region ${REGION}
----

. Add a tag to your public subnets:
+
[source,terminal]
----
$ aws ec2 create-tags \
  --resources ${PUBLIC_SUBNET_IDS} \
  --tags Key=kubernetes.io/role/elb,Value='1' \
        Key=kubernetes.io/cluster/${CLUSTER},Value=shared \
  --region ${REGION}
----

. Add a tag to your private subnets:
+
[source,terminal]
----
$ aws ec2 create-tags \
  --resources ${PRIVATE_SUBNET_IDS} \
  --tags Key=kubernetes.io/role/internal-elb,Value='1' \
        Key=kubernetes.io/cluster/${CLUSTER},Value=shared \
  --region ${REGION}
----