diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/util.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/util.ts index 3666d078f4a7f..518e0865161c9 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/util.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/util.ts @@ -1,6 +1,6 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; +import { Arn, ArnFormat, Fn, Token } from '@aws-cdk/core'; import { ApplicationProtocol, Protocol } from './enums'; -import { Arn, ArnFormat } from '@aws-cdk/core'; export type Attributes = { [key: string]: string | undefined }; @@ -92,10 +92,21 @@ export function mapTagMapToCxschema(tagMap: Record): cxschema.Ta .map(([key, value]) => ({ key, value })); } -export function parseLoadBalancerFullName(loadBalancerArn: string): string { - const arnComponents = Arn.split(loadBalancerArn, ArnFormat.SLASH_RESOURCE_NAME); - if (!arnComponents.resourceName) { - throw new Error(`Provided ARN does not belong to a load balancer: ${loadBalancerArn}`); +export function parseLoadBalancerFullName(arn: string): string { + if (Token.isUnresolved(arn)) { + // Unfortunately it is not possible to use Arn.split() because the ARNs have this shape: + // + // arn:...:loadbalancer/net/my-load-balancer/123456 + // + // And the way that Arn.split() handles this situation is not enough to obtain the full name + const arnParts = Fn.split('/', arn); + return `${Fn.select(1, arnParts)}/${Fn.select(2, arnParts)}/${Fn.select(3, arnParts)}`; + } else { + const arnComponents = Arn.split(arn, ArnFormat.SLASH_RESOURCE_NAME); + const resourceName = arnComponents.resourceName; + if (!resourceName) { + throw new Error(`Provided ARN does not belong to a load balancer: ${arn}`); + } + return resourceName; } - return arnComponents.resourceName; } diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.assets.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.assets.json index de8afd591772f..e830638335cf4 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.assets.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.assets.json @@ -1,17 +1,17 @@ { "version": "29.0.0", "files": { - "b2b2e615554259736dccb6ecc100edae2dc9d18e7d4b2103b6b7ebacebba8485": { + "e24b7b4b9bebbe70e470dbe2c83f8f69c8338d37b258b8ebec384b51fd61536d": { "source": { "path": "aws-cdk-elbv2-StackWithLb.template.json", "packaging": "file" }, "destinations": { - "123456-eu-west-1": { - "bucketName": "cdk-hnb659fds-assets-123456-eu-west-1", - "objectKey": "b2b2e615554259736dccb6ecc100edae2dc9d18e7d4b2103b6b7ebacebba8485.json", - "region": "eu-west-1", - "assumeRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-file-publishing-role-123456-eu-west-1" + "12345678-test-region": { + "bucketName": "cdk-hnb659fds-assets-12345678-test-region", + "objectKey": "e24b7b4b9bebbe70e470dbe2c83f8f69c8338d37b258b8ebec384b51fd61536d.json", + "region": "test-region", + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-file-publishing-role-12345678-test-region" } } } diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.template.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.template.json index c2966a3dabc2c..4170f7e23915c 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.template.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-StackWithLb.template.json @@ -21,7 +21,7 @@ "VpcId": { "Ref": "VPCB9E5F0B4" }, - "AvailabilityZone": "dummy1a", + "AvailabilityZone": "test-region-1a", "CidrBlock": "10.0.0.0/18", "MapPublicIpOnLaunch": true, "Tags": [ @@ -122,7 +122,7 @@ "VpcId": { "Ref": "VPCB9E5F0B4" }, - "AvailabilityZone": "dummy1b", + "AvailabilityZone": "test-region-1b", "CidrBlock": "10.0.64.0/18", "MapPublicIpOnLaunch": true, "Tags": [ @@ -223,7 +223,7 @@ "VpcId": { "Ref": "VPCB9E5F0B4" }, - "AvailabilityZone": "dummy1a", + "AvailabilityZone": "test-region-1a", "CidrBlock": "10.0.128.0/18", "MapPublicIpOnLaunch": false, "Tags": [ @@ -285,7 +285,7 @@ "VpcId": { "Ref": "VPCB9E5F0B4" }, - "AvailabilityZone": "dummy1b", + "AvailabilityZone": "test-region-1b", "CidrBlock": "10.0.192.0/18", "MapPublicIpOnLaunch": false, "Tags": [ @@ -382,12 +382,6 @@ "Ref": "VPCPublicSubnet2Subnet74179F39" } ], - "Tags": [ - { - "Key": "some", - "Value": "tag" - } - ], "Type": "network" }, "DependsOn": [ @@ -398,6 +392,24 @@ ] } }, + "Outputs": { + "NlbArn": { + "Value": { + "Ref": "LB8A12904C" + }, + "Export": { + "Name": "NlbArn" + } + }, + "ExportsOutputRefLB8A12904C1150D6A6": { + "Value": { + "Ref": "LB8A12904C" + }, + "Export": { + "Name": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + } + }, "Parameters": { "BootstrapVersion": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.assets.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.assets.json index 7cbc4f901fc43..37afa2c575793 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.assets.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.assets.json @@ -1,17 +1,17 @@ { "version": "29.0.0", "files": { - "c90244dbab9ab3bd198b9233fcf42c068fad41afc3efb1b1a1b12d352b81970d": { + "e42d9c4a114328c16cb773781b2fee3cceeb499294ef3cb4f7a0aeafce947f13": { "source": { "path": "aws-cdk-elbv2-integ-StackUnderTest.template.json", "packaging": "file" }, "destinations": { - "123456-eu-west-1": { - "bucketName": "cdk-hnb659fds-assets-123456-eu-west-1", - "objectKey": "c90244dbab9ab3bd198b9233fcf42c068fad41afc3efb1b1a1b12d352b81970d.json", - "region": "eu-west-1", - "assumeRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-file-publishing-role-123456-eu-west-1" + "12345678-test-region": { + "bucketName": "cdk-hnb659fds-assets-12345678-test-region", + "objectKey": "e42d9c4a114328c16cb773781b2fee3cceeb499294ef3cb4f7a0aeafce947f13.json", + "region": "test-region", + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-file-publishing-role-12345678-test-region" } } } diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.template.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.template.json index 9090201be1346..0356b00b65d81 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.template.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/aws-cdk-elbv2-integ-StackUnderTest.template.json @@ -1,6 +1,6 @@ { "Resources": { - "NlbByAttributesAlarmFlowCountB9EE6965": { + "NlbByHardcodedArnAlarmFlowCount60A46641": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "ComparisonOperator": "GreaterThanOrEqualToThreshold", @@ -17,6 +17,136 @@ "Statistic": "Average", "Threshold": 0 } + }, + "NlbByCfnOutputsFromAnotherStackOutsideCdkAlarmFlowCountD9A1D5AC": { + "Type": "AWS::CloudWatch::Alarm", + "Properties": { + "ComparisonOperator": "GreaterThanOrEqualToThreshold", + "EvaluationPeriods": 1, + "Dimensions": [ + { + "Name": "LoadBalancer", + "Value": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + } + ] + ] + } + } + ], + "MetricName": "ActiveFlowCount", + "Namespace": "AWS/NetworkELB", + "Period": 300, + "Statistic": "Average", + "Threshold": 0 + } + }, + "NlbByCfnOutputsFromAnotherStackWithinCdkAlarmFlowCountD865DB84": { + "Type": "AWS::CloudWatch::Alarm", + "Properties": { + "ComparisonOperator": "GreaterThanOrEqualToThreshold", + "EvaluationPeriods": 1, + "Dimensions": [ + { + "Name": "LoadBalancer", + "Value": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + } + ] + ] + } + } + ], + "MetricName": "ActiveFlowCount", + "Namespace": "AWS/NetworkELB", + "Period": 300, + "Statistic": "Average", + "Threshold": 0 + } } }, "Parameters": { diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/integ.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/integ.json index 97d4c77fd964a..c87d22abd7b94 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/integ.json @@ -1,4 +1,5 @@ { + "enableLookups": true, "version": "29.0.0", "testCases": { "elbv2-integ/DefaultTest": { @@ -8,8 +9,8 @@ }, "aws-cdk-elbv2-integ-StackUnderTest/aws-cdk-elbv2-integ-StackUnderTestTestCase": { "env": { - "account": "123456", - "region": "eu-west-1" + "account": "12345678", + "region": "test-region" }, "stacks": [ "aws-cdk-elbv2-integ-StackUnderTest" diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/manifest.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/manifest.json index e7748e9449349..ecb92960fabc0 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/manifest.json @@ -1,6 +1,209 @@ { "version": "29.0.0", "artifacts": { + "aws-cdk-elbv2-StackWithLb.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-elbv2-StackWithLb.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-elbv2-StackWithLb": { + "type": "aws:cloudformation:stack", + "environment": "aws://12345678/test-region", + "properties": { + "templateFile": "aws-cdk-elbv2-StackWithLb.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-deploy-role-12345678-test-region", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-cfn-exec-role-12345678-test-region", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-12345678-test-region/e24b7b4b9bebbe70e470dbe2c83f8f69c8338d37b258b8ebec384b51fd61536d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-elbv2-StackWithLb.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-lookup-role-12345678-test-region", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-cdk-elbv2-StackWithLb.assets" + ], + "metadata": { + "/aws-cdk-elbv2-StackWithLb/VPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCB9E5F0B4" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1SubnetB4246D30" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableFEE4B781" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableAssociation0B0896DC" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1DefaultRoute91CEF279" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1EIP6AD938E8" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1NATGatewayE0556630" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2Subnet74179F39" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTable6F1A15F1" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTableAssociation5A808732" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2DefaultRouteB7481BBA" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2EIP4947BC00" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2NATGateway3C070193" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1Subnet8BCA10E0" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableBE8A6027" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableAssociation347902D1" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1DefaultRouteAE1D6490" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTable0A19E10E" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTableAssociation0C73D413" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2DefaultRouteF4F5CFD2" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCIGWB7E252D3" + } + ], + "/aws-cdk-elbv2-StackWithLb/VPC/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCVPCGW99B986DC" + } + ], + "/aws-cdk-elbv2-StackWithLb/LB/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "LB8A12904C" + } + ], + "/aws-cdk-elbv2-StackWithLb/NlbArn": [ + { + "type": "aws:cdk:logicalId", + "data": "NlbArn" + } + ], + "/aws-cdk-elbv2-StackWithLb/Exports/Output{\"Ref\":\"LB8A12904C\"}": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsOutputRefLB8A12904C1150D6A6" + } + ], + "/aws-cdk-elbv2-StackWithLb/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-elbv2-StackWithLb/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-elbv2-StackWithLb" + }, "awscdkelbv2integStackUnderTestDeployAssert483BFB1A.assets": { "type": "cdk:asset-manifest", "properties": { @@ -105,32 +308,45 @@ }, "aws-cdk-elbv2-integ-StackUnderTest": { "type": "aws:cloudformation:stack", - "environment": "aws://123456/eu-west-1", + "environment": "aws://12345678/test-region", "properties": { "templateFile": "aws-cdk-elbv2-integ-StackUnderTest.template.json", "validateOnSynth": false, - "assumeRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-deploy-role-123456-eu-west-1", - "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-cfn-exec-role-123456-eu-west-1", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-123456-eu-west-1/c90244dbab9ab3bd198b9233fcf42c068fad41afc3efb1b1a1b12d352b81970d.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-deploy-role-12345678-test-region", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-cfn-exec-role-12345678-test-region", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-12345678-test-region/e42d9c4a114328c16cb773781b2fee3cceeb499294ef3cb4f7a0aeafce947f13.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ "aws-cdk-elbv2-integ-StackUnderTest.assets" ], "lookupRole": { - "arn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-lookup-role-123456-eu-west-1", + "arn": "arn:${AWS::Partition}:iam::12345678:role/cdk-hnb659fds-lookup-role-12345678-test-region", "requiresBootstrapStackVersion": 8, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" } }, "dependencies": [ + "aws-cdk-elbv2-StackWithLb", "aws-cdk-elbv2-integ-StackUnderTest.assets" ], "metadata": { - "/aws-cdk-elbv2-integ-StackUnderTest/NlbByAttributes_AlarmFlowCount/Resource": [ + "/aws-cdk-elbv2-integ-StackUnderTest/NlbByHardcodedArn_AlarmFlowCount/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NlbByHardcodedArnAlarmFlowCount60A46641" + } + ], + "/aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "NlbByCfnOutputsFromAnotherStackOutsideCdkAlarmFlowCountD9A1D5AC" + } + ], + "/aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount/Resource": [ { "type": "aws:cdk:logicalId", - "data": "NlbByAttributesAlarmFlowCountB9EE6965" + "data": "NlbByCfnOutputsFromAnotherStackWithinCdkAlarmFlowCountD865DB84" } ], "/aws-cdk-elbv2-integ-StackUnderTest/BootstrapVersion": [ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/tree.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/tree.json index 040b056ab3ada..16876b01d13bb 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.js.snapshot/tree.json @@ -4,6 +4,713 @@ "id": "App", "path": "", "children": { + "aws-cdk-elbv2-StackWithLb": { + "id": "aws-cdk-elbv2-StackWithLb", + "path": "aws-cdk-elbv2-StackWithLb", + "children": { + "VPC": { + "id": "VPC", + "path": "aws-cdk-elbv2-StackWithLb/VPC", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-elbv2-StackWithLb/VPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "my-vpc-name" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "availabilityZone": "test-region-1a", + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "availabilityZone": "test-region-1b", + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "availabilityZone": "test-region-1a", + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "availabilityZone": "test-region-1b", + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "tags": [ + { + "key": "Name", + "value": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-cdk-elbv2-StackWithLb/VPC/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "aws-cdk-elbv2-StackWithLb/VPC/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "my-vpc-name" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "aws-cdk-elbv2-StackWithLb/VPC/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "VPCB9E5F0B4" + }, + "internetGatewayId": { + "Ref": "VPCIGWB7E252D3" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.Vpc", + "version": "0.0.0" + } + }, + "LB": { + "id": "LB", + "path": "aws-cdk-elbv2-StackWithLb/LB", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-elbv2-StackWithLb/LB/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ElasticLoadBalancingV2::LoadBalancer", + "aws:cdk:cloudformation:props": { + "loadBalancerAttributes": [ + { + "key": "deletion_protection.enabled", + "value": "false" + } + ], + "name": "my-load-balancer", + "scheme": "internet-facing", + "subnets": [ + { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + ], + "type": "network" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-elasticloadbalancingv2.CfnLoadBalancer", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-elasticloadbalancingv2.NetworkLoadBalancer", + "version": "0.0.0" + } + }, + "NlbArn": { + "id": "NlbArn", + "path": "aws-cdk-elbv2-StackWithLb/NlbArn", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + }, + "Exports": { + "id": "Exports", + "path": "aws-cdk-elbv2-StackWithLb/Exports", + "children": { + "Output{\"Ref\":\"LB8A12904C\"}": { + "id": "Output{\"Ref\":\"LB8A12904C\"}", + "path": "aws-cdk-elbv2-StackWithLb/Exports/Output{\"Ref\":\"LB8A12904C\"}", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.237" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-elbv2-StackWithLb/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-elbv2-StackWithLb/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, "aws-cdk-elbv2-integ-StackUnderTest": { "id": "aws-cdk-elbv2-integ-StackUnderTest", "path": "aws-cdk-elbv2-integ-StackUnderTest", @@ -13,7 +720,7 @@ "path": "aws-cdk-elbv2-integ-StackUnderTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.216" + "version": "10.1.237" } }, "DeployAssert": { @@ -51,7 +758,7 @@ "path": "aws-cdk-elbv2-integ-StackUnderTest/aws-cdk-elbv2-integ-StackUnderTestTestCase/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.216" + "version": "10.1.237" } }, "DeployAssert": { @@ -86,21 +793,21 @@ "version": "0.0.0" } }, - "NlbByAttributes": { - "id": "NlbByAttributes", - "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByAttributes", + "NlbByHardcodedArn": { + "id": "NlbByHardcodedArn", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByHardcodedArn", "constructInfo": { "fqn": "@aws-cdk/core.Resource", "version": "0.0.0" } }, - "NlbByAttributes_AlarmFlowCount": { - "id": "NlbByAttributes_AlarmFlowCount", - "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByAttributes_AlarmFlowCount", + "NlbByHardcodedArn_AlarmFlowCount": { + "id": "NlbByHardcodedArn_AlarmFlowCount", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByHardcodedArn_AlarmFlowCount", "children": { "Resource": { "id": "Resource", - "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByAttributes_AlarmFlowCount/Resource", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByHardcodedArn_AlarmFlowCount/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", "aws:cdk:cloudformation:props": { @@ -130,6 +837,188 @@ "version": "0.0.0" } }, + "NlbByCfnOutputsFromAnotherStackOutsideCdk": { + "id": "NlbByCfnOutputsFromAnotherStackOutsideCdk", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackOutsideCdk", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount": { + "id": "NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", + "aws:cdk:cloudformation:props": { + "comparisonOperator": "GreaterThanOrEqualToThreshold", + "evaluationPeriods": 1, + "dimensions": [ + { + "name": "LoadBalancer", + "value": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "NlbArn" + } + ] + } + ] + } + ] + ] + } + } + ], + "metricName": "ActiveFlowCount", + "namespace": "AWS/NetworkELB", + "period": 300, + "statistic": "Average", + "threshold": 0 + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-cloudwatch.CfnAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-cloudwatch.Alarm", + "version": "0.0.0" + } + }, + "NlbByCfnOutputsFromAnotherStackWithinCdk": { + "id": "NlbByCfnOutputsFromAnotherStackWithinCdk", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackWithinCdk", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount": { + "id": "NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-elbv2-integ-StackUnderTest/NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", + "aws:cdk:cloudformation:props": { + "comparisonOperator": "GreaterThanOrEqualToThreshold", + "evaluationPeriods": 1, + "dimensions": [ + { + "name": "LoadBalancer", + "value": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + "/", + { + "Fn::ImportValue": "aws-cdk-elbv2-StackWithLb:ExportsOutputRefLB8A12904C1150D6A6" + } + ] + } + ] + } + ] + ] + } + } + ], + "metricName": "ActiveFlowCount", + "namespace": "AWS/NetworkELB", + "period": 300, + "statistic": "Average", + "threshold": 0 + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-cloudwatch.CfnAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-cloudwatch.Alarm", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-elbv2-integ-StackUnderTest/BootstrapVersion", @@ -165,7 +1054,7 @@ "path": "elbv2-integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.216" + "version": "10.1.237" } }, "DeployAssert": { @@ -211,7 +1100,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.216" + "version": "10.1.237" } } }, diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.ts index 820416949836c..ef5a0f7125ada 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/integ.nlb-lookup.ts @@ -1,11 +1,11 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; import * as integ from '@aws-cdk/integ-tests'; -import * as elbv2 from '../lib'; import { IntegTestCaseStack } from '@aws-cdk/integ-tests'; +import * as elbv2 from '../lib'; -const appWithLb = new cdk.App(); -const stackWithLb = new cdk.Stack(appWithLb, 'aws-cdk-elbv2-StackWithLb', { +const app = new cdk.App(); +const stackWithLb = new cdk.Stack(app, 'aws-cdk-elbv2-StackWithLb', { env: { account: process.env.CDK_INTEG_ACCOUNT ?? process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_INTEG_REGION ?? process.env.CDK_DEFAULT_REGION, @@ -22,29 +22,45 @@ const lb = new elbv2.NetworkLoadBalancer(stackWithLb, 'LB', { internetFacing: true, loadBalancerName: 'my-load-balancer', }); -cdk.Tags.of(lb).add('some', 'tag'); -const lbArn = 'arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/network/my-load-balancer/50dc6c495c0c9188'; +new cdk.CfnOutput(stackWithLb, 'NlbArn', { + value: lb.loadBalancerArn, + exportName: 'NlbArn', +}); -const appUnderTest = new cdk.App(); -const stackLookup = new IntegTestCaseStack(appUnderTest, 'aws-cdk-elbv2-integ-StackUnderTest', { +const stackLookup = new IntegTestCaseStack(app, 'aws-cdk-elbv2-integ-StackUnderTest', { env: { account: process.env.CDK_INTEG_ACCOUNT ?? process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_INTEG_REGION ?? process.env.CDK_DEFAULT_REGION, }, }); -const lbByAttributes = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stackLookup, 'NlbByAttributes', { - loadBalancerArn: lbArn, +const lbByHardcodedArn = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stackLookup, 'NlbByHardcodedArn', { + loadBalancerArn: 'arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/network/my-load-balancer/50dc6c495c0c9188', +}); +lbByHardcodedArn.metrics.activeFlowCount().createAlarm(stackLookup, 'NlbByHardcodedArn_AlarmFlowCount', { + evaluationPeriods: 1, + threshold: 0, +}); + +const lbByCfnOutputsFromAnotherStackOutsideCdk = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stackLookup, 'NlbByCfnOutputsFromAnotherStackOutsideCdk', { + loadBalancerArn: cdk.Fn.importValue('NlbArn'), +}); +lbByCfnOutputsFromAnotherStackOutsideCdk.metrics.activeFlowCount().createAlarm(stackLookup, 'NlbByCfnOutputsFromAnotherStackOutsideCdk_AlarmFlowCount', { + evaluationPeriods: 1, + threshold: 0, }); -lbByAttributes.metrics.activeFlowCount().createAlarm(stackLookup, 'NlbByAttributes_AlarmFlowCount', { +const lbByCfnOutputsFromAnotherStackWithinCdk = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stackLookup, 'NlbByCfnOutputsFromAnotherStackWithinCdk', { + loadBalancerArn: lb.loadBalancerArn, +}); +lbByCfnOutputsFromAnotherStackWithinCdk.metrics.activeFlowCount().createAlarm(stackLookup, 'NlbByCfnOutputsFromAnotherStackWithinCdk_AlarmFlowCount', { evaluationPeriods: 1, threshold: 0, }); -new integ.IntegTest(appUnderTest, 'elbv2-integ', { +new integ.IntegTest(app, 'elbv2-integ', { testCases: [stackLookup], + enableLookups: true, }); -appWithLb.synth(); -appUnderTest.synth(); +app.synth();