diff --git a/packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts b/packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts index 1fd931cbd73a5..6aeb3090b334b 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts +++ b/packages/@aws-cdk/aws-ec2-alpha/lib/ipam.ts @@ -1,6 +1,6 @@ import { CfnIPAM, CfnIPAMPool, CfnIPAMPoolCidr, CfnIPAMScope } from 'aws-cdk-lib/aws-ec2'; import { Construct } from 'constructs'; -import { Lazy, Names, Resource, Stack } from 'aws-cdk-lib'; +import { Lazy, Names, Resource, Stack, Tags } from 'aws-cdk-lib'; /** * Represents the address family for IP addresses in an IPAM pool. @@ -138,6 +138,9 @@ export interface PoolOptions { readonly awsService?: AwsServiceName; } +const NAME_TAG: string = 'NAME'; +//const IPAM_TAG: string = 'IPAM'; + /** * Properties for creating an IPAM pool. * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html @@ -343,6 +346,11 @@ class IpamPool extends Resource implements IIpamPool { throw new Error('awsService is required when addressFamily is set to ipv6'); } + //Add tags to the IPAM Pool if name is provided + if (props.ipamPoolName) { + Tags.of(this).add(NAME_TAG, props.ipamPoolName); + } + this._ipamPool = new CfnIPAMPool(this, id, { addressFamily: props.addressFamily, provisionedCidrs: props.ipv4ProvisionedCidrs?.map(cidr => ({ cidr })), @@ -413,6 +421,7 @@ class IpamScope extends Resource implements IIpamScopeBase { this._ipamScope = new CfnIPAMScope(scope, 'IpamScope', { ipamId: props.ipamId, }); + Tags.of(this._ipamScope).add(NAME_TAG, props.ipamScopeName ?? 'CustomIpamScope'); this.scopeId = this._ipamScope.attrIpamScopeId; this.scopeType = IpamScopeType.CUSTOM; this.scope = scope; @@ -440,6 +449,7 @@ class IpamScopeBase implements IIpamScopeBase { readonly scopeType?: IpamScopeType, ) { this.scopeType = IpamScopeType.DEFAULT; + //Tags.of(this).add(NAME_TAG, 'DefaultIpamScope'); if (!props.ipamScopeId) { throw new Error('ipamScopeId is required'); } else { @@ -494,14 +504,24 @@ export class Ipam extends Resource { */ public readonly scopes: IIpamScopeBase[] = []; + /** + * IPAM name to be used for tagging + * @default no tag specified + * @attribute IpamName + */ + public readonly ipamName?: string; + constructor(scope: Construct, id: string, props?: IpamProps) { super(scope, id); - + if (props?.ipamName) { + Tags.of(this).add(NAME_TAG, props.ipamName); + } if (!props?.operatingRegion && !Stack.of(this).region) { throw new Error('Please provide at least one operating region'); } this.operatingRegions = props?.operatingRegion ?? [Stack.of(this).region]; + this.ipamName = props?.ipamName; this._ipam = new CfnIPAM(this, 'Ipam', { operatingRegions: this.operatingRegions ? this.operatingRegions.map(region => ({ regionName: region })) : [], @@ -531,6 +551,7 @@ export class Ipam extends Resource { public addScope(scope: Construct, id: string, options: IpamScopeOptions): IIpamScopeBase { const ipamScope = new IpamScope(scope, id, { ...options, + ipamScopeName: options.ipamScopeName, ipamId: this.ipamId, ipamOperatingRegions: this.operatingRegions, }); diff --git a/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts b/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts index 80776a0f29eee..e257fa4888f61 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts +++ b/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts @@ -1,6 +1,6 @@ import { CfnEIP, CfnEgressOnlyInternetGateway, CfnInternetGateway, CfnNatGateway, CfnVPCPeeringConnection, CfnRoute, CfnRouteTable, CfnVPCGatewayAttachment, CfnVPNGateway, CfnVPNGatewayRoutePropagation, GatewayVpcEndpoint, IRouteTable, IVpcEndpoint, RouterType } from 'aws-cdk-lib/aws-ec2'; import { Construct, IDependable } from 'constructs'; -import { Annotations, Duration, IResource, Resource } from 'aws-cdk-lib/core'; +import { Annotations, Duration, IResource, Resource, Tags } from 'aws-cdk-lib/core'; import { IVpcV2, VPNGatewayV2Options } from './vpc-v2-base'; import { NetworkUtils, allRouteTableIds, CidrBlock } from './util'; import { ISubnetV2 } from './subnet-v2'; @@ -209,6 +209,11 @@ export interface VPCPeeringConnectionProps extends VPCPeeringConnectionOptions { readonly requestorVpc: IVpcV2; } +/** + * Name tag constant + */ +const NAME_TAG: string = 'Name'; + /** * Creates an egress-only internet gateway * @resource AWS::EC2::EgressOnlyInternetGateway @@ -232,6 +237,9 @@ export class EgressOnlyInternetGateway extends Resource implements IRouteTarget constructor(scope: Construct, id: string, props: EgressOnlyInternetGatewayProps) { super(scope, id); + if (props.egressOnlyInternetGatewayName) { + Tags.of(this).add(NAME_TAG, props.egressOnlyInternetGatewayName); + } this.routerType = RouterType.EGRESS_ONLY_INTERNET_GATEWAY; this.resource = new CfnEgressOnlyInternetGateway(this, 'EIGW', { @@ -279,6 +287,10 @@ export class InternetGateway extends Resource implements IRouteTarget { this.routerTargetId = this.resource.attrInternetGatewayId; this.vpcId = props.vpc.vpcId; + if (props.internetGatewayName) { + Tags.of(this).add(NAME_TAG, props.internetGatewayName); + } + new CfnVPCGatewayAttachment(this, 'GWAttachment', { vpcId: this.vpcId, internetGatewayId: this.routerTargetId, @@ -322,7 +334,9 @@ export class VPNGatewayV2 extends Resource implements IRouteTarget { private readonly _routePropagation: CfnVPNGatewayRoutePropagation; constructor(scope: Construct, id: string, props: VPNGatewayV2Props) { - super(scope, id); + super(scope, id, { + physicalName: props.vpnGatewayName, + }); this.routerType = RouterType.GATEWAY; @@ -340,6 +354,10 @@ export class VPNGatewayV2 extends Resource implements IRouteTarget { vpnGatewayId: this.resource.attrVpnGatewayId, }); + if (props.vpnGatewayName) { + Tags.of(this).add(NAME_TAG, props.vpnGatewayName); + } + // Propagate routes on route tables associated with the right subnets const vpnRoutePropagation = props.vpnRoutePropagation ?? []; const subnets = vpnRoutePropagation.map(s => props.vpc.selectSubnets(s).subnets).flat(); @@ -409,6 +427,10 @@ export class NatGateway extends Resource implements IRouteTarget { } } + if (props.natGatewayName) { + Tags.of(this).add(NAME_TAG, props?.natGatewayName); + } + // If user does not provide EIP, generate one for them var aId: string | undefined; if (this.connectivityType === NatConnectivityType.PUBLIC) { @@ -476,6 +498,9 @@ export class VPCPeeringConnection extends Resource implements IRouteTarget { if (overlap) { throw new Error('CIDR block should not overlap with each other for establishing a peering connection'); } + if (props.vpcPeeringConnectionName) { + Tags.of(this).add(NAME_TAG, props.vpcPeeringConnectionName); + } this.resource = new CfnVPCPeeringConnection(this, 'VPCPeeringConnection', { vpcId: props.requestorVpc.vpcId, @@ -701,6 +726,9 @@ export class Route extends Resource implements IRouteV2 { } this.targetRouterType = this.target.gateway ? this.target.gateway.routerType : RouterType.VPC_ENDPOINT; + if (props.routeName) { + Tags.of(this).add(NAME_TAG, props.routeName); + } // Gateway generates route automatically via its RouteTable, thus we don't need to generate the resource for it if (!(this.target.endpoint instanceof GatewayVpcEndpoint)) { this.resource = new CfnRoute(this, 'Route', { @@ -761,6 +789,9 @@ export class RouteTable extends Resource implements IRouteTable { this.resource = new CfnRouteTable(this, 'RouteTable', { vpcId: props.vpc.vpcId, }); + if (props.routeTableName) { + Tags.of(this).add(NAME_TAG, props.routeTableName); + } this.node.defaultChild = this.resource; this.routeTableId = this.resource.attrRouteTableId; @@ -771,12 +802,14 @@ export class RouteTable extends Resource implements IRouteTable { * * @param destination The IPv4 or IPv6 CIDR block used for the destination match. * @param target The gateway or endpoint targeted by the route. + * @param routeName The resource name of the route. */ - public addRoute(id: string, destination: string, target: RouteTargetType) { + public addRoute(id: string, destination: string, target: RouteTargetType, routeName?: string) { new Route(this, id, { routeTable: this, destination: destination, target: target, + routeName: routeName, }); } } diff --git a/packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts b/packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts index 1300e782e94b4..dcfdb8f6ea345 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts +++ b/packages/@aws-cdk/aws-ec2-alpha/lib/subnet-v2.ts @@ -1,4 +1,4 @@ -import { Resource, Names, Lazy } from 'aws-cdk-lib'; +import { Resource, Names, Lazy, Tags } from 'aws-cdk-lib'; import { CfnSubnet, CfnSubnetRouteTableAssociation, INetworkAcl, IRouteTable, ISubnet, NetworkAcl, SubnetNetworkAclAssociation, SubnetType } from 'aws-cdk-lib/aws-ec2'; import { Construct, DependencyGroup, IDependable } from 'constructs'; import { IVpcV2 } from './vpc-v2-base'; @@ -27,6 +27,16 @@ export class IpCidr implements ICidr { } } +/** + * Name tag constant + */ +const NAME_TAG: string = 'Name'; + +/** + * VPC Name tag constant + */ +const VPCNAME_TAG: string = 'VpcName'; + /** * Properties to define subnet for VPC. */ @@ -282,12 +292,21 @@ export class SubnetV2 extends Resource implements ISubnetV2 { this._networkAcl = NetworkAcl.fromNetworkAclId(this, 'Acl', subnet.attrNetworkAclAssociationId); + if (props.subnetName) { + Tags.of(this).add(NAME_TAG, props.subnetName); + } + + if (props.vpc.vpcName) { + Tags.of(this).add(VPCNAME_TAG, props.vpc.vpcName); + } + if (props.routeTable) { this._routeTable = props.routeTable; } else { // Assigning a default route table this._routeTable = new RouteTable(this, 'RouteTable', { vpc: props.vpc, + routeTableName: 'DefaultCDKRouteTable', }); } diff --git a/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts b/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts index 26bde2cb903c8..3834bf4283c62 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts +++ b/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts @@ -24,6 +24,14 @@ export interface EgressOnlyInternetGatewayOptions { * @default - '::/0' all Ipv6 traffic */ readonly destination?: string; + + /** + * The resource name of the egress-only internet gateway. + * Provided name will be used for tagging + * + * @default - no name tag associated and provisioned without a resource name + */ + readonly egressOnlyInternetGatewayName?: string; } /** @@ -44,6 +52,14 @@ export interface InternetGatewayOptions{ * @default - '::/0' all Ipv6 traffic */ readonly ipv6Destination?: string; + + /** + * The resource name of the internet gateway. + * Provided name will be used for tagging + * + * @default - provisioned without a resource name + */ + readonly internetGatewayName?: string; } /** @@ -119,6 +135,12 @@ export interface IVpcV2 extends IVpc { */ readonly ipv4IpamProvisionedCidrs?: string[]; + /** + * VpcName to be used for tagging its components + * @attribute + */ + readonly vpcName?: string; + /** * Add an Egress only Internet Gateway to current VPC. * Can only be used for ipv6 enabled VPCs. @@ -234,6 +256,11 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { */ public abstract readonly ipv4CidrBlock: string; + /** + * VpcName to be used for tagging its components + */ + public abstract readonly vpcName?: string; + /** * Region for this VPC */ @@ -331,6 +358,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { * Adds VPNGAtewayV2 to this VPC */ public enableVpnGatewayV2(options: VPNGatewayV2Options): VPNGatewayV2 { + if (this.vpnGatewayId) { throw new Error('The VPN Gateway has already been enabled.'); } @@ -393,8 +421,10 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { * @default - in case of no input subnets, no route is created */ public addEgressOnlyInternetGateway(options?: EgressOnlyInternetGatewayOptions): void { + const egw = new EgressOnlyInternetGateway(this, 'EgressOnlyGW', { vpc: this, + egressOnlyInternetGatewayName: options?.egressOnlyInternetGatewayName, }); let useIpv6; @@ -425,6 +455,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { routeTable: subnet.routeTable, destination: destinationIpv6, // IPv6 default route target: { gateway: egw }, + routeName: 'CDKEIGWRoute', }); } @@ -440,6 +471,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { const igw = new InternetGateway(this, 'InternetGateway', { vpc: this, + internetGatewayName: options?.internetGatewayName, }); this._internetConnectivityEstablished.add(igw); @@ -467,6 +499,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { routeTable: subnet.routeTable, destination: options?.ipv6Destination ?? '::/0', target: { gateway: igw }, + routeName: 'CDKDefaultIPv6Route', }); } //Add default route to IGW for IPv4 @@ -474,6 +507,7 @@ export abstract class VpcV2Base extends Resource implements IVpcV2 { routeTable: subnet.routeTable, destination: options?.ipv4Destination ?? '0.0.0.0/0', target: { gateway: igw }, + routeName: 'CDKDefaultIPv4Route', }); } diff --git a/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts b/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts index 841bdcb6d8a63..f7b7381f66818 100644 --- a/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts +++ b/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts @@ -1,5 +1,5 @@ import { CfnVPC, CfnVPCCidrBlock, DefaultInstanceTenancy, ISubnet, SubnetType } from 'aws-cdk-lib/aws-ec2'; -import { Arn, CfnResource, Lazy, Names, Resource } from 'aws-cdk-lib/core'; +import { Arn, CfnResource, Lazy, Names, Resource, Tags } from 'aws-cdk-lib/core'; import { Construct, DependencyGroup, IDependable } from 'constructs'; import { IpamOptions, IIpamPool } from './ipam'; import { IVpcV2, VpcV2Base } from './vpc-v2-base'; @@ -136,6 +136,11 @@ export interface IIpAddresses { } +/** + * Name tag constant + */ +const NAME_TAG: string = 'Name'; + /** * Properties to define VPC * [disable-awslint:from-method] @@ -279,6 +284,7 @@ export class VpcV2 extends VpcV2Base { public readonly ipv4CidrBlock: string; public readonly region: string; public readonly ownerAccountId: string; + public readonly vpcName?: string; private readonly _partition?: string; /* @@ -437,6 +443,12 @@ export class VpcV2 extends VpcV2Base { */ public readonly useIpv6: boolean = false; + /** + * VpcName to be used for tagging its components + * @attribute + */ + public readonly vpcName?: string; + public readonly ipv4CidrBlock: string = ''; constructor(scope: Construct, id: string, props: VpcV2Props = {}) { @@ -445,7 +457,7 @@ export class VpcV2 extends VpcV2Base { produce: () => Names.uniqueResourceName(this, { maxLength: 128, allowedSpecialCharacters: '_' }), }), }); - + this.vpcName = props.vpcName; this.ipAddresses = props.primaryAddressBlock ?? IpAddresses.ipv4('10.0.0.0/16'); const vpcOptions = this.ipAddresses.allocateVpcCidr(); @@ -475,7 +487,8 @@ export class VpcV2 extends VpcV2Base { }, this.stack); this.region = this.stack.region; this.ownerAccountId = this.stack.account; - + //Add tag to the VPC with the name provided in properties + Tags.of(this).add(NAME_TAG, props.vpcName || this.node.path); if (props.secondaryAddressBlocks) { const secondaryAddressBlocks: IIpAddresses[] = props.secondaryAddressBlocks; @@ -732,7 +745,7 @@ class VPCCidrBlock extends Resource implements IVPCCidrBlock { public static fromVPCCidrBlockattributes(scope: Construct, id: string, props: VPCCidrBlockattributes) : IVPCCidrBlock { class Import extends Resource implements IVPCCidrBlock { public readonly cidrBlock = props.cidrBlock; - public readonly amazonProvidedIpv6CidrBlock ?: boolean = props.amazonProvidedIpv6CidrBlock;; + public readonly amazonProvidedIpv6CidrBlock ?: boolean = props.amazonProvidedIpv6CidrBlock; public readonly ipv6IpamPoolId ?: string = props.ipv6IpamPoolId; public readonly ipv4IpamPoolId ?: string = props.ipv4IpamPoolId; } diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.assets.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.assets.json new file mode 100644 index 0000000000000..e45dcde961163 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "e2906a6af2e011c6eb94f3ec392adad5218197bbffe23712a7dcdd4322d9024c": { + "source": { + "path": "aws-cdk-ec2-alpha-tag.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "e2906a6af2e011c6eb94f3ec392adad5218197bbffe23712a7dcdd4322d9024c.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.template.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.template.json new file mode 100644 index 0000000000000..ceb3fa67c097c --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/aws-cdk-ec2-alpha-tag.template.json @@ -0,0 +1,224 @@ +{ + "Resources": { + "VPCintegtesttag58C3A45F": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.1.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "CDKintegTestVPC" + } + ] + } + }, + "VPCintegtesttagSecondaryAddress2475BE474": { + "Type": "AWS::EC2::VPCCidrBlock", + "Properties": { + "CidrBlock": "10.2.0.0/16", + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "VPCintegtesttagAmazonProvided3931207E": { + "Type": "AWS::EC2::VPCCidrBlock", + "Properties": { + "AmazonProvidedIpv6CidrBlock": true, + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "VPCintegtesttagTestGWendpoint9E9D53AD": { + "Type": "AWS::EC2::VPCEndpoint", + "Properties": { + "RouteTableIds": [ + { + "Fn::GetAtt": [ + "testsubnetRouteTable682580B2", + "RouteTableId" + ] + } + ], + "ServiceName": { + "Fn::Join": [ + "", + [ + "com.amazonaws.", + { + "Ref": "AWS::Region" + }, + ".s3" + ] + ] + }, + "VpcEndpointType": "Gateway", + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + }, + "DependsOn": [ + "VPCintegtesttagAmazonProvided3931207E", + "VPCintegtesttagEgressOnlyGWEIGW161299BF", + "VPCintegtesttag58C3A45F", + "VPCintegtesttagSecondaryAddress2475BE474" + ] + }, + "VPCintegtesttagEgressOnlyGWEIGW161299BF": { + "Type": "AWS::EC2::EgressOnlyInternetGateway", + "Properties": { + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "testsubnetSubnetDD417829": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AssignIpv6AddressOnCreation": false, + "AvailabilityZone": "us-west-2b", + "CidrBlock": "10.2.0.0/24", + "Tags": [ + { + "Key": "Name", + "Value": "CDKIntegTestSubnet" + }, + { + "Key": "VpcName", + "Value": "CDKintegTestVPC" + } + ], + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + }, + "DependsOn": [ + "VPCintegtesttagAmazonProvided3931207E", + "VPCintegtesttagSecondaryAddress2475BE474" + ] + }, + "testsubnetRouteTable682580B2": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "CDKIntegTestSubnet" + }, + { + "Key": "VpcName", + "Value": "CDKintegTestVPC" + } + ], + "VpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + }, + "DependsOn": [ + "VPCintegtesttagAmazonProvided3931207E", + "VPCintegtesttagSecondaryAddress2475BE474" + ] + }, + "testsubnetRouteTableAssociationC106676D": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Fn::GetAtt": [ + "testsubnetRouteTable682580B2", + "RouteTableId" + ] + }, + "SubnetId": { + "Ref": "testsubnetSubnetDD417829" + } + }, + "DependsOn": [ + "VPCintegtesttagAmazonProvided3931207E", + "VPCintegtesttagSecondaryAddress2475BE474" + ] + }, + "IpamIntegTestIpam00B5B97A": { + "Type": "AWS::EC2::IPAM", + "Properties": { + "OperatingRegions": [ + { + "RegionName": "us-west-2" + } + ], + "Tags": [ + { + "Key": "NAME", + "Value": "CDKIpamTestTag" + } + ] + } + }, + "IpamScope": { + "Type": "AWS::EC2::IPAMScope", + "Properties": { + "IpamId": { + "Fn::GetAtt": [ + "IpamIntegTestIpam00B5B97A", + "IpamId" + ] + } + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/cdk.out b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integ.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integ.json new file mode 100644 index 0000000000000..0e4d323458194 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "integtest-model/DefaultTest": { + "stacks": [ + "aws-cdk-ec2-alpha-tag" + ], + "assertionStack": "integtest-model/DefaultTest/DeployAssert", + "assertionStackName": "integtestmodelDefaultTestDeployAssertCF40BD53" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.assets.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.assets.json new file mode 100644 index 0000000000000..1a14fac91ce61 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "integtestmodelDefaultTestDeployAssertCF40BD53.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.template.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/integtestmodelDefaultTestDeployAssertCF40BD53.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/manifest.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/manifest.json new file mode 100644 index 0000000000000..c162315e6d4d4 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/manifest.json @@ -0,0 +1,167 @@ +{ + "version": "38.0.1", + "artifacts": { + "aws-cdk-ec2-alpha-tag.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-ec2-alpha-tag.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-ec2-alpha-tag": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-ec2-alpha-tag.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e2906a6af2e011c6eb94f3ec392adad5218197bbffe23712a7dcdd4322d9024c.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-ec2-alpha-tag.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-cdk-ec2-alpha-tag.assets" + ], + "metadata": { + "/aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCintegtesttag58C3A45F" + } + ], + "/aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/SecondaryAddress2/SecondaryAddress2": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCintegtesttagSecondaryAddress2475BE474" + } + ], + "/aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/AmazonProvided/AmazonProvided": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCintegtesttagAmazonProvided3931207E" + } + ], + "/aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/TestGWendpoint/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCintegtesttagTestGWendpoint9E9D53AD" + } + ], + "/aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/EgressOnlyGW/EIGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCintegtesttagEgressOnlyGWEIGW161299BF" + } + ], + "/aws-cdk-ec2-alpha-tag/testsubnet/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "testsubnetSubnetDD417829" + } + ], + "/aws-cdk-ec2-alpha-tag/testsubnet/RouteTable/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "testsubnetRouteTable682580B2" + } + ], + "/aws-cdk-ec2-alpha-tag/testsubnet/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "testsubnetRouteTableAssociationC106676D" + } + ], + "/aws-cdk-ec2-alpha-tag/IpamIntegTest/Ipam": [ + { + "type": "aws:cdk:logicalId", + "data": "IpamIntegTestIpam00B5B97A" + } + ], + "/aws-cdk-ec2-alpha-tag/IpamScope": [ + { + "type": "aws:cdk:logicalId", + "data": "IpamScope" + } + ], + "/aws-cdk-ec2-alpha-tag/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-ec2-alpha-tag/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-ec2-alpha-tag" + }, + "integtestmodelDefaultTestDeployAssertCF40BD53.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integtestmodelDefaultTestDeployAssertCF40BD53.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integtestmodelDefaultTestDeployAssertCF40BD53": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integtestmodelDefaultTestDeployAssertCF40BD53.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integtestmodelDefaultTestDeployAssertCF40BD53.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integtestmodelDefaultTestDeployAssertCF40BD53.assets" + ], + "metadata": { + "/integtest-model/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integtest-model/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integtest-model/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/tree.json b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/tree.json new file mode 100644 index 0000000000000..3e034a2a74645 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.js.snapshot/tree.json @@ -0,0 +1,445 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-ec2-alpha-tag": { + "id": "aws-cdk-ec2-alpha-tag", + "path": "aws-cdk-ec2-alpha-tag", + "children": { + "VPC-integ-test-tag": { + "id": "VPC-integ-test-tag", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.1.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "CDKintegTestVPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "SecondaryAddress2": { + "id": "SecondaryAddress2", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/SecondaryAddress2", + "children": { + "SecondaryAddress2": { + "id": "SecondaryAddress2", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/SecondaryAddress2/SecondaryAddress2", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCCidrBlock", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.2.0.0/16", + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCCidrBlock", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "AmazonProvided": { + "id": "AmazonProvided", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/AmazonProvided", + "children": { + "AmazonProvided": { + "id": "AmazonProvided", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/AmazonProvided/AmazonProvided", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCCidrBlock", + "aws:cdk:cloudformation:props": { + "amazonProvidedIpv6CidrBlock": true, + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCCidrBlock", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "TestGWendpoint": { + "id": "TestGWendpoint", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/TestGWendpoint", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/TestGWendpoint/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCEndpoint", + "aws:cdk:cloudformation:props": { + "routeTableIds": [ + { + "Fn::GetAtt": [ + "testsubnetRouteTable682580B2", + "RouteTableId" + ] + } + ], + "serviceName": { + "Fn::Join": [ + "", + [ + "com.amazonaws.", + { + "Ref": "AWS::Region" + }, + ".s3" + ] + ] + }, + "vpcEndpointType": "Gateway", + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCEndpoint", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.GatewayVpcEndpoint", + "version": "0.0.0" + } + }, + "EgressOnlyGW": { + "id": "EgressOnlyGW", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/EgressOnlyGW", + "children": { + "EIGW": { + "id": "EIGW", + "path": "aws-cdk-ec2-alpha-tag/VPC-integ-test-tag/EgressOnlyGW/EIGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EgressOnlyInternetGateway", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEgressOnlyInternetGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2-alpha.EgressOnlyInternetGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2-alpha.VpcV2", + "version": "0.0.0" + } + }, + "testsubnet": { + "id": "testsubnet", + "path": "aws-cdk-ec2-alpha-tag/testsubnet", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-cdk-ec2-alpha-tag/testsubnet/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "assignIpv6AddressOnCreation": false, + "availabilityZone": "us-west-2b", + "cidrBlock": "10.2.0.0/24", + "tags": [ + { + "key": "Name", + "value": "CDKIntegTestSubnet" + }, + { + "key": "VpcName", + "value": "CDKintegTestVPC" + } + ], + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-cdk-ec2-alpha-tag/testsubnet/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-ec2-alpha-tag/testsubnet/RouteTable", + "children": { + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-ec2-alpha-tag/testsubnet/RouteTable/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "CDKIntegTestSubnet" + }, + { + "key": "VpcName", + "value": "CDKintegTestVPC" + } + ], + "vpcId": { + "Fn::GetAtt": [ + "VPCintegtesttag58C3A45F", + "VpcId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2-alpha.RouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-cdk-ec2-alpha-tag/testsubnet/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Fn::GetAtt": [ + "testsubnetRouteTable682580B2", + "RouteTableId" + ] + }, + "subnetId": { + "Ref": "testsubnetSubnetDD417829" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2-alpha.SubnetV2", + "version": "0.0.0" + } + }, + "IpamIntegTest": { + "id": "IpamIntegTest", + "path": "aws-cdk-ec2-alpha-tag/IpamIntegTest", + "children": { + "Ipam": { + "id": "Ipam", + "path": "aws-cdk-ec2-alpha-tag/IpamIntegTest/Ipam", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::IPAM", + "aws:cdk:cloudformation:props": { + "operatingRegions": [ + { + "regionName": "us-west-2" + } + ], + "tags": [ + { + "key": "NAME", + "value": "CDKIpamTestTag" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnIPAM", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2-alpha.Ipam", + "version": "0.0.0" + } + }, + "CustomIpamScope": { + "id": "CustomIpamScope", + "path": "aws-cdk-ec2-alpha-tag/CustomIpamScope", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "IpamScope": { + "id": "IpamScope", + "path": "aws-cdk-ec2-alpha-tag/IpamScope", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::IPAMScope", + "aws:cdk:cloudformation:props": { + "ipamId": { + "Fn::GetAtt": [ + "IpamIntegTestIpam00B5B97A", + "IpamId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnIPAMScope", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-ec2-alpha-tag/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-ec2-alpha-tag/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "integtest-model": { + "id": "integtest-model", + "path": "integtest-model", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "integtest-model/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "integtest-model/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "integtest-model/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integtest-model/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integtest-model/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.ts b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.ts new file mode 100644 index 0000000000000..0f1e41897763d --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/integ.vpc-v2-tagging.ts @@ -0,0 +1,62 @@ +import * as vpc_v2 from '../lib/vpc-v2'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as cdk from 'aws-cdk-lib'; +import { SubnetType, VpnConnectionType } from 'aws-cdk-lib/aws-ec2'; +import { SubnetV2, IpCidr } from '../lib/subnet-v2'; +//import { Ipam } from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'aws-cdk-ec2-alpha-tag'); + +/** Test Multiple Ipv4 Primary and Secondary address */ +const vpc = new vpc_v2.VpcV2(stack, 'VPC-integ-test-tag', { + primaryAddressBlock: vpc_v2.IpAddresses.ipv4('10.1.0.0/16'), + secondaryAddressBlocks: [ + vpc_v2.IpAddresses.ipv4('10.2.0.0/16', { + cidrBlockName: 'SecondaryAddress2', + }), + //Test Amazon provided secondary ipv6 address + vpc_v2.IpAddresses.amazonProvidedIpv6({ + cidrBlockName: 'AmazonProvided', + }), + ], + enableDnsHostnames: true, + enableDnsSupport: true, + vpcName: 'CDKintegTestVPC', +}); + +const subnet = new SubnetV2(stack, 'testsubnet', { + vpc, + availabilityZone: 'us-west-2b', + ipv4CidrBlock: new IpCidr('10.2.0.0/24'), + subnetType: SubnetType.PRIVATE_ISOLATED, + subnetName: 'CDKIntegTestSubnet', +}); + +vpc.addInternetGateway({ + internetGatewayName: 'CDKIntegTestTagIGW', +}); + +vpc.addNatGateway({ + natGatewayName: 'CDKIntegTestTagNGW', + subnet: subnet, +}); + +vpc.enableVpnGatewayV2({ + vpnGatewayName: 'CDKIntegTestTagVGW', + type: VpnConnectionType.IPSEC_1, +}); + +// const ipam = new Ipam(stack, 'IpamIntegTest', { +// operatingRegion: ['us-west-2'], +// ipamName: 'CDKIpamTestTag', +// }); + +// ipam.addScope(stack, 'CustomIpamScope', { +// ipamScopeName: 'CustomPrivateScopeTag', +// }); + +new IntegTest(app, 'integtest-model', { + testCases: [stack], +}); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2-alpha/test/vpc-tagging.test.ts b/packages/@aws-cdk/aws-ec2-alpha/test/vpc-tagging.test.ts new file mode 100644 index 0000000000000..3fa2897c1501b --- /dev/null +++ b/packages/@aws-cdk/aws-ec2-alpha/test/vpc-tagging.test.ts @@ -0,0 +1,302 @@ +import { Template } from 'aws-cdk-lib/assertions'; +import * as cdk from 'aws-cdk-lib'; +import * as vpc from '../lib/vpc-v2'; +import { IpCidr, SubnetV2 } from '../lib/subnet-v2'; +import { InternetGateway, NatGateway, RouteTable, VPCPeeringConnection, VPNGatewayV2 } from '../lib/route'; +import { SubnetType, VpnConnectionType } from 'aws-cdk-lib/aws-ec2'; +import { Ipam } from '../lib'; + +describe('Vpc V2 with full control', () => { + let stack: cdk.Stack; + + beforeEach(() => { + const app = new cdk.App({ + context: { + '@aws-cdk/core:newStyleStackSynthesis': false, + }, + }); + stack = new cdk.Stack(app); + }); + // Test VPC tagging + test('VPC has correct tags', () => { + new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPC', { + Tags: [ + { + Key: 'Name', + Value: 'MyTestVpc', + }, + ], + }); + }); + + // Test VPC tagging with default name + test('VPC has default tag when no name provided', () => { + new vpc.VpcV2(stack, 'TestVpc'); + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPC', { + Tags: [ + { + Key: 'Name', + Value: 'Default/TestVpc', + }, + ], + }); + }); + + test('Subnet has correct tags from Tags.of(this)', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + new SubnetV2(stack, 'TestSubnet', { + vpc: testVpc, + ipv4CidrBlock: new IpCidr('10.0.0.0/24'), + availabilityZone: 'us-east-1a', + subnetType: cdk.aws_ec2.SubnetType.PRIVATE_WITH_EGRESS, + subnetName: 'MyTestSubnet', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::Subnet', { + Tags: [ + { + Key: 'Name', + Value: 'MyTestSubnet', + }, + { + Key: 'VpcName', + Value: 'MyTestVpc', + }, + ], + }); + }); + + test('RouteTable has correct tags from Tags.of(this)', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + new RouteTable(stack, 'TestRouteTable', { + vpc: testVpc, + routeTableName: 'TestRouteTable', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::RouteTable', { + Tags: [ + { + Key: 'Name', + Value: 'TestRouteTable', + }, + ], + }); + }); + + test('InternetGateway has correct tags from Tags.of(this)', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + new InternetGateway(stack, 'TestIGW', { + vpc: testVpc, + internetGatewayName: 'TestIGW', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::InternetGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestIGW', + }, + ], + }); + }); + + test('NatGateway has correct tags from Tags.of(this)', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + const testSubnet = new SubnetV2(stack, 'TestSubnet', { + vpc: testVpc, + ipv4CidrBlock: new IpCidr('10.0.0.0/24'), + availabilityZone: 'us-east-1a', + subnetType: SubnetType.PUBLIC, + subnetName: 'MyTestSubnet', + }); + + new NatGateway(stack, 'TestNGW', { + vpc: testVpc, + subnet: testSubnet, + natGatewayName: 'TestNGW', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::NatGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestNGW', + }, + ], + }); + }); + + test('VPCPeeringConnection has correct tags from Tags.of(this)', () => { + const vpc1 = new vpc.VpcV2(stack, 'TestVpc1'); + const vpc2 = new vpc.VpcV2(stack, 'TestVpc2', { + primaryAddressBlock: vpc.IpAddresses.ipv4('10.1.0.0/16'), + }); + + new VPCPeeringConnection(stack, 'TestPeering', { + requestorVpc: vpc1, + acceptorVpc: vpc2, + vpcPeeringConnectionName: 'TestPeering', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPCPeeringConnection', { + Tags: [ + { + Key: 'Name', + Value: 'TestPeering', + }, + ], + }); + }); + + test('VPNGatewayV2 has correct tags from Tags.of(this)', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + new VPNGatewayV2(stack, 'TestVPNGateway', { + vpc: testVpc, + amazonSideAsn: 65000, + type: VpnConnectionType.DUMMY, + vpnGatewayName: 'TestVPNGateway', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPNGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestVPNGateway', + }, + ], + }); + }); + + // Testing the tags using add method + + test('NatGateway has correct tags from Tags.of(this) using add method', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + const testSubnet = new SubnetV2(stack, 'TestSubnet', { + vpc: testVpc, + ipv4CidrBlock: new IpCidr('10.0.0.0/24'), + availabilityZone: 'us-east-1a', + subnetType: SubnetType.PUBLIC, + subnetName: 'MyTestSubnet', + }); + + testVpc.addNatGateway({ + subnet: testSubnet, + natGatewayName: 'TestNGW', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::NatGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestNGW', + }, + ], + }); + }); + + test('VPNGatewayV2 has correct tags from Tags.of(this) using add method', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + testVpc.enableVpnGatewayV2({ + amazonSideAsn: 65000, + type: VpnConnectionType.DUMMY, + vpnGatewayName: 'TestVPNGateway', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPNGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestVPNGateway', + }, + ], + }); + }); + test('InternetGateway has correct tags from Tags.of(this) using add method', () => { + const testVpc = new vpc.VpcV2(stack, 'TestVpc', { + vpcName: 'MyTestVpc', + }); + + testVpc.addInternetGateway({ + internetGatewayName: 'TestIGW', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::InternetGateway', { + Tags: [ + { + Key: 'Name', + Value: 'TestIGW', + }, + ], + }); + }); + + test('VPCPeeringConnection has correct tags from Tags.of(this) using add method', () => { + const vpc1 = new vpc.VpcV2(stack, 'TestVpc1'); + const vpc2 = new vpc.VpcV2(stack, 'TestVpc2', { + primaryAddressBlock: vpc.IpAddresses.ipv4('10.1.0.0/16'), + }); + + vpc1.createPeeringConnection('TestPeeringConnection', { + acceptorVpc: vpc2, + vpcPeeringConnectionName: 'TestPeering', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPCPeeringConnection', { + Tags: [ + { + Key: 'Name', + Value: 'TestPeering', + }, + ], + }); + }); + + test('Adds tag to IPAM and IPAM Pool', () => { + const ipam = new Ipam(stack, 'TestIpam', { + ipamName: 'TestIpam', + }); + + ipam.addScope(stack, 'TestScope', { + ipamScopeName: 'TestScope', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::IPAM', { + Tags: [ + { + Key: 'NAME', + Value: 'TestIpam', + }, + ], + }); + Template.fromStack(stack).hasResourceProperties('AWS::EC2::IPAMScope', { + Tags: [ + { + Key: 'NAME', + Value: 'TestScope', + }, + ], + }); + }); +});