5 ms·
For AWS users AWS CDK is a far better take on infrastructure as code - strongly typed TypeScript resources and higher level constructs that hide the underlying
by bsingh4 7y ago
For AWS users AWS CDK is a far better take on infrastructure as code - strongly typed TypeScript resources and higher level constructs that hide the underlying details of load balancers, IAM, etc. Pulumi was not as useful the last time I tried it - most resources were string key-value pairs with no typing or code completion. You're still referencing documentation to do anything and defining tons of low level resources to accomplish basic tasks. Might as well be writing raw Terraform or CloudFormation configs at that point, as they have more documentation available.
- reilly3000 7y agoSomething was wrong w/ your setup I think. All of their code has Typescript annotations, and their autocomplete w/ intellisense is remarkably useful.
- bsingh4 7y agoHere are two simple database definitions: Database in Pulumi: const db = new gcp.sql.DatabaseInstance('app-db', { databaseVersion: 'POSTGRES_11', region: 'us-central1', settings: { tier: 'db-f1-micro', diskType: 'PD_HDD', }, }); Database in AWS CDK: const db = new rds.DatabaseInstance(this, 'AppDb', { engine: rds.DatabaseInstanceEngine.POSTGRES, engineVersion: '11.5', instanceClass: ec2.InstanceType.of( ec2.InstanceClass.STANDARD5, ec2.InstanceSize.XLARGE ), storageType: rds.StorageType.GP2 }) Not to mention they have higher level constructs like DatabaseCluster that will handle the underlying details of replicas and create the lower level resources for you.
- bsingh4 7y agoI don't think large blocks of comments qualify as strong typing: https://github.com/pulumi/pulumi-gcp/blob/76df2e85214ad134652327fa78f2f29f50502eae/sdk/nodejs/sql/databaseInstance.ts https://github.com/pulumi/pulumi-gcp/blob/76df2e85214ad13465...
- antics 7y agoI don't think I understand, but am happy to help clarify. That is a TypeScript file where the type `DatabaseInstance` is defined. It's a completely normal TypeScript type—it will get picked up by editors, verified by the compiler, and so on. It is exactly the sort of type you'll find in CDK.
- antics 7y ago`DatabaseInstance` not only has TypeScript type definitions, it's actually written in pure TypeScript: https://github.com/pulumi/pulumi-gcp/blob/master/sdk/nodejs/sql/databaseInstance.ts https://github.com/pulumi/pulumi-gcp/blob/master/sdk/nodejs/... Pulumi also does have a number of higher-level constructs, which you can learn about here: https://www.pulumi.com/docs/guides/crosswalk/aws/ https://www.pulumi.com/docs/guides/crosswalk/aws/
- bsingh4 7y agoWhy is every single property of type string - to see what to put there I have to reference a comment in code? I shouldn't have to read comments to see what the magic string is for the f1-micro tier, or the hard disk type or the region. CDK has actual Enums for all of these things that work to make life easier. You're not making it any easier to code up a DatabaseInstance - its simply a bucket of keys and values where I'm looking up what those values should be.
- antics 7y agoAh—unions of strings (e.g., `"foo" | "bar"`) effectively are enums in TypeScript and JavaScript. They are autocompleted and type-checked at compile time, so you should get exactly the same behavior. Even exhaustiveness checking. See docs[1] for details. And, to the specific point: you absolutely should not have to look up the docs. These values definitely will autocomplete. Anyway, aside from all that, unions of strings is "the idiomatic way" to do this sort of thing in TypeScript and JavaScript. [1]: https://www.typescriptlang.org/docs/handbook/advanced-types.html https://www.typescriptlang.org/docs/handbook/advanced-types....
- bsingh4 7y agoNone of the properties in the DatabaseInstance construct example posted above are defined as unions of strings - the TypeScript documentation link you just posted is irrelevant. This is what one of the property types actually look like: /** * The MySQL or PostgreSQL version to * use. Can be `MYSQL_5_6`, `MYSQL_5_7`, `POSTGRES_9_6` or `POSTGRES_11` (beta) for second-generation * instances, or `MYSQL_5_5` or `MYSQL_5_6` for first-generation instances. * See [Second Generation Capabilities](https://cloud.google.com/sql/docs/1st-2nd-gen-differences) * for more information. */ readonly databaseVersion?: pulumi.Input<string>; In AWS CDK it was an easy task to select Postgres - in Pulumi case I had to read the comment.
- antics 7y agoHmm... just to set the record straight, Pulumi definitely does have TypeScript type definitions for all resource types, across all of our providers, and it has had them since our initial launch. Happy to help you debug why you're not getting type hints, drop me a line at alex@pulumi.com or on the community slack: https://slack.pulumi.com/ https://slack.pulumi.com/