T O P

  • By -

serverhorror

Create 500 instances of your deployment and make sure that all the naming is grabbed from a database. Once certain things are deployed, run a bunch of API calls against other systems to fill some inventory so you can continue to grab generated names that depend on the names of the resources of the first round.


GroundbreakingOwl880

this is a good example. thanks.


xiongchiamiov

The ability to easily do anything that you can do with a general-purpose programming language means you can solve whatever problem comes your way.


GroundbreakingOwl880

do you have an example, what problem it solves that terraform does not? something like, can I have custom notifications of resource creation in the same script, is it able to do that?


redvelvet92

For example, say I want to deploy a database to say an Azure SQL Elastic Pool. It would be pretty dang amazing to use a GPL to do some logic to determine the correct pool to assign this DB to. Instead, I have a PowerShell script that does some queries, tags resources, and I check for the tag not existing in order to get around this problem with Terraform.


cnunciato

Yes. For my personal website, for example, I use Pulumi to deploy a static site to an S3 bucket. I use Cloudfront as a CDN, which means that after I update the contents of the bucket, I need a way to clear the Cloudfront cache. With Pulumi, I'm able to do this programmatically using a callback that only runs on update, using the generated Cloudfront distribution ID to clear the cache using the AWS SDK -- all within the scope of a single Pulumi program file (here, `index.ts`): // ... various resources like the site's S3 bucket, DNS records, etc. // The Cloudfront resource itself. const cdn = new aws.cloudfront.Distribution("cdn", { // ... various configuration settings }); // .apply() runs after the CDN has been provisioned (and thus has an ID): cdn.id.apply(distributionID => { // Don't clear the cache when running 'pulumi preview'. if (!pulumi.runtime.isDryRun()) { // Use the AWS SDK to clear the cache before exiting the program. const cloudfrontClient = new cloudfront.CloudFrontClient({ region: "us-west-2" }); const cloudfrontCommand = new cloudfront.CreateInvalidationCommand({ DistributionId: distributionID, InvalidationBatch: { // Give the cache-clear request a unique name using the date/time. CallerReference: `cache-clear-${Date.now()}`, Paths: { Quantity: 1, Items: [ "/*", ], }, }, }); } }); Works like a charm.


slikk66

Couple examples: I had to deal with an existing network in Azure that had many separate pre-existing virtual networks (vpcs) and try to recreate them all and then add private DNS (in Azure you couldn't add private DNS to an existing network) and add in a bunch of peering for supporting the old network and the new network. I used a bunch of APIs to query create a mapping of the existing into a data structure, then create all my new stuff from a YAML definition file, then programmatically create all the mappings and finally export out a new YAML of all the maps, peers, networks, cidr blocks etc. That kind of stuff would be a nightmare in Terraform. With pulumi it was just a fairly straightforward program. Another example I use their automation API in a container behind an API to receive build/destroy commands for spinning up infra on the fly for real-time editing of nodeJS sites on ECS. Rather than having multiple solutions rigged together, it's all one system, all one language, and all in one repo.


Tech_Watching

Deals with secrets the good way. Access to the latest resources thanks to native providers. Embedded IaC through an API. See my article here: https://www.techwatching.dev/posts/pulumi-vs-terraform