diff --git a/docs/api/04-standard-library/aws/api-reference.md b/docs/api/04-standard-library/aws/api-reference.md
index 3df7541c23a..2651d0c2688 100644
--- a/docs/api/04-standard-library/aws/api-reference.md
+++ b/docs/api/04-standard-library/aws/api-reference.md
@@ -115,6 +115,7 @@ NOTE: This statement must be executed within an async context.
| --- | --- | --- |
| node
| constructs.Node
| The tree node. |
| bucketArn
| str
| The ARN of this bucket. |
+| bucketDomainName
| str
| The domain name of this bucket. |
| bucketName
| str
| The Name of this bucket. |
---
@@ -143,6 +144,18 @@ The ARN of this bucket.
---
+##### `bucketDomainName`Required
+
+```wing
+bucketDomainName: str;
+```
+
+- *Type:* str
+
+The domain name of this bucket.
+
+---
+
##### `bucketName`Required
```wing
@@ -1605,6 +1618,7 @@ A shared interface for AWS buckets.
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| bucketArn
| str
| AWS Bucket arn. |
+| bucketDomainName
| str
| Bucket domain name. |
| bucketName
| str
| AWS Bucket name. |
---
@@ -1621,6 +1635,18 @@ AWS Bucket arn.
---
+##### `bucketDomainName`Required
+
+```wing
+bucketDomainName: str;
+```
+
+- *Type:* str
+
+Bucket domain name.
+
+---
+
##### `bucketName`Required
```wing
diff --git a/packages/@winglang/platform-awscdk/src/bucket.ts b/packages/@winglang/platform-awscdk/src/bucket.ts
index dac156b8e5f..0c04077feeb 100644
--- a/packages/@winglang/platform-awscdk/src/bucket.ts
+++ b/packages/@winglang/platform-awscdk/src/bucket.ts
@@ -245,6 +245,10 @@ export class Bucket extends cloud.Bucket implements IAwsBucket {
public get bucketName(): string {
return this.bucket.bucketName;
}
+
+ public get bucketDomainName(): string {
+ return this.bucket.bucketDomainName;
+ }
}
export function createEncryptedBucket(
diff --git a/packages/@winglang/sdk/src/shared-aws/bucket.ts b/packages/@winglang/sdk/src/shared-aws/bucket.ts
index aa275baae35..68f6ccc770c 100644
--- a/packages/@winglang/sdk/src/shared-aws/bucket.ts
+++ b/packages/@winglang/sdk/src/shared-aws/bucket.ts
@@ -15,6 +15,11 @@ export interface IAwsBucket {
*/
readonly bucketArn: string;
+ /**
+ * Bucket domain name
+ */
+ readonly bucketDomainName: string;
+
/**
* AWS Bucket name
*/
@@ -81,12 +86,17 @@ export class BucketRef extends Resource {
*/
public readonly bucketArn: string;
+ /**
+ * The domain name of this bucket.
+ */
+ public readonly bucketDomainName: string;
+
constructor(scope: Construct, id: string, bucketName: string) {
super(scope, id);
this.bucketName = bucketName;
this.bucketArn = `arn:aws:s3:::${bucketName}`;
-
+ this.bucketDomainName = `${bucketName}.s3.amazonaws.com`;
const target = App.of(this)._target;
if (target === "sim") {
this.addUserInterface();
diff --git a/packages/@winglang/sdk/src/target-tf-aws/bucket.ts b/packages/@winglang/sdk/src/target-tf-aws/bucket.ts
index 3b7acdac6d4..b3b5ce03559 100644
--- a/packages/@winglang/sdk/src/target-tf-aws/bucket.ts
+++ b/packages/@winglang/sdk/src/target-tf-aws/bucket.ts
@@ -211,6 +211,10 @@ export class Bucket extends cloud.Bucket implements IAwsBucket {
public get bucketName(): string {
return this.bucket.bucket;
}
+
+ public get bucketDomainName(): string {
+ return this.bucket.bucketDomainName;
+ }
}
export function createEncryptedBucket(
diff --git a/tests/sdk_tests/bucket/aws-bucket.test.w b/tests/sdk_tests/bucket/aws-bucket.test.w
index d9e6078e232..2c1eeb8f1e6 100644
--- a/tests/sdk_tests/bucket/aws-bucket.test.w
+++ b/tests/sdk_tests/bucket/aws-bucket.test.w
@@ -8,6 +8,7 @@ let getBucketInfo = (b: cloud.Bucket): Map? => {
return {
bucketName: bucket.bucketName,
bucketArn: bucket.bucketArn,
+ bucketDomainName: bucket.bucketDomainName
};
}
return nil;
@@ -20,10 +21,12 @@ test "validates the AWS Bucket" {
if @target == "tf-aws" {
assert(bucket.get("bucketArn").contains("arn:aws:s3:::aws-wing-bucket"));
assert(bucket.get("bucketName").contains("aws-wing-bucket"));
+ assert(bucket.get("bucketDomainName").contains("aws-wing-bucket.s3.amazonaws.com"));
} else { // If it's not a 'tf-aws' target, it's an 'awscdk'
assert(bucket.get("bucketArn").contains("arn:aws:s3:::"));
assert(bucket.get("bucketArn").contains("awswingbucket"));
assert(bucket.get("bucketName").contains("awswingbucket"));
+ assert(bucket.get("bucketDomainName").contains("awswingbucket.s3.amazonaws.com"));
}
} else {
// If the test is not on AWS, it should not fail, so I am returning true.
diff --git a/tests/sdk_tests/bucket/bucket-ref.test.w b/tests/sdk_tests/bucket/bucket-ref.test.w
index e7b6c6abcd7..46b860cfb78 100644
--- a/tests/sdk_tests/bucket/bucket-ref.test.w
+++ b/tests/sdk_tests/bucket/bucket-ref.test.w
@@ -22,6 +22,7 @@ if @target == "sim" {
test "bucketArn returns the arn" {
expect.equal(dummyArn, br.bucketArn);
expect.equal(dummyName, br.bucketName);
+ expect.equal(dummyName + ".s3.amazonaws.com", br.bucketDomainName);
}
test "get() sends a request to aws, fails because we are using a dummy bucket" {