From 7ce35b21966bc167ec4fcfcd0607b40e5242961d Mon Sep 17 00:00:00 2001 From: shikha372 Date: Mon, 16 Dec 2024 22:49:08 -0800 Subject: [PATCH] fixing readme --- packages/@aws-cdk/aws-ec2-alpha/README.md | 19 +++++++++++++++++++ .../aws-ec2-alpha/rosetta/default.ts-fixture | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-ec2-alpha/README.md b/packages/@aws-cdk/aws-ec2-alpha/README.md index 21d5ff793016b..b387e02180ad4 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/README.md +++ b/packages/@aws-cdk/aws-ec2-alpha/README.md @@ -645,3 +645,22 @@ SubnetV2.fromSubnetV2Attributes(this, 'ImportedSubnet', { ``` By importing existing VPCs and subnets, you can easily integrate your existing AWS infrastructure with new resources created through CDK. This is particularly useful when you need to work with pre-existing network configurations or when you're migrating existing infrastructure to CDK. + +### Tagging VPC and its components + +By default, when a resource name is given to the construct, it automatically adds a tag with the key `Name` and the value set to the provided resource name. To add additional custom tags, use the Tag Manager, like this: `Tags.of(myConstruct).add('key', 'value');`. + +For example, if the `vpcName` is set to `TestVpc`, the following code will add a tag to the VPC with `key: Name` and `value: TestVpc`. + +```ts + +const vpc = new VpcV2(this, 'VPC-integ-test-tag', { + primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'), + enableDnsHostnames: true, + enableDnsSupport: true, + vpcName: 'CDKintegTestVPC', +}); + +// Add custom tags if needed +Tags.of(vpc).add('Environment', 'Production'); +``` diff --git a/packages/@aws-cdk/aws-ec2-alpha/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-ec2-alpha/rosetta/default.ts-fixture index d48ffb9f1330b..5704158e8073c 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/rosetta/default.ts-fixture +++ b/packages/@aws-cdk/aws-ec2-alpha/rosetta/default.ts-fixture @@ -1,6 +1,6 @@ // Fixture with packages imported, but nothing else import { Construct } from 'constructs'; -import { Stack, App, Fn } from 'aws-cdk-lib'; +import { Stack, App, Fn, Tags } from 'aws-cdk-lib'; import { VpcV2, SubnetV2, IpAddresses, IpamPoolPublicIpSource, RouteTable, InternetGateway, Route, NatGateway, EgressOnlyInternetGateway, VPCPeeringConnection } from '@aws-cdk/aws-ec2-alpha'; import { Ipam, AwsServiceName, IpCidr, AddressFamily } from '@aws-cdk/aws-ec2-alpha'; import { NatConnectivityType } from '@aws-cdk/aws-ec2-alpha';