Coder Social home page Coder Social logo

Comments (9)

Chriscbr avatar Chriscbr commented on July 23, 2024 1

That would be great - I'll assign the issue to you.

The simulator implementation of the Table class uses DynamoDB local (a version of DynamoDB you can run on a container), which ought to support most of the same props as the AWS Terraform provider. For any of the props that expect an enum like BillingMode or RemovalPolicy, I might suggest defining them as new enums in https://github.com/winglang/winglibs/blob/23d298a87242f793eaa2203f3e39fe1c3048dcc5/dynamodb/dynamodb-types.w to avoid taking on a dependency on aws-cdk-lib.

Happy to help provide any more pointers as needed 👍

from wing.

Chriscbr avatar Chriscbr commented on July 23, 2024 1

Ah - RemovalPolicy is an idiom specific to AWS CDK because it's related to CloudFormation specific behavior. See here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html.

I'm not sure there's a clear way to map this into the Terraform implementation. Terraform has a "lifecycle" hook that lets you specify that a resource shouldn't be destroyed, but it's not as full featured:

resource "aws_s3_bucket" "MyPreciousBucket" {
  lifecycle {
    prevent_destroy = true
  }
}

One option could be to say that if deletionProtection is enabled, then we should also add that to your Terraform. It could be added like this:

new tfaws.dynamodbTable.DynamodbTable({
  ...
  lifecycle: {
    preventDestroy: true,
  }
});

Deletion protection should be available (I see it listed in the Terraform Provider [here](https://registry.terraform.io/providers/hashicorp/aws/latest/doc. It's not available in the cdktf-aws-cdk repo you linked but it is in the cdktf-provider-aws repo - see here: https://github.com/cdktf/cdktf-provider-aws/blob/main/docs/dynamodbTable.typescript.md#dynamodbtableconfig-

from wing.

Chriscbr avatar Chriscbr commented on July 23, 2024 1

Yeah, that's a good question. I think the best option on the cloud side would be if we could just make some assertions about the configuration that's generated, similar to https://developer.hashicorp.com/terraform/cdktf/test/unit-tests#write-assertions. I'm not sure if it's possible to reuse these utilities in Wing at the moment though.

On the sim side maybe you can call the DescribeTable API inflight to confirm that the properties are set?

from wing.

Chriscbr avatar Chriscbr commented on July 23, 2024

Thanks for bringing this to our attention @thoroc! I think the ideal fix would be to add these missing properties to the TableProps type in @winglibs/dynamodb here and handle the new props in the implementation accordingly.

Pull requests are welcome!

from wing.

thoroc avatar thoroc commented on July 23, 2024

@Chriscbr I am open to create a PR for that, but I might need some guidance for the implementation.

from wing.

thoroc avatar thoroc commented on July 23, 2024

Just to confirm, I cannot see RemovalPolicy or the DeletionProtection in the cdktf-aws: https://github.com/hashicorp/cdktf-aws-cdk/blob/main/docs/dynamodbTable.md. Am I looking at the wrong place?

from wing.

thoroc avatar thoroc commented on July 23, 2024

Just opened a draft PR, but I need to investigate a bit more terraform to see if the options are available: winglang/winglibs#272

from wing.

thoroc avatar thoroc commented on July 23, 2024

Deletion protection should be available (I see it listed in the Terraform Provider

I was just playing with cdktf locally and I can confirm there is a props that seems to map to the same in aws cdk: deletionProtectionEnabled

I'll have a look at the solution you've suggested for removalPolicy.

from wing.

thoroc avatar thoroc commented on July 23, 2024

Just a question about testing. I am unsure how I would go about unit testing the new properties here.

For the tf side of things, should I expect a synthesised tf template?

For the sim side of things, I need to think about it.

from wing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.