Skip to content

Commit

Permalink
fix(cdk): only make Outputs Exports when necessary (#1624)
Browse files Browse the repository at this point in the history
Export names must be unique and can conflict, so automatically turning
every Output into an Export can lead to problems for customers who
deploy the same template multiple times. Especially when the outputs
are created for them and they have no control over them.

We'll turn Outputs into exports on-demand (when .makeImportValue() is
called).

Fixes #903, fixes #1611.
  • Loading branch information
rix0rrr authored Feb 5, 2019
1 parent 09e216a commit ebb8aa1
Show file tree
Hide file tree
Showing 24 changed files with 96 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"S3BucketName": {
"Value": {
"Ref": "SampleAssetS3BucketE6B2908E"
},
"Export": {
"Name": "aws-cdk-asset-refs:S3BucketName"
}
},
"S3ObjectKey": {
Expand Down Expand Up @@ -51,9 +48,6 @@
}
]
]
},
"Export": {
"Name": "aws-cdk-asset-refs:S3ObjectKey"
}
},
"S3URL": {
Expand Down Expand Up @@ -102,9 +96,6 @@
}
]
]
},
"Export": {
"Name": "aws-cdk-asset-refs:S3URL"
}
}
},
Expand Down Expand Up @@ -184,4 +175,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,7 @@
"/"
]
]
},
"Export": {
"Name": "restapi-books-example:booksapiEndpointE230E8D5"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@
"/"
]
]
},
"Export": {
"Name": "test-apigateway-restapi-defaults:myapiEndpoint3628AFE3"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,7 @@
"/"
]
]
},
"Export": {
"Name": "test-apigateway-restapi:myapiEndpoint3628AFE3"
}
}
}
}
}
3 changes: 1 addition & 2 deletions packages/@aws-cdk/aws-apigateway/test/test.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ export = {
{ Ref: "myapiDeploymentStageprod298F01AF" },
"/"
]]
},
Export: { Name: "myapiEndpoint3628AFE3" }
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
"DemoResource5B5C546C",
"Response"
]
},
"Export": {
"Name": "SucceedingStack:ResponseMessage"
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
},
"Outputs": {
"PublicSubnets": {
"Value": "ids:subnet-e19455ca,subnet-e0c24797,subnet-ccd77395",
"Export": {
"Name": "aws-cdk-ec2-import:PublicSubnets"
}
"Value": "ids:subnet-e19455ca,subnet-e0c24797,subnet-ccd77395"
},
"PrivateSubnets": {
"Value": "ids:",
"Export": {
"Name": "aws-cdk-ec2-import:PrivateSubnets"
}
"Value": "ids:"
}
}
}
}
5 changes: 1 addition & 4 deletions packages/@aws-cdk/aws-ecr/test/integ.basic.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@
}
]
]
},
"Export": {
"Name": "aws-ecr-integ-stack:RepositoryURI"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,6 @@
"LB8A12904C",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ:LoadBalancerDNS"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,6 @@
"LB8A12904C",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ-ecs:LoadBalancerDNS"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,6 @@
"FargateServiceLBB353E155",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ:FargateServiceLoadBalancerDNS9433D5F6"
}
},
"LoadBalancerDNS": {
Expand All @@ -1013,9 +1010,6 @@
"FargateServiceLBB353E155",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ:LoadBalancerDNS"
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions packages/@aws-cdk/aws-ecs/test/fargate/integ.l3.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,6 @@
"L3LB212FC0E0",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ:L3LoadBalancerDNSC6CB4A70"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,6 @@
"LB8A12904C",
"DNSName"
]
},
"Export": {
"Name": "aws-ecs-integ:LoadBalancerDNS"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,12 @@
"PrivateZoneId": {
"Value": {
"Ref": "PrivateZone27242E85"
},
"Export": {
"Name": "aws-cdk-route53-integ:PrivateZoneId"
}
},
"PublicZoneId": {
"Value": {
"Ref": "PublicZone2E1C4E34"
},
"Export": {
"Name": "aws-cdk-route53-integ:PublicZoneId"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
}
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
"RealBucketDomain": {
"Value": {
"Fn::GetAtt":["MyBucketF68F3FF0","DomainName"]
},
"Export": {
"Name": "aws-cdk-s3-urls:RealBucketDomain"
}
},
"ImportedBucketDomain": {
"Value": "my-bucket-test.s3.amazonaws.com",
"Export": {
"Name": "aws-cdk-s3-urls:ImportedBucketDomain"
}
"Value": "my-bucket-test.s3.amazonaws.com"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
}
]
]
},
"Export": {
"Name": "aws-cdk-s3-urls:BucketURL"
}
},
"ObjectURL": {
Expand All @@ -49,9 +46,6 @@
"/myfolder/myfile.txt"
]
]
},
"Export": {
"Name": "aws-cdk-s3-urls:ObjectURL"
}
}
}
Expand Down
13 changes: 1 addition & 12 deletions packages/@aws-cdk/aws-s3/test/test.bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,7 @@ export = {
"WebsiteURL"
]
},
"Export": {
"Name": "MyBucketWebsiteURL9C222788"
}
"Export": {"Name": "MyBucketWebsiteURL9C222788"}
}
}
});
Expand Down Expand Up @@ -1083,9 +1081,6 @@ export = {
]
]
},
"Export": {
"Name": "BucketURL"
}
},
"MyFileURL": {
"Value": {
Expand All @@ -1107,9 +1102,6 @@ export = {
"/my/file.txt"
]
]
},
"Export": {
"Name": "MyFileURL"
}
},
"YourFileURL": {
Expand All @@ -1133,9 +1125,6 @@ export = {
]
]
},
"Export": {
"Name": "YourFileURL"
}
}
}
});
Expand Down
5 changes: 1 addition & 4 deletions packages/@aws-cdk/aws-sqs/test/integ.sqs.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
"QueueUrl": {
"Value": {
"Ref": "Queue4A7E3555"
},
"Export": {
"Name": "aws-cdk-sqs:QueueUrl"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@
]
}
]
},
"Export": {
"Name": "SSM-Parameter:StringListOutput"
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cdk/lib/cloudformation/cfn-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class CfnReference extends Token {

// We want to return an actual FnImportValue Token here, but Fn.importValue() returns a 'string',
// so construct one in-place.
return new Token({ 'Fn::ImportValue': output.export });
return new Token({ 'Fn::ImportValue': output.obtainExportName() });
}

}
Expand Down
Loading

0 comments on commit ebb8aa1

Please sign in to comment.