<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>

KiteUp
<p>You can do it automatically using lambda-supported custom resources.</p>
