aws-cloudformation / cloudformation-pkl

Apache License 2.0
9 stars 2 forks source link

Use global `Tag` instead of module specific tag #9

Open henriqueleite42 opened 3 weeks ago

henriqueleite42 commented 3 weeks ago

Currently, each resource that accepts tags uses its own typing:

https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/organizations/account.pkl [https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/organizations/account.pkl](https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/organizations/account.pkl)

https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/certificatemanager/certificate.pkl [https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/certificatemanager/certificate.pkl](https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/certificatemanager/certificate.pkl)

https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/apigatewayv2/api.pkl [https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/apigatewayv2/api.pkl](https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/apigatewayv2/api.pkl)

https://github.com/aws-cloudformation/cloudformation-pkl/blob/main/package/aws/s3/bucket.pkl [
![image](https://github.com/aws-cloudformation/cloudformation-pkl/assets/50992814/56024a8e-116f-4eaa-a7cb-aaa4c959e60d)
](
![image](https://github.com/aws-cloudformation/cloudformation-pkl/assets/50992814/4a4ac857-3450-4b5c-98d8-e8f703cb4ffd)
)

What I get, I some cases you need extra validation, like in the AccountTag, but most of the places you will have the exactly same thing:

open class Tag {
    Key: String|Mapping
    Value: String|Mapping
}

Having multiple classes to do the same thing makes it impossible to use something like "default tags" for the resources, what would be very useful to create tags for the environment or similar repetitive tags.

Currently, if you try to do it, you get the error: image

ericzbeard commented 2 weeks ago

The problem is that tags are modeled and implemented differently per resource, so I'm not sure if we can effectively abstract them out to a higher level definition.