From 291715b383be8baa4d6b2bd8443ced18f2d58033 Mon Sep 17 00:00:00 2001 From: Shai Ber Date: Tue, 29 Oct 2024 14:02:06 +0200 Subject: [PATCH 1/4] add bucketDomainName to IAwsBucket --- packages/@winglang/platform-awscdk/src/bucket.ts | 4 ++++ packages/@winglang/sdk/src/shared-aws/bucket.ts | 5 +++++ packages/@winglang/sdk/src/target-tf-aws/bucket.ts | 4 ++++ 3 files changed, 13 insertions(+) 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..f696ab78c06 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 */ 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( From cfe3268b3891ee0837db85d2d5ce8348b4c40524 Mon Sep 17 00:00:00 2001 From: Shai Ber Date: Tue, 29 Oct 2024 14:13:46 +0200 Subject: [PATCH 2/4] add bucketDomainName to BucketRef --- packages/@winglang/sdk/src/shared-aws/bucket.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@winglang/sdk/src/shared-aws/bucket.ts b/packages/@winglang/sdk/src/shared-aws/bucket.ts index f696ab78c06..68f6ccc770c 100644 --- a/packages/@winglang/sdk/src/shared-aws/bucket.ts +++ b/packages/@winglang/sdk/src/shared-aws/bucket.ts @@ -86,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(); From ebdcd9f61b6fbdc534f532ed42dc2848d7ea7aec Mon Sep 17 00:00:00 2001 From: Shai Ber Date: Tue, 29 Oct 2024 14:14:00 +0200 Subject: [PATCH 3/4] add tests --- tests/sdk_tests/bucket/aws-bucket.test.w | 3 +++ tests/sdk_tests/bucket/bucket-ref.test.w | 1 + 2 files changed, 4 insertions(+) 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" { From ef1acc9c0bbeef19e47d92fb2cd5cae1dbb31286 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Tue, 29 Oct 2024 12:30:11 +0000 Subject: [PATCH 4/4] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- .../04-standard-library/aws/api-reference.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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