Skip to content

Commit 8cc9abe

Browse files
authored
Merge 790318e into ad91fd2
2 parents ad91fd2 + 790318e commit 8cc9abe

File tree

4 files changed

+64
-15
lines changed

4 files changed

+64
-15
lines changed

packages/@aws-cdk/aws-s3-assets/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ to an S3 bucket during deployment.
3232

3333
`Asset` constructs expose the following deploy-time attributes:
3434

35+
* `httpUrl` - the HTTP URL of the asset (i.e. https://s3.us-east-1.amazonaws.com/mybucket/mykey.zip)
3536
* `s3BucketName` - the name of the assets S3 bucket.
3637
* `s3ObjectKey` - the S3 object key of the asset file (whether it's a file or a zip archive)
37-
* `s3Url` - the S3 URL of the asset (i.e. https://s3.us-east-1.amazonaws.com/mybucket/mykey.zip)
38+
* `s3UrlObject` - the S3 URL of the asset (i.e. s3://mybucket/mykey.zip)
3839

3940
In the following example, the various asset attributes are exported as stack outputs:
4041

packages/@aws-cdk/aws-s3-assets/lib/asset.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export interface AssetProps extends AssetOptions {
5151
* and then can be referenced within a CDK application.
5252
*/
5353
export class Asset extends cdk.Construct implements assets.IAsset {
54+
/**
55+
* Attribute which represents the HTTP URL of this asset.
56+
* @example https://s3.us-west-1.amazonaws.com/bucket/key
57+
*/
58+
public readonly httpUrl: string;
59+
5460
/**
5561
* Attribute that represents the name of the bucket this asset exists in.
5662
*/
@@ -63,9 +69,9 @@ export class Asset extends cdk.Construct implements assets.IAsset {
6369

6470
/**
6571
* Attribute which represents the S3 URL of this asset.
66-
* @example https://s3.us-west-1.amazonaws.com/bucket/key
72+
* @example s3://bucket/key
6773
*/
68-
public readonly s3Url: string;
74+
public readonly s3ObjectUrl: string;
6975

7076
/**
7177
* The path to the asset (stringinfied token).
@@ -116,9 +122,10 @@ export class Asset extends cdk.Construct implements assets.IAsset {
116122
fileName: staging.stagedPath,
117123
});
118124

125+
this.httpUrl = location.httpUrl;
119126
this.s3BucketName = location.bucketName;
120127
this.s3ObjectKey = location.objectKey;
121-
this.s3Url = location.s3Url;
128+
this.s3ObjectUrl = `s3://${this.s3BucketName}/${this.s3ObjectKey}`;
122129

123130
this.bucket = s3.Bucket.fromBucketName(this, 'AssetBucket', this.s3BucketName);
124131

packages/@aws-cdk/aws-s3-assets/test/integ.assets.refs.lit.expected.json

+50-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,54 @@
1414
}
1515
},
1616
"Outputs": {
17+
"HTTPURL": {
18+
"Value": {
19+
"Fn::Join": [
20+
"",
21+
[
22+
"https://s3.",
23+
{
24+
"Ref": "AWS::Region"
25+
},
26+
".",
27+
{
28+
"Ref": "AWS::URLSuffix"
29+
},
30+
"/",
31+
{
32+
"Ref": "AssetParameters6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2S3Bucket50B5A10B"
33+
},
34+
"/",
35+
{
36+
"Fn::Select": [
37+
0,
38+
{
39+
"Fn::Split": [
40+
"||",
41+
{
42+
"Ref": "AssetParameters6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2S3VersionKey1F7D75F9"
43+
}
44+
]
45+
}
46+
]
47+
},
48+
{
49+
"Fn::Select": [
50+
1,
51+
{
52+
"Fn::Split": [
53+
"||",
54+
{
55+
"Ref": "AssetParameters6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2S3VersionKey1F7D75F9"
56+
}
57+
]
58+
}
59+
]
60+
}
61+
]
62+
]
63+
}
64+
},
1765
"S3BucketName": {
1866
"Value": {
1967
"Ref": "AssetParameters6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2S3Bucket50B5A10B"
@@ -54,20 +102,12 @@
54102
]
55103
}
56104
},
57-
"S3URL": {
105+
"S3ObjectUrl": {
58106
"Value": {
59107
"Fn::Join": [
60108
"",
61109
[
62-
"https://s3.",
63-
{
64-
"Ref": "AWS::Region"
65-
},
66-
".",
67-
{
68-
"Ref": "AWS::URLSuffix"
69-
},
70-
"/",
110+
"s3://",
71111
{
72112
"Ref": "AssetParameters6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2S3Bucket50B5A10B"
73113
},

packages/@aws-cdk/aws-s3-assets/test/integ.assets.refs.lit.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class TestStack extends cdk.Stack {
1212
path: path.join(__dirname, 'sample-asset-directory'),
1313
});
1414

15+
new cdk.CfnOutput(this, 'HTTPURL', { value: asset.httpUrl });
1516
new cdk.CfnOutput(this, 'S3BucketName', { value: asset.s3BucketName });
1617
new cdk.CfnOutput(this, 'S3ObjectKey', { value: asset.s3ObjectKey });
17-
new cdk.CfnOutput(this, 'S3URL', { value: asset.s3Url });
18+
new cdk.CfnOutput(this, 'S3ObjectUrl', { value: asset.s3ObjectUrl });
1819
/// !hide
1920

2021
// we need at least one resource

0 commit comments

Comments
 (0)