Skip to content

Commit

Permalink
fix(sdk): some fixes and minor refactoring (#7234)
Browse files Browse the repository at this point in the history
I made two small corrections and a refactoring in this PR:

1. There was an error in an environment variable related to the bucket name that was passed in the aws-cdk build.
2. When updating the lambda function log, I assigned the new enum to the old variable, but I have now corrected it to the proper variable.
3. It didn't make sense to have a file just to keep a global variable related to the Counter, so I removed the file and moved the global variable to the shared-aws/counter.ts file.

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
marciocadev authored Jan 6, 2025
1 parent 332bd69 commit 680203a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions packages/@winglang/platform-awscdk/src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class Bucket extends cloud.Bucket implements IAwsBucket {
/** @internal */
public _liftedState(): Record<string, string> {
return {
$url: `process.env["${this.envName()}"]`,
$bucketName: `process.env["${this.envName()}"]`,
};
}

Expand Down Expand Up @@ -265,11 +265,11 @@ export function createEncryptedBucket(
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: isPublic
? {
blockPublicAcls: false,
blockPublicPolicy: false,
ignorePublicAcls: false,
restrictPublicBuckets: false,
}
blockPublicAcls: false,
blockPublicPolicy: false,
ignorePublicAcls: false,
restrictPublicBuckets: false,
}
: BlockPublicAccess.BLOCK_ALL,
publicReadAccess: isPublic ? true : false,
removalPolicy: RemovalPolicy.DESTROY,
Expand Down
3 changes: 1 addition & 2 deletions packages/@winglang/platform-awscdk/src/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { RemovalPolicy } from "aws-cdk-lib";
import { AttributeType, BillingMode, Table } from "aws-cdk-lib/aws-dynamodb";
import { Construct } from "constructs";
import { cloud, std } from "@winglang/sdk";
import { COUNTER_HASH_KEY } from "@winglang/sdk/lib/shared-aws/commons";
import { calculateCounterPermissions } from "@winglang/sdk/lib/shared-aws/permissions";
import { IAwsCounter } from "@winglang/sdk/lib/shared-aws/counter";
import { IAwsCounter, COUNTER_HASH_KEY } from "@winglang/sdk/lib/shared-aws/counter";
import { addPolicyStatements, isAwsCdkFunction } from "./function";
import { InflightClient, LiftMap } from "@winglang/sdk/lib/core";

Expand Down
2 changes: 1 addition & 1 deletion packages/@winglang/platform-awscdk/src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Function
memorySize: props.memory ?? 1024,
architecture: Architecture.ARM_64,
logGroup: logs,
logFormat: LoggingFormat.JSON,
loggingFormat: LoggingFormat.JSON,
});
}

Expand Down
1 change: 0 additions & 1 deletion packages/@winglang/sdk/src/shared-aws/commons.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/@winglang/sdk/src/shared-aws/counter.inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
GetItemCommand,
DynamoDBClient,
} from "@aws-sdk/client-dynamodb";
import { COUNTER_HASH_KEY } from "./commons";
import { COUNTER_HASH_KEY } from "./counter";
import type { ICounterClient } from "../cloud";

const AMOUNT_TOKEN = "amount";
Expand Down
2 changes: 2 additions & 0 deletions packages/@winglang/sdk/src/shared-aws/counter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { cloud } from "..";

export const COUNTER_HASH_KEY = "id";

/**
* A shared interface for AWS Counter.
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/@winglang/sdk/src/target-tf-aws/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as cloud from "../cloud";
import * as core from "../core";
import { NameOptions, ResourceNames } from "../shared/resource-names";
import { AwsInflightHost } from "../shared-aws";
import { COUNTER_HASH_KEY } from "../shared-aws/commons";
import { IAwsCounter } from "../shared-aws/counter";
import { IAwsCounter, COUNTER_HASH_KEY } from "../shared-aws/counter";
import { calculateCounterPermissions } from "../shared-aws/permissions";
import { IInflightHost } from "../std";

Expand Down

0 comments on commit 680203a

Please sign in to comment.