hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 456 forks source link

docs(constructs.mdx) #3711

Closed polyglotm closed 3 months ago

polyglotm commented 3 months ago

I changed the example.

In TaggedS3Bucket example this documents re-assigne value into this.tagsInput with spread operator like this.

this.tagsInput = {
     ...this.tagsInput,
     owner: "my-team",
     purpose: "storage",
};

I changed to

Object.assign(this.tagsInput, {
    owner: "my-team",
    purpose: "storage"
});

What’s the difference?

When use … AKA spread operator is a kind of duplicate mechanism And usually use for dont want impact to original value.

When using Object.assign it’s just extend the original object

In this document example …this.tagsInput is used for assing itself. which means generate new object and assign to original object It’s working but not best practice.

If you change to Object.assign approach (my offer)

  1. There are tiny performance difference
  2. And who read this documents they instintly understand ‘oh this guy extends object’

I love Terraform, and I wish Terraform document offer best practice Thank you.

hashicorp-cla-app[bot] commented 3 months ago

CLA assistant check
All committers have signed the CLA.

hashicorp-cla-app[bot] commented 3 months ago

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

github-actions[bot] commented 2 months ago

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.