<p>I am trying to build an AWS EKS Cluster with AWS cdk in Java.</p>

<p>We have an existing VPC and subnets which need to get some Kubernetes tags like <strong>kubernetes.io/role/internal-elb=1</strong> etc.</p>

<p>I can get the ISubnets by getting the vpc with:</p>

<pre class="lang-java prettyprint-override"><code>IVpc vpc = Vpc.fromVpcAttributes(this, "my-vpc", vpcAttributes);
List&lt;ISubnet&gt; subnets = vpc.getPrivateSubnets();

subnets.forEach(iSubnet -&gt; Tag.add(iSubnet, "kubernetes.io/role/internal-elb", "1"));
</code></pre>

<p>but <code>awscdk.core.Tag.add()</code> is expecting a Construct, which I am not creating because the subnet already exists.</p>

<p>Also tried the example here: <a href="https://docs.aws.amazon.com/de_de/cdk/latest/guide/tagging.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/de_de/cdk/latest/guide/tagging.html</a></p>

<pre class="lang-java prettyprint-override"><code>private void addTagToAllVPCSubnets(Tag tag) {
    TagProps includeOnlySubnets = TagProps.builder()
        .includeResourceTypes(singletonList("AWS::EC2::Subnet"))
        .build();

    Tag.add(this, tag.getKey(), tag.getValue(), includeOnlySubnets);
}
</code></pre>

<p>... but still i can not see any of the new tags in the CF yaml of the <code>cdk synth</code>.</p>

<p>Any help will be appreciated!</p>

<p>It seems like this is a limitation in CDK at the moment. This is something that the EKS construct in CDK should deal with, but which is currently not possible as indicated by a warning during a CDK deployment:</p>

<pre><code>[Warning at /stack/some-project-EKS-cluster] Could not auto-tag private subnets with "kubernetes.io/role/internal-elb=1", please remember to do this manually
</code></pre>

<p>For the same reason that this can't be done automatically, you can't do it by using <code>Tag.add()</code>.</p>

<p>Since the EKS module in CDK is still experimental/development preview, you have three options right now:</p>

<ol>
<li>Wait for a full release, which perhaps includes automatic subnet tagging. </li>
<li>Create your own VPC through CDK, which allows you to tag your own subnets.</li>
<li>Manually edit existing subnets through the VPC service interface in the AWS console</li>
</ol>

<p>A good idea would probably be to create an issue on the AWS CDK Github and request tagging existing subnets (and other existing constructs in general) as a feature. I could not find other issues regarding this on their Github.</p>
