Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dynamodb): add billingMode, deletionProtection props #272

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

thoroc
Copy link

@thoroc thoroc commented Jun 21, 2024

Trying to address the missing properties coming from AWS CDK for DynamoDB Table.

Closes: #6753

Copy link

wing-cloud-platform bot commented Jun 21, 2024

AppStatusConsoleEndpointsUpdated (UTC)
eladb/winglibsStopped21-6-2024 0:2 (UTC)

@thoroc thoroc changed the title added props billingMode, removalPolicy and deletionProtection to DynamoDB construct dynamodb - added props billingMode, removalPolicy and deletionProtection to DynamoDB construct Jun 21, 2024
@thoroc thoroc changed the title dynamodb - added props billingMode, removalPolicy and deletionProtection to DynamoDB construct dynamodb: added props billingMode, removalPolicy and deletionProtection to DynamoDB construct Jun 21, 2024
dynamodb/dynamodb-types.w Outdated Show resolved Hide resolved
dynamodb/dynamodb.tf-aws.w Outdated Show resolved Hide resolved
@Chriscbr Chriscbr changed the title dynamodb: added props billingMode, removalPolicy and deletionProtection to DynamoDB construct feat(dynamodb): add billingMode, deletionProtection props Jul 8, 2024
Copy link
Contributor

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @thoroc! A few small comments but otherwise I'm cool merging it

Comment on lines +63 to +65
deletionProtectionEnabled: props.deletionProtection ?? false,
lifecycle: {
preventDestroy: props.deletionProtection ?? true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these fields default to the same value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a good catch. Yes that would make sense. I actually was wondering if there has been a wider discussion about having a system wide sensible default for those things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any built-in mechanisms at the moment -- perhaps we can add deletionProtection as a prop for more resources and eventually establish it as a convention of some sort.

Comment on lines +9 to +36
let tableWithBillingModeProvisioned = new dynamodb.Table({
billingMode: dynamodb_types.BillingMode.PROVISIONED,
attributes: [
{ name: "id", type: "S" },
],
hashKey: "id",
});

let simClient = dynamodb_sim.Util.createClient({
endpoint: "http:https://localhost:8000",
region: "us-west",
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

test "Sim: table with billing mode `provisioned`" {

let tableDescription = simClient.describeTable({
TableName: tableWithBillingModeProvisioned.tableName,
});

expect.equal(
tableDescription.billingMode,
dynamodb_types.BillingMode.PROVISIONED
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test will fail if you try running it on the tf-aws platform since it's directly calling into the dynamodb_sim implementation. If we want to scope this test just to run on the simulator, you can wrap all of it in a block like:

bring util;

if util.env("WING_TARGET") == "sim" {
  // resources...
  // tests ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing properties for Winglibs/DynamoDB
2 participants